Title: [153877] trunk
Revision
153877
Author
[email protected]
Date
2013-08-08 23:44:27 -0700 (Thu, 08 Aug 2013)

Log Message

navigator.plugins has plugins in it when plugins are disabled
https://bugs.webkit.org/show_bug.cgi?id=119607
<rdar://problem/14678030>

Reviewed by Anders Carlsson.

Test: plugins/navigator-plugins-disabled.html

* page/Settings.cpp:
(WebCore::Settings::setPluginsEnabled):
Refresh the plugin database when plugins are enabled or disabled.
This is necessary to ensure that navigator.plugins will have the
correct set of plugins after dynamically changing whether plugins
are enabled, which makes the test for this patch possible (but it
makes sense in the browser as well).

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::getPlugins):
Return a list of all plugins, and a list of only application plugins.

* UIProcess/WebProcessProxy.h:
* UIProcess/WebProcessProxy.messages.in:
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::getPluginInfo):
Add applicationPlugin parameter to getPlugins, and storage for the returned list.

(WebKit::WebPlatformStrategies::populatePluginCache):
If plugins are disabled for the given page, give WebCore the list that
only includes application plugins. Otherwise, give it the whole list
as we are doing currently.

* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::getPluginInfo):
If plugins are disabled for the given page, give WebCore an empty list of
plugins. If WebKit1 had any application plugins, we'd return just them
instead.

Add a test that ensures that navigator.plugins only contains
application plugins when plugins are disabled.

* plugins/navigator-plugins-disabled-expected.txt: Added.
* plugins/navigator-plugins-disabled.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (153876 => 153877)


--- trunk/LayoutTests/ChangeLog	2013-08-09 06:39:52 UTC (rev 153876)
+++ trunk/LayoutTests/ChangeLog	2013-08-09 06:44:27 UTC (rev 153877)
@@ -1,3 +1,17 @@
+2013-08-08  Tim Horton  <[email protected]>
+
+        navigator.plugins has plugins in it when plugins are disabled
+        https://bugs.webkit.org/show_bug.cgi?id=119607
+        <rdar://problem/14678030>
+
+        Reviewed by Anders Carlsson.
+
+        Add a test that ensures that navigator.plugins only contains
+        application plugins when plugins are disabled.
+
+        * plugins/navigator-plugins-disabled-expected.txt: Added.
+        * plugins/navigator-plugins-disabled.html: Added.
+
 2013-08-08  Timothy Hatcher  <[email protected]>
 
         Allow SVG images to be drawn into canvas without tainting.

Added: trunk/LayoutTests/plugins/navigator-plugins-disabled-expected.txt (0 => 153877)


--- trunk/LayoutTests/plugins/navigator-plugins-disabled-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/plugins/navigator-plugins-disabled-expected.txt	2013-08-09 06:44:27 UTC (rev 153877)
@@ -0,0 +1 @@
+Passed!

Added: trunk/LayoutTests/plugins/navigator-plugins-disabled.html (0 => 153877)


--- trunk/LayoutTests/plugins/navigator-plugins-disabled.html	                        (rev 0)
+++ trunk/LayoutTests/plugins/navigator-plugins-disabled.html	2013-08-09 06:44:27 UTC (rev 153877)
@@ -0,0 +1,26 @@
+<html>
+<head>
+    <title>Test if navigator.plugins is (mostly) empty when plugins are disabled.</title>
+<body>
+<script>
+if (window.testRunner) {
+    testRunner.setPluginsEnabled(false);
+    testRunner.dumpAsText();
+}
+
+var hasNonApplicationPlugin = false;
+
+for (var i = 0; i < navigator.plugins.length; ++i) {
+    var plugin = navigator.plugins[i];
+
+    // Application plugins have an empty filename and are OK even when plugins are disabled.
+    if (plugin.filename != "") {
+        hasNonApplicationPlugin = true;
+        document.write("Found non-application plug-in: " + plugin.name + "<br>");
+    }
+}
+
+document.write(hasNonApplicationPlugin ? "Failed!" : "Passed!");
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (153876 => 153877)


--- trunk/Source/WebCore/ChangeLog	2013-08-09 06:39:52 UTC (rev 153876)
+++ trunk/Source/WebCore/ChangeLog	2013-08-09 06:44:27 UTC (rev 153877)
@@ -1,3 +1,21 @@
+2013-08-08  Tim Horton  <[email protected]>
+
+        navigator.plugins has plugins in it when plugins are disabled
+        https://bugs.webkit.org/show_bug.cgi?id=119607
+        <rdar://problem/14678030>
+
+        Reviewed by Anders Carlsson.
+
+        Test: plugins/navigator-plugins-disabled.html
+
+        * page/Settings.cpp:
+        (WebCore::Settings::setPluginsEnabled):
+        Refresh the plugin database when plugins are enabled or disabled.
+        This is necessary to ensure that navigator.plugins will have the
+        correct set of plugins after dynamically changing whether plugins
+        are enabled, which makes the test for this patch possible (but it
+        makes sense in the browser as well).
+
 2013-08-08  Timothy Hatcher  <[email protected]>
 
         Allow SVG images to be drawn into canvas without tainting.

Modified: trunk/Source/WebCore/page/Settings.cpp (153876 => 153877)


--- trunk/Source/WebCore/page/Settings.cpp	2013-08-09 06:39:52 UTC (rev 153876)
+++ trunk/Source/WebCore/page/Settings.cpp	2013-08-09 06:44:27 UTC (rev 153877)
@@ -390,7 +390,11 @@
 
 void Settings::setPluginsEnabled(bool arePluginsEnabled)
 {
+    if (m_arePluginsEnabled == arePluginsEnabled)
+        return;
+
     m_arePluginsEnabled = arePluginsEnabled;
+    Page::refreshPlugins(false);
 }
 
 void Settings::setPrivateBrowsingEnabled(bool privateBrowsingEnabled)

Modified: trunk/Source/WebKit/mac/ChangeLog (153876 => 153877)


--- trunk/Source/WebKit/mac/ChangeLog	2013-08-09 06:39:52 UTC (rev 153876)
+++ trunk/Source/WebKit/mac/ChangeLog	2013-08-09 06:44:27 UTC (rev 153877)
@@ -1,3 +1,17 @@
+2013-08-08  Tim Horton  <[email protected]>
+
+        navigator.plugins has plugins in it when plugins are disabled
+        https://bugs.webkit.org/show_bug.cgi?id=119607
+        <rdar://problem/14678030>
+
+        Reviewed by Anders Carlsson.
+
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        (WebPlatformStrategies::getPluginInfo):
+        If plugins are disabled for the given page, give WebCore an empty list of
+        plugins. If WebKit1 had any application plugins, we'd return just them
+        instead.
+
 2013-08-06  Stephanie Lewis  <[email protected]>
 
         Update Order Files for Safari

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm (153876 => 153877)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm	2013-08-09 06:39:52 UTC (rev 153876)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm	2013-08-09 06:44:27 UTC (rev 153877)
@@ -126,10 +126,14 @@
     [[WebPluginDatabase sharedDatabase] refresh];
 }
 
-void WebPlatformStrategies::getPluginInfo(const Page*, Vector<PluginInfo>& plugins)
+void WebPlatformStrategies::getPluginInfo(const Page* page, Vector<PluginInfo>& plugins)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
+    // WebKit1 has no application plug-ins, so we don't need to add them here.
+    if (!page->mainFrame()->loader()->subframeLoader()->allowPlugins(NotAboutToInstantiatePlugin))
+        return;
+
     NSArray* pluginsArray = [[WebPluginDatabase sharedDatabase] plugins];
     for (unsigned int i = 0; i < [pluginsArray count]; ++i) {
         WebPluginPackage *plugin = [pluginsArray objectAtIndex:i];

Modified: trunk/Source/WebKit2/ChangeLog (153876 => 153877)


--- trunk/Source/WebKit2/ChangeLog	2013-08-09 06:39:52 UTC (rev 153876)
+++ trunk/Source/WebKit2/ChangeLog	2013-08-09 06:44:27 UTC (rev 153877)
@@ -1,3 +1,27 @@
+2013-08-08  Tim Horton  <[email protected]>
+
+        navigator.plugins has plugins in it when plugins are disabled
+        https://bugs.webkit.org/show_bug.cgi?id=119607
+        <rdar://problem/14678030>
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::getPlugins):
+        Return a list of all plugins, and a list of only application plugins.
+
+        * UIProcess/WebProcessProxy.h:
+        * UIProcess/WebProcessProxy.messages.in:
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::getPluginInfo):
+        Add applicationPlugin parameter to getPlugins, and storage for the returned list.
+
+        (WebKit::WebPlatformStrategies::populatePluginCache):
+        If plugins are disabled for the given page, give WebCore the list that
+        only includes application plugins. Otherwise, give it the whole list
+        as we are doing currently.
+
 2013-08-08  Gavin Barraclough  <[email protected]>
 
         Disable suppression of plugin process for Java

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (153876 => 153877)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2013-08-09 06:39:52 UTC (rev 153876)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2013-08-09 06:44:27 UTC (rev 153877)
@@ -306,7 +306,7 @@
 }
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
-void WebProcessProxy::getPlugins(bool refresh, Vector<PluginInfo>& plugins)
+void WebProcessProxy::getPlugins(bool refresh, Vector<PluginInfo>& plugins, Vector<PluginInfo>& applicationPlugins)
 {
     if (refresh)
         m_context->pluginInfoStore().refresh();
@@ -317,8 +317,10 @@
 
 #if ENABLE(PDFKIT_PLUGIN)
     // Add built-in PDF last, so that it's not used when a real plug-in is installed.
-    if (!m_context->omitPDFSupport())
+    if (!m_context->omitPDFSupport()) {
         plugins.append(PDFPlugin::pluginInfo());
+        applicationPlugins.append(PDFPlugin::pluginInfo());
+    }
 #endif
 }
 #endif // ENABLE(NETSCAPE_PLUGIN_API)

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (153876 => 153877)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2013-08-09 06:39:52 UTC (rev 153876)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2013-08-09 06:44:27 UTC (rev 153877)
@@ -144,7 +144,7 @@
 
     // Plugins
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    void getPlugins(bool refresh, Vector<WebCore::PluginInfo>& plugins);
+    void getPlugins(bool refresh, Vector<WebCore::PluginInfo>& plugins, Vector<WebCore::PluginInfo>& applicationPlugins);
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 #if ENABLE(PLUGIN_PROCESS)
     void getPluginProcessConnection(uint64_t pluginProcessToken, PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply>);

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in (153876 => 153877)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in	2013-08-09 06:39:52 UTC (rev 153876)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in	2013-08-09 06:44:27 UTC (rev 153877)
@@ -38,7 +38,7 @@
 
     # Plugin messages.
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins)
+    GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins, Vector<WebCore::PluginInfo> applicationPlugins)
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 #if ENABLE(PLUGIN_PROCESS)
     GetPluginProcessConnection(uint64_t pluginProcessToken) -> (CoreIPC::Attachment connectionHandle, bool supportsAsynchronousInitialization) Delayed

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp (153876 => 153877)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2013-08-09 06:39:52 UTC (rev 153876)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2013-08-09 06:44:27 UTC (rev 153877)
@@ -39,6 +39,7 @@
 #include "WebProcess.h"
 #include "WebProcessProxyMessages.h"
 #include <WebCore/Color.h>
+#include <WebCore/Frame.h>
 #include <WebCore/KURL.h>
 #include <WebCore/LoaderStrategy.h>
 #include <WebCore/NetworkStorageSession.h>
@@ -279,11 +280,17 @@
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 }
 
-void WebPlatformStrategies::getPluginInfo(const WebCore::Page*, Vector<WebCore::PluginInfo>& plugins)
+void WebPlatformStrategies::getPluginInfo(const WebCore::Page* page, Vector<WebCore::PluginInfo>& plugins)
 {
 #if ENABLE(NETSCAPE_PLUGIN_API)
     populatePluginCache();
-    plugins = m_cachedPlugins;
+
+    if (page->mainFrame()->loader()->subframeLoader()->allowPlugins(NotAboutToInstantiatePlugin)) {
+        plugins = m_cachedPlugins;
+        return;
+    }
+
+    plugins = m_cachedApplicationPlugins;
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 }
 
@@ -296,7 +303,7 @@
     ASSERT(m_cachedPlugins.isEmpty());
     
     // FIXME: Should we do something in case of error here?
-    if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebProcessProxy::GetPlugins(m_shouldRefreshPlugins), Messages::WebProcessProxy::GetPlugins::Reply(m_cachedPlugins), 0))
+    if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebProcessProxy::GetPlugins(m_shouldRefreshPlugins), Messages::WebProcessProxy::GetPlugins::Reply(m_cachedPlugins, m_cachedApplicationPlugins), 0))
         return;
 
     m_shouldRefreshPlugins = false;

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h (153876 => 153877)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2013-08-09 06:39:52 UTC (rev 153876)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2013-08-09 06:44:27 UTC (rev 153877)
@@ -118,11 +118,12 @@
     bool m_pluginCacheIsPopulated;
     bool m_shouldRefreshPlugins;
     Vector<WebCore::PluginInfo> m_cachedPlugins;
+    Vector<WebCore::PluginInfo> m_cachedApplicationPlugins;
 #endif // ENABLE(PLUGIN_PROCESS)
 };
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
-void handleDidGetPlugins(uint64_t requestID, const Vector<WebCore::PluginInfo>&);
+void handleDidGetPlugins(uint64_t requestID, const Vector<WebCore::PluginInfo>&, const Vector<WebCore::PluginInfo>& applicationPlugins);
 #endif // ENABLE(PLUGIN_PROCESS)
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to