navigator.plugins has plugins in it when plugins are disabled
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Aug 2013 06:44:27 +0000 (06:44 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Aug 2013 06:44:27 +0000 (06:44 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@153877 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/plugins/navigator-plugins-disabled-expected.txt [new file with mode: 0644]
LayoutTests/plugins/navigator-plugins-disabled.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/Settings.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Source/WebKit2/UIProcess/WebProcessProxy.h
Source/WebKit2/UIProcess/WebProcessProxy.messages.in
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h

index 95bab5c..a251024 100644 (file)
@@ -1,3 +1,17 @@
+2013-08-08  Tim Horton  <timothy_horton@apple.com>
+
+        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  <timothy@apple.com>
 
         Allow SVG images to be drawn into canvas without tainting.
diff --git a/LayoutTests/plugins/navigator-plugins-disabled-expected.txt b/LayoutTests/plugins/navigator-plugins-disabled-expected.txt
new file mode 100644 (file)
index 0000000..53e0935
--- /dev/null
@@ -0,0 +1 @@
+Passed!
diff --git a/LayoutTests/plugins/navigator-plugins-disabled.html b/LayoutTests/plugins/navigator-plugins-disabled.html
new file mode 100644 (file)
index 0000000..baf0664
--- /dev/null
@@ -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>
index d2c8071..4444532 100644 (file)
@@ -1,3 +1,21 @@
+2013-08-08  Tim Horton  <timothy_horton@apple.com>
+
+        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  <timothy@apple.com>
 
         Allow SVG images to be drawn into canvas without tainting.
index 1775dae..12b438b 100644 (file)
@@ -390,7 +390,11 @@ void Settings::setImagesEnabled(bool areImagesEnabled)
 
 void Settings::setPluginsEnabled(bool arePluginsEnabled)
 {
+    if (m_arePluginsEnabled == arePluginsEnabled)
+        return;
+
     m_arePluginsEnabled = arePluginsEnabled;
+    Page::refreshPlugins(false);
 }
 
 void Settings::setPrivateBrowsingEnabled(bool privateBrowsingEnabled)
index 32411fd..93b1f5f 100644 (file)
@@ -1,3 +1,17 @@
+2013-08-08  Tim Horton  <timothy_horton@apple.com>
+
+        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  <slewis@apple.com>
 
         Update Order Files for Safari
index 64a5a36..ed067ac 100644 (file)
@@ -126,10 +126,14 @@ void WebPlatformStrategies::refreshPlugins()
     [[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];
index dd48420..fbe32dc 100644 (file)
@@ -1,3 +1,27 @@
+2013-08-08  Tim Horton  <timothy_horton@apple.com>
+
+        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  <barraclough@apple.com>
 
         Disable suppression of plugin process for Java
index 7de8bb9..c46fa3d 100644 (file)
@@ -306,7 +306,7 @@ void WebProcessProxy::addBackForwardItem(uint64_t itemID, const String& original
 }
 
 #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 @@ void WebProcessProxy::getPlugins(bool refresh, Vector<PluginInfo>& plugins)
 
 #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)
index 7d9b7f6..7877140 100644 (file)
@@ -144,7 +144,7 @@ private:
 
     // 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>);
index fe6d3a2..0647982 100644 (file)
@@ -38,7 +38,7 @@ messages -> WebProcessProxy LegacyReceiver {
 
     # 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
index 474e574..098b818 100644 (file)
@@ -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 @@ void WebPlatformStrategies::refreshPlugins()
 #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 @@ void WebPlatformStrategies::populatePluginCache()
     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;
index 7262828..daedc4d 100644 (file)
@@ -118,11 +118,12 @@ private:
     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