Title: [137627] trunk/Source
- Revision
- 137627
- Author
- [email protected]
- Date
- 2012-12-13 11:23:23 -0800 (Thu, 13 Dec 2012)
Log Message
Allow plugins to be disabled by shared library filename
https://bugs.webkit.org/show_bug.cgi?id=101274
Patch by Parth Patel <[email protected]>, Max Feil <[email protected]> on 2012-12-13
Reviewed by Antonio Gomes.
Source/WebCore:
This fix makes PluginDatabase changes general so that other ports
can use this mechanism if they wish.
Layout test not included with this patch because there
is currently no framework within LayoutTests to allow calls
from an external application via platform API code (such as the
WebView API).
* plugins/PluginDatabase.cpp:
(WebCore::PluginDatabase::fileExistsAndIsNotDisabled):
(WebCore):
(WebCore::PluginDatabase::getDeletedPlugins):
(WebCore::PluginDatabase::removeDisabledPluginFile):
(WebCore::PluginDatabase::addDisabledPluginFile):
(WebCore::PluginDatabase::getPluginPathsInDirectories):
* plugins/PluginDatabase.h:
(PluginDatabase):
Source/WebKit/blackberry:
Mechanism allows plugins to be disabled by specifying their shared library filenames.
Once disabled, a plugin's shared library should never be loaded.
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPage::setExtraPluginDirectory):
(WebKit):
(BlackBerry::WebKit::WebPage::updateDisabledPluginFiles):
* Api/WebPage.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (137626 => 137627)
--- trunk/Source/WebCore/ChangeLog 2012-12-13 19:16:29 UTC (rev 137626)
+++ trunk/Source/WebCore/ChangeLog 2012-12-13 19:23:23 UTC (rev 137627)
@@ -1,3 +1,28 @@
+2012-12-13 Parth Patel <[email protected]>, Max Feil <[email protected]>
+
+ Allow plugins to be disabled by shared library filename
+ https://bugs.webkit.org/show_bug.cgi?id=101274
+
+ Reviewed by Antonio Gomes.
+
+ This fix makes PluginDatabase changes general so that other ports
+ can use this mechanism if they wish.
+
+ Layout test not included with this patch because there
+ is currently no framework within LayoutTests to allow calls
+ from an external application via platform API code (such as the
+ WebView API).
+
+ * plugins/PluginDatabase.cpp:
+ (WebCore::PluginDatabase::fileExistsAndIsNotDisabled):
+ (WebCore):
+ (WebCore::PluginDatabase::getDeletedPlugins):
+ (WebCore::PluginDatabase::removeDisabledPluginFile):
+ (WebCore::PluginDatabase::addDisabledPluginFile):
+ (WebCore::PluginDatabase::getPluginPathsInDirectories):
+ * plugins/PluginDatabase.h:
+ (PluginDatabase):
+
2012-12-13 Yongjun Zhang <[email protected]>
Document will never be released when an Image is created inside unload event listener
Modified: trunk/Source/WebCore/plugins/PluginDatabase.cpp (137626 => 137627)
--- trunk/Source/WebCore/plugins/PluginDatabase.cpp 2012-12-13 19:16:29 UTC (rev 137626)
+++ trunk/Source/WebCore/plugins/PluginDatabase.cpp 2012-12-13 19:23:23 UTC (rev 137627)
@@ -312,11 +312,20 @@
m_preferredPlugins.set(mimeType.lower(), plugin);
}
+bool PluginDatabase::fileExistsAndIsNotDisabled(const String& filePath) const
+{
+ // Skip plugin files that are disabled by filename.
+ if (m_disabledPluginFiles.contains(pathGetFileName(filePath)))
+ return false;
+
+ return fileExists(filePath);
+}
+
void PluginDatabase::getDeletedPlugins(PluginSet& plugins) const
{
PluginSet::const_iterator end = m_plugins.end();
for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
- if (!fileExists((*it)->path()))
+ if (!fileExistsAndIsNotDisabled((*it)->path()))
plugins.add(*it);
}
}
@@ -360,6 +369,20 @@
#endif
}
+bool PluginDatabase::removeDisabledPluginFile(const String& fileName)
+{
+ if (!m_disabledPluginFiles.contains(fileName))
+ return false;
+
+ m_disabledPluginFiles.remove(fileName);
+ return true;
+}
+
+bool PluginDatabase::addDisabledPluginFile(const String& fileName)
+{
+ return m_disabledPluginFiles.add(fileName).isNewEntry;
+}
+
#if (!OS(WINCE)) && (!OS(WINDOWS) || !ENABLE(NETSCAPE_PLUGIN_API))
// For Safari/Win the following three methods are implemented
// in PluginDatabaseWin.cpp, but if we can use WebCore constructs
@@ -462,7 +485,7 @@
Vector<String> pluginPaths = listDirectory(*dIt, fileNameFilter);
Vector<String>::const_iterator pluginsEnd = pluginPaths.end();
for (Vector<String>::const_iterator pIt = pluginPaths.begin(); pIt != pluginsEnd; ++pIt) {
- if (!fileExists(*pIt))
+ if (!fileExistsAndIsNotDisabled(*pIt))
continue;
paths.add(*pIt);
Modified: trunk/Source/WebCore/plugins/PluginDatabase.h (137626 => 137627)
--- trunk/Source/WebCore/plugins/PluginDatabase.h 2012-12-13 19:16:29 UTC (rev 137626)
+++ trunk/Source/WebCore/plugins/PluginDatabase.h 2012-12-13 19:23:23 UTC (rev 137627)
@@ -75,6 +75,8 @@
m_pluginDirectories = directories;
}
+ bool removeDisabledPluginFile(const String& fileName);
+ bool addDisabledPluginFile(const String& fileName);
static Vector<String> defaultPluginDirectories();
Vector<String> pluginDirectories() const { return m_pluginDirectories; }
@@ -89,6 +91,7 @@
private:
void getPluginPathsInDirectories(HashSet<String>&) const;
void getDeletedPlugins(PluginSet&) const;
+ bool fileExistsAndIsNotDisabled(const String&) const;
// Returns whether the plugin was actually added or not (it won't be added if it's a duplicate of an existing plugin).
bool add(PassRefPtr<PluginPackage>);
@@ -98,6 +101,7 @@
void updatePersistentMetadataCache();
#endif
+ HashSet<String> m_disabledPluginFiles;
Vector<String> m_pluginDirectories;
HashSet<String> m_registeredMIMETypes;
PluginSet m_plugins;
Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (137626 => 137627)
--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2012-12-13 19:16:29 UTC (rev 137626)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2012-12-13 19:23:23 UTC (rev 137627)
@@ -5153,6 +5153,66 @@
(*it)->clearSiteData(String());
}
+void WebPage::setExtraPluginDirectory(const BlackBerry::Platform::String& path)
+{
+ PluginDatabase* database = PluginDatabase::installedPlugins(true /* true for loading default directories */);
+ if (!database)
+ return;
+
+ Vector<String> pluginDirectories = database->pluginDirectories();
+ if (path.empty() || pluginDirectories.contains(path)
+ return;
+
+ pluginDirectories.append(path);
+ database->setPluginDirectories(pluginDirectories);
+ // Clear out every Page's local copy of PluginData, so it will
+ // retrieve it again when necessary. Otherwise each page will be
+ // using old data and may either direct content to a plugin that
+ // doesn't exist (causing a crash) or not direct content to a plugin
+ // that does exist. We do this even if plugins are disabled because
+ // this step is not done when plugins get enabled.
+
+ // True only needs to be passed here if we want to reload each frame
+ // in the page's frame tree. Here we are passing false for minimum disruption,
+ // and because this does exactly what we need and nothing more: refresh the plugin data.
+ d->m_page->refreshPlugins(false /* false for minimum disruption as described above */);
+
+ if (d->m_webSettings->arePluginsEnabled())
+ database->refresh();
+}
+
+void WebPage::updateDisabledPluginFiles(const BlackBerry::Platform::String& fileName, bool disabled)
+{
+ // Passing true will set plugin database with default plugin directories and refresh it.
+ PluginDatabase* database = PluginDatabase::installedPlugins(true /* true for loading default directories */);
+ if (!database)
+ return;
+
+ if (disabled) {
+ if (!database->addDisabledPluginFile(fileName))
+ return;
+ } else {
+ if (!database->removeDisabledPluginFile(fileName))
+ return;
+ }
+
+ // Clear out every Page's local copy of PluginData, so it will
+ // retrieve it again when necessary. Otherwise each page will be
+ // using old data and may either direct content to a plugin that
+ // doesn't exist (causing a crash) or not direct content to a plugin
+ // that does exist. We do this even if plugins are disabled because
+ // this step is not done when plugins get enabled.
+
+ // True only needs to be passed here if we want to reload each frame
+ // in the page's frame tree. Here we are passing false for minimum disruption,
+ // and because this does exactly what we need and nothing more: refresh the plugin data.
+ d->m_page->refreshPlugins(false /* false for minimum disruption as described above */);
+
+ // Refresh the plugin database if necessary.
+ if (d->m_webSettings->arePluginsEnabled())
+ database->refresh();
+}
+
void WebPage::onNetworkAvailabilityChanged(bool available)
{
updateOnlineStatus(available);
Modified: trunk/Source/WebKit/blackberry/Api/WebPage.h (137626 => 137627)
--- trunk/Source/WebKit/blackberry/Api/WebPage.h 2012-12-13 19:16:29 UTC (rev 137626)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.h 2012-12-13 19:23:23 UTC (rev 137627)
@@ -331,6 +331,8 @@
void notifyScreenPowerStateChanged(bool powered);
void notifyFullScreenVideoExited(bool done);
void clearPluginSiteData();
+ void setExtraPluginDirectory(const BlackBerry::Platform::String& path);
+ void updateDisabledPluginFiles(const BlackBerry::Platform::String& fileName, bool disabled);
void setJavaScriptCanAccessClipboard(bool);
bool isWebGLEnabled() const;
void setWebGLEnabled(bool);
Modified: trunk/Source/WebKit/blackberry/ChangeLog (137626 => 137627)
--- trunk/Source/WebKit/blackberry/ChangeLog 2012-12-13 19:16:29 UTC (rev 137626)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2012-12-13 19:23:23 UTC (rev 137627)
@@ -1,3 +1,19 @@
+2012-12-13 Parth Patel <[email protected]>, Max Feil <[email protected]>
+
+ Allow plugins to be disabled by shared library filename
+ https://bugs.webkit.org/show_bug.cgi?id=101274
+
+ Reviewed by Antonio Gomes.
+
+ Mechanism allows plugins to be disabled by specifying their shared library filenames.
+ Once disabled, a plugin's shared library should never be loaded.
+
+ * Api/WebPage.cpp:
+ (BlackBerry::WebKit::WebPage::setExtraPluginDirectory):
+ (WebKit):
+ (BlackBerry::WebKit::WebPage::updateDisabledPluginFiles):
+ * Api/WebPage.h:
+
2012-12-12 Gyuyoung Kim <[email protected]>
NetworkInfoController needs to support destructor
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes