Don't instantiate the Java plug-in if it's inactive
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Nov 2012 23:39:33 +0000 (23:39 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Nov 2012 23:39:33 +0000 (23:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=101102
<rdar://problem/12595679>

Reviewed by Andreas Kling.

Source/WebKit/mac:

* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::shouldUnavailablePluginMessageBeButton):
The RenderEmbeddedObject::PluginInactive reason should always result in a button being shown.

(WebChromeClient::unavailablePluginButtonClicked):
If the Java plug-in is inactive, call WKJLReportWebComponentsUsed() to reactivate the plug-in and
then reload the page.

* WebCoreSupport/WebFrameLoaderClient.mm:
(isOracleJavaPlugIn):
(isPlugInInactive):
Helper functions.

(WebFrameLoaderClient::createPlugin):
If the plug-in is inactive, set the appropriate unavailability reason on the renderer.

Source/WebKit2:

* Shared/Plugins/PluginModuleInfo.h:
Add a PluginModuleLoadPolicy enum.

* UIProcess/Plugins/PluginInfoStore.cpp:
(WebKit::PluginInfoStore::policyForPlugin):
* UIProcess/Plugins/PluginInfoStore.h:
(PluginInfoStore):
Rename shouldBlockPlugin to policyForPlugin and make it return an enum so we can handle inactive plug-ins.

* UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
(WebKit::shouldBlockPlugin):
Add helper function.

(WebKit::PluginInfoStore::policyForPlugin):
If the Java plug-in is inactive, return PluginModuleInactive.

(WebKit::PluginInfoStore::reactivateInactivePlugin):
If the given plug-in is the Java plug-in, call WKJLReportWebComponentsUsed() to reactivate it.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::unavailablePluginButtonClicked):
If the plug-in is inactive, try to reactivate it and reload the page if reactivation succeeded.

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::getPluginPath):
* UIProcess/WebProcessProxy.h:
This now returns a plug-in load policy.

* UIProcess/WebProcessProxy.messages.in:
GetPluginPack now returns a load policy enum.

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::shouldUnavailablePluginMessageBeButton):
Change this to a switch statement and always return true for RenderEmbeddedObject::PluginInactive.

(WebKit::WebChromeClient::unavailablePluginButtonClicked):
Add RenderEmbeddedObject::PluginInactive to the assertion.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::createPlugin):
Update now that GetPluginPath returns a pluginLoadPolicy enum.

(WebKit::canPluginHandleResponse):
Ditto.

WebKitLibraries:

Update WebKitSystemInterface to a version that has WKJLReportWebComponentsUsed.

* WebKitSystemInterface.h:
* libWebKitSystemInterfaceLion.a:
* libWebKitSystemInterfaceMountainLion.a:
Roll WebKitSystemInterface DERPS.

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

18 files changed:
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/Plugins/PluginModuleInfo.h
Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp
Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h
Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Source/WebKit2/UIProcess/WebProcessProxy.h
Source/WebKit2/UIProcess/WebProcessProxy.messages.in
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceLion.a
WebKitLibraries/libWebKitSystemInterfaceMountainLion.a

index c40d949..fbf70e5 100644 (file)
@@ -1,3 +1,27 @@
+2012-11-02  Anders Carlsson  <andersca@apple.com>
+
+        Don't instantiate the Java plug-in if it's inactive
+        https://bugs.webkit.org/show_bug.cgi?id=101102
+        <rdar://problem/12595679>
+
+        Reviewed by Andreas Kling.
+
+        * WebCoreSupport/WebChromeClient.mm:
+        (WebChromeClient::shouldUnavailablePluginMessageBeButton):
+        The RenderEmbeddedObject::PluginInactive reason should always result in a button being shown.
+
+        (WebChromeClient::unavailablePluginButtonClicked):
+        If the Java plug-in is inactive, call WKJLReportWebComponentsUsed() to reactivate the plug-in and
+        then reload the page.
+
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (isOracleJavaPlugIn):
+        (isPlugInInactive):
+        Helper functions.
+
+        (WebFrameLoaderClient::createPlugin):
+        If the plug-in is inactive, set the appropriate unavailability reason on the renderer.
+
 2012-11-02  Simon Fraser  <simon.fraser@apple.com>
 
         Enable SUBPIXEL_LAYOUT on Mac
index 806d62d..b9ca697 100644 (file)
@@ -31,6 +31,7 @@
 
 #import "DOMElementInternal.h"
 #import "DOMNodeInternal.h"
+#import "WebBasePluginPackage.h"
 #import "WebDefaultUIDelegate.h"
 #import "WebDelegateImplementationCaching.h"
 #import "WebElementDictionary.h"
@@ -63,6 +64,7 @@
 #import <WebCore/FrameLoadRequest.h>
 #import <WebCore/FrameView.h>
 #import <WebCore/HTMLNames.h>
+#import <WebCore/HTMLPlugInImageElement.h>
 #import <WebCore/HitTestResult.h>
 #import <WebCore/Icon.h>
 #import <WebCore/IntPoint.h>
@@ -128,6 +130,7 @@ NSString *WebConsoleMessageDebugMessageLevel = @"DebugMessageLevel";
 @end
 
 using namespace WebCore;
+using namespace HTMLNames;
 
 WebChromeClient::WebChromeClient(WebView *webView) 
     : m_webView(webView)
@@ -592,6 +595,9 @@ void WebChromeClient::scrollRectIntoView(const IntRect& r) const
 
 bool WebChromeClient::shouldUnavailablePluginMessageBeButton(RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const
 {
+    if (pluginUnavailabilityReason == RenderEmbeddedObject::PluginInactive)
+        return true;
+
     if (pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing)
         return [[m_webView UIDelegate] respondsToSelector:@selector(webView:didPressMissingPluginButton:)];
 
@@ -600,7 +606,30 @@ bool WebChromeClient::shouldUnavailablePluginMessageBeButton(RenderEmbeddedObjec
 
 void WebChromeClient::unavailablePluginButtonClicked(Element* element, RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const
 {
-    ASSERT_UNUSED(pluginUnavailabilityReason, pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing);
+    ASSERT(element->hasTagName(objectTag) || element->hasTagName(embedTag) || element->hasTagName(appletTag));
+
+    if (pluginUnavailabilityReason == RenderEmbeddedObject::PluginInactive) {
+        HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(element);
+
+        WebBasePluginPackage *pluginPackage = nil;
+        if (!pluginElement->serviceType().isEmpty())
+            pluginPackage = [m_webView _pluginForMIMEType:pluginElement->serviceType()];
+
+        NSURL *url = pluginElement->document()->completeURL(pluginElement->url());
+        NSString *extension = [[url path] pathExtension];
+        if (!pluginPackage && [extension length])
+            pluginPackage = [m_webView _pluginForExtension:extension];
+
+        if (pluginPackage && [pluginPackage bundleIdentifier] == "com.oracle.java.JavaAppletPlugin") {
+            // Reactivate the plug-in and reload the page so the plug-in will be instantiated correctly.
+            WKJLReportWebComponentsUsed();
+            [m_webView reload:nil];
+        }
+
+        return;
+    }
+
+    ASSERT(pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing || pluginUnavailabilityReason == RenderEmbeddedObject::PluginInactive);
     CallUIDelegate(m_webView, @selector(webView:didPressMissingPluginButton:), kit(element));
 }
 
index 72dd7a9..a81bf91 100644 (file)
@@ -1596,6 +1596,19 @@ private:
 
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 
+static bool isOracleJavaPlugIn(NSString *bundleIdentifier)
+{
+    return [bundleIdentifier isEqualToString:@"com.oracle.java.JavaAppletPlugin"];
+}
+
+static bool isPlugInInactive(NSString *bundleIdentifier)
+{
+    if (isOracleJavaPlugIn(bundleIdentifier) && !WKJLIsRuntimeAndWebComponentsInstalled())
+        return true;
+
+    return false;
+}
+
 PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLPlugInElement* element, const KURL& url,
     const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
 {
@@ -1667,7 +1680,15 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP
     NSView *view = nil;
 
     if (pluginPackage) {
-        if (!WKShouldBlockPlugin([pluginPackage bundleIdentifier], [pluginPackage bundleVersion])) {
+        if (WKShouldBlockPlugin([pluginPackage bundleIdentifier], [pluginPackage bundleVersion])) {
+            errorCode = WebKitErrorBlockedPlugInVersion;
+            if (element->renderer()->isEmbeddedObject())
+                toRenderEmbeddedObject(element->renderer())->setPluginUnavailabilityReason(RenderEmbeddedObject::InsecurePluginVersion);
+        } else if (isPlugInInactive([pluginPackage bundleIdentifier])) {
+            if (element->renderer()->isEmbeddedObject())
+                toRenderEmbeddedObject(element->renderer())->setPluginUnavailabilityReason(RenderEmbeddedObject::PluginInactive);
+            return 0;
+        } else {
             if ([pluginPackage isKindOfClass:[WebPluginPackage class]])
                 view = pluginView(m_webFrame.get(), (WebPluginPackage *)pluginPackage, attributeKeys, kit(paramValues), baseURL, kit(element), loadManually);
 
@@ -1687,10 +1708,6 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP
                 return adoptRef(new NetscapePluginWidget(pluginView));
             }
 #endif
-        } else {
-            errorCode = WebKitErrorBlockedPlugInVersion;
-            if (element->renderer()->isEmbeddedObject())
-                toRenderEmbeddedObject(element->renderer())->setPluginUnavailabilityReason(RenderEmbeddedObject::InsecurePluginVersion);
         }
     } else
         errorCode = WebKitErrorCannotFindPlugIn;
@@ -1770,7 +1787,15 @@ PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& s
     int errorCode = WebKitErrorJavaUnavailable;
 
     if (pluginPackage) {
-        if (!WKShouldBlockPlugin([pluginPackage bundleIdentifier], [pluginPackage bundleVersion])) {
+        if (WKShouldBlockPlugin([pluginPackage bundleIdentifier], [pluginPackage bundleVersion])) {
+            errorCode = WebKitErrorBlockedPlugInVersion;
+            if (element->renderer()->isEmbeddedObject())
+                toRenderEmbeddedObject(element->renderer())->setPluginUnavailabilityReason(RenderEmbeddedObject::InsecurePluginVersion);
+        } else if (isPlugInInactive([pluginPackage bundleIdentifier])) {
+            if (element->renderer()->isEmbeddedObject())
+                toRenderEmbeddedObject(element->renderer())->setPluginUnavailabilityReason(RenderEmbeddedObject::PluginInactive);
+            return 0;
+        } else {
     #if ENABLE(NETSCAPE_PLUGIN_API)
             if ([pluginPackage isKindOfClass:[WebNetscapePluginPackage class]]) {
                 view = [[[NETSCAPE_PLUGIN_VIEW alloc] initWithFrame:NSMakeRect(0, 0, size.width(), size.height())
@@ -1786,10 +1811,6 @@ PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& s
                     return adoptRef(new NetscapePluginWidget(static_cast<WebBaseNetscapePluginView *>(view)));
             }
     #endif
-        } else {
-            errorCode = WebKitErrorBlockedPlugInVersion;
-            if (element->renderer()->isEmbeddedObject())
-                toRenderEmbeddedObject(element->renderer())->setPluginUnavailabilityReason(RenderEmbeddedObject::InsecurePluginVersion);
         }
     }
 
index 7e16708..410f730 100644 (file)
@@ -1,3 +1,56 @@
+2012-11-02  Anders Carlsson  <andersca@apple.com>
+
+        Don't instantiate the Java plug-in if it's inactive
+        https://bugs.webkit.org/show_bug.cgi?id=101102
+        <rdar://problem/12595679>
+
+        Reviewed by Andreas Kling.
+
+        * Shared/Plugins/PluginModuleInfo.h:
+        Add a PluginModuleLoadPolicy enum.
+
+        * UIProcess/Plugins/PluginInfoStore.cpp:
+        (WebKit::PluginInfoStore::policyForPlugin):
+        * UIProcess/Plugins/PluginInfoStore.h:
+        (PluginInfoStore):
+        Rename shouldBlockPlugin to policyForPlugin and make it return an enum so we can handle inactive plug-ins.
+        
+        * UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
+        (WebKit::shouldBlockPlugin):
+        Add helper function.
+
+        (WebKit::PluginInfoStore::policyForPlugin):
+        If the Java plug-in is inactive, return PluginModuleInactive.
+
+        (WebKit::PluginInfoStore::reactivateInactivePlugin):
+        If the given plug-in is the Java plug-in, call WKJLReportWebComponentsUsed() to reactivate it.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::unavailablePluginButtonClicked):
+        If the plug-in is inactive, try to reactivate it and reload the page if reactivation succeeded.
+
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::getPluginPath):
+        * UIProcess/WebProcessProxy.h:
+        This now returns a plug-in load policy.
+
+        * UIProcess/WebProcessProxy.messages.in:
+        GetPluginPack now returns a load policy enum.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::shouldUnavailablePluginMessageBeButton):
+        Change this to a switch statement and always return true for RenderEmbeddedObject::PluginInactive.
+
+        (WebKit::WebChromeClient::unavailablePluginButtonClicked):
+        Add RenderEmbeddedObject::PluginInactive to the assertion.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::createPlugin):
+        Update now that GetPluginPath returns a pluginLoadPolicy enum.
+
+        (WebKit::canPluginHandleResponse):
+        Ditto.
+
 2012-11-02  Alexey Proskuryakov  <ap@apple.com>
 
         [Mac] ResourceHandle changes for network process
index a232db3..9e50f63 100644 (file)
 
 namespace WebKit {
 
+enum PluginModuleLoadPolicy {
+    // The plug-in module should be loaded normally.
+    PluginModuleLoadNormally,
+
+    // The plug-in should be blocked from being instantiated.
+    // Note that the plug-in will still be seen by e.g. navigator.plugins
+    PluginModuleBlocked,
+
+    // The plug-in module is inactive and should not be instantiated unless the user explicitly allows it.
+    PluginModuleInactive
+};
+
 struct PluginModuleInfo {
     String path;
     WebCore::PluginInfo info;
index 8044554..95f589b 100644 (file)
@@ -189,7 +189,12 @@ static inline String pathExtension(const KURL& url)
 }
 
 #if !PLATFORM(MAC)
-bool PluginInfoStore::shouldBlockPlugin(const PluginModuleInfo&)
+PluginModuleLoadPolicy PluginInfoStore::policyForPlugin(const PluginModuleInfo&)
+{
+    return PluginModuleLoadNormally;
+}
+
+bool PluginInfoStore::reactivateInactivePlugin(const PluginModuleInfo&)
 {
     return false;
 }
index 287ec92..9a6bd9f 100644 (file)
@@ -56,9 +56,8 @@ public:
     // Returns the info for the plug-in with the given path.
     PluginModuleInfo infoForPluginWithPath(const String& pluginPath) const;
 
-    // Return whether this plug-in should be blocked from being instantiated.
-    // Note that the plug-in will still be seen by e.g. navigator.plugins
-    static bool shouldBlockPlugin(const PluginModuleInfo&);
+    static PluginModuleLoadPolicy policyForPlugin(const PluginModuleInfo&);
+    static bool reactivateInactivePlugin(const PluginModuleInfo&);
 
 private:
     PluginModuleInfo findPluginForMIMEType(const String& mimeType) const;
index 5bacc2c..bc272a9 100644 (file)
@@ -36,6 +36,8 @@
 
 using namespace WebCore;
 
+static const char* const oracleJavaAppletPluginBundleIdentifier =  "com.oracle.java.JavaAppletPlugin";
+
 namespace WebKit {
 
 Vector<String> PluginInfoStore::pluginsDirectories()
@@ -105,6 +107,11 @@ static bool checkForPreferredPlugin(Vector<PluginModuleInfo>& alreadyLoadedPlugi
     return true;
 }
 
+static bool shouldBlockPlugin(const PluginModuleInfo& plugin)
+{
+    return PluginInfoStore::policyForPlugin(plugin) == PluginModuleBlocked;
+}
+
 bool PluginInfoStore::shouldUsePlugin(Vector<PluginModuleInfo>& alreadyLoadedPlugins, const PluginModuleInfo& plugin)
 {
     for (size_t i = 0; i < alreadyLoadedPlugins.size(); ++i) {
@@ -122,7 +129,7 @@ bool PluginInfoStore::shouldUsePlugin(Vector<PluginModuleInfo>& alreadyLoadedPlu
     }
 
     // Prefer the Oracle Java plug-in over the Apple java plug-in.
-    if (!checkForPreferredPlugin(alreadyLoadedPlugins, plugin, "com.apple.java.JavaAppletPlugin", "com.oracle.java.JavaAppletPlugin"))
+    if (!checkForPreferredPlugin(alreadyLoadedPlugins, plugin, "com.apple.java.JavaAppletPlugin",  oracleJavaAppletPluginBundleIdentifier))
         return false;
 
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
@@ -135,9 +142,27 @@ bool PluginInfoStore::shouldUsePlugin(Vector<PluginModuleInfo>& alreadyLoadedPlu
     return true;
 }
 
-bool PluginInfoStore::shouldBlockPlugin(const PluginModuleInfo& plugin)
+PluginModuleLoadPolicy PluginInfoStore::policyForPlugin(const PluginModuleInfo& plugin)
 {
-    return WKShouldBlockPlugin(plugin.bundleIdentifier, plugin.versionString);
+    if (WKShouldBlockPlugin(plugin.bundleIdentifier, plugin.versionString))
+        return PluginModuleBlocked;
+
+    if (plugin.bundleIdentifier == oracleJavaAppletPluginBundleIdentifier && !WKJLIsRuntimeAndWebComponentsInstalled())
+        return PluginModuleInactive;
+
+    return PluginModuleLoadNormally;
+}
+
+bool PluginInfoStore::reactivateInactivePlugin(const PluginModuleInfo& plugin)
+{
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
+    if (plugin.bundleIdentifier == oracleJavaAppletPluginBundleIdentifier) {
+        WKJLReportWebComponentsUsed();
+        return true;
+    }
+#endif
+
+    return false;
 }
 
 String PluginInfoStore::getMIMETypeForExtension(const String& extension)
index b345a30..24d3268 100644 (file)
@@ -2592,8 +2592,20 @@ void WebPageProxy::unavailablePluginButtonClicked(uint32_t opaquePluginUnavailab
         pluginUnavailabilityReason = kWKPluginUnavailabilityReasonPluginCrashed;
         break;
 
+    case RenderEmbeddedObject::PluginInactive: {
+#if ENABLE(NETSCAPE_PLUGIN_API)
+        String newMimeType = mimeType;
+        PluginModuleInfo plugin = m_process->context()->pluginInfoStore().findPlugin(newMimeType, KURL(KURL(), url));
+
+        if (!plugin.path.isEmpty() && PluginInfoStore::reactivateInactivePlugin(plugin)) {
+            // The plug-in has been reactivated now; reload the page so it'll be instantiated.
+            reload(false);
+        }
+        return;
+#endif
+    }
+
     case RenderEmbeddedObject::PluginBlockedByContentSecurityPolicy:
-    case RenderEmbeddedObject::PluginInactive:
         ASSERT_NOT_REACHED();
     }
 
index 6bf6543..e8a39bd 100644 (file)
@@ -359,21 +359,20 @@ void WebProcessProxy::getPlugins(CoreIPC::Connection*, uint64_t requestID, bool
     pluginWorkQueue().dispatch(bind(&WebProcessProxy::handleGetPlugins, this, requestID, refresh));
 }
 
-void WebProcessProxy::getPluginPath(const String& mimeType, const String& urlString, String& pluginPath, bool& blocked)
+void WebProcessProxy::getPluginPath(const String& mimeType, const String& urlString, String& pluginPath, uint32_t& pluginLoadPolicy)
 {
     MESSAGE_CHECK_URL(urlString);
 
     String newMimeType = mimeType.lower();
 
-    blocked = false;
+    pluginLoadPolicy = PluginModuleLoadNormally;
     PluginModuleInfo plugin = m_context->pluginInfoStore().findPlugin(newMimeType, KURL(KURL(), urlString));
     if (!plugin.path)
         return;
 
-    if (m_context->pluginInfoStore().shouldBlockPlugin(plugin)) {
-        blocked = true;
+    pluginLoadPolicy = PluginInfoStore::policyForPlugin(plugin);
+    if (pluginLoadPolicy != PluginModuleLoadNormally)
         return;
-    }
 
     pluginPath = plugin.path;
 }
index 88ee153..a0120ef 100644 (file)
@@ -140,7 +140,7 @@ private:
     // Plugins
 #if ENABLE(NETSCAPE_PLUGIN_API)
     void getPlugins(CoreIPC::Connection*, uint64_t requestID, bool refresh);
-    void getPluginPath(const String& mimeType, const String& urlString, String& pluginPath, bool& blocked);
+    void getPluginPath(const String& mimeType, const String& urlString, String& pluginPath, uint32_t& pluginLoadPolicy);
     void handleGetPlugins(uint64_t requestID, bool refresh);
     void sendDidGetPlugins(uint64_t requestID, PassOwnPtr<Vector<WebCore::PluginInfo> >);
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
index e721388..22e2f08 100644 (file)
@@ -36,7 +36,7 @@ messages -> WebProcessProxy {
     # Plugin messages.
 #if ENABLE(NETSCAPE_PLUGIN_API)
     GetPlugins(uint64_t requestID, bool refresh) DispatchOnConnectionQueue
-    GetPluginPath(WTF::String mimeType, WTF::String urlString) -> (WTF::String pluginPath, bool blocked)
+    GetPluginPath(WTF::String mimeType, WTF::String urlString) -> (WTF::String pluginPath, uint32_t pluginLoadPolicy)
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 #if ENABLE(PLUGIN_PROCESS)
     GetPluginProcessConnection(WTF::String pluginPath) -> (CoreIPC::Attachment connectionHandle, bool supportsAsynchronousInitialization) Delayed
index ac3daa9..3e7fe32 100644 (file)
@@ -473,19 +473,28 @@ void WebChromeClient::scrollRectIntoView(const IntRect&) const
 
 bool WebChromeClient::shouldUnavailablePluginMessageBeButton(RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const
 {
-    if (pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing || pluginUnavailabilityReason == RenderEmbeddedObject::InsecurePluginVersion) {
+    switch (pluginUnavailabilityReason) {
+    case RenderEmbeddedObject::PluginMissing:
         // FIXME: <rdar://problem/8794397> We should only return true when there is a
         // missingPluginButtonClicked callback defined on the Page UI client.
+    case RenderEmbeddedObject::InsecurePluginVersion:
+    case RenderEmbeddedObject::PluginInactive:
         return true;
+
+
+    case RenderEmbeddedObject::PluginCrashed:
+    case RenderEmbeddedObject::PluginBlockedByContentSecurityPolicy:
+        return false;
     }
 
+    ASSERT_NOT_REACHED();
     return false;
 }
     
 void WebChromeClient::unavailablePluginButtonClicked(Element* element, RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const
 {
     ASSERT(element->hasTagName(objectTag) || element->hasTagName(embedTag) || element->hasTagName(appletTag));
-    ASSERT(pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing || pluginUnavailabilityReason == RenderEmbeddedObject::InsecurePluginVersion);
+    ASSERT(pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing || pluginUnavailabilityReason == RenderEmbeddedObject::InsecurePluginVersion || pluginUnavailabilityReason == RenderEmbeddedObject::PluginInactive);
 
     HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(element);
 
index 696adb1..2312e84 100644 (file)
@@ -491,20 +491,28 @@ void WebPage::initializeInjectedBundleDiagnosticLoggingClient(WKBundlePageDiagno
 PassRefPtr<Plugin> WebPage::createPlugin(WebFrame* frame, HTMLPlugInElement* pluginElement, const Plugin::Parameters& parameters)
 {
     String pluginPath;
-    bool blocked;
-
+    uint32_t pluginLoadPolicy;
     if (!WebProcess::shared().connection()->sendSync(
             Messages::WebProcessProxy::GetPluginPath(parameters.mimeType, parameters.url.string()),
-            Messages::WebProcessProxy::GetPluginPath::Reply(pluginPath, blocked), 0)) {
+            Messages::WebProcessProxy::GetPluginPath::Reply(pluginPath, pluginLoadPolicy), 0)) {
         return 0;
     }
 
-    if (blocked) {
+    switch (static_cast<PluginModuleLoadPolicy>(pluginLoadPolicy)) {
+    case PluginModuleLoadNormally:
+        break;
+
+    case PluginModuleBlocked:
         if (pluginElement->renderer()->isEmbeddedObject())
             toRenderEmbeddedObject(pluginElement->renderer())->setPluginUnavailabilityReason(RenderEmbeddedObject::InsecurePluginVersion);
 
         send(Messages::WebPageProxy::DidBlockInsecurePluginVersion(parameters.mimeType, parameters.url.string()));
         return 0;
+
+    case PluginModuleInactive:
+        if (pluginElement->renderer()->isEmbeddedObject())
+            toRenderEmbeddedObject(pluginElement->renderer())->setPluginUnavailabilityReason(RenderEmbeddedObject::PluginInactive);
+        return 0;
     }
 
     if (pluginPath.isNull()) {
@@ -3493,12 +3501,12 @@ static bool canPluginHandleResponse(const ResourceResponse& response)
 {
 #if ENABLE(NETSCAPE_PLUGIN_API)
     String pluginPath;
-    bool blocked;
+    uint32_t pluginLoadPolicy;
     
-    if (!WebProcess::shared().connection()->sendSync(Messages::WebProcessProxy::GetPluginPath(response.mimeType(), response.url().string()), Messages::WebProcessProxy::GetPluginPath::Reply(pluginPath, blocked), 0))
+    if (!WebProcess::shared().connection()->sendSync(Messages::WebProcessProxy::GetPluginPath(response.mimeType(), response.url().string()), Messages::WebProcessProxy::GetPluginPath::Reply(pluginPath, pluginLoadPolicy), 0))
         return false;
-    
-    return !blocked && !pluginPath.isEmpty();
+
+    return pluginLoadPolicy != PluginModuleBlocked && !pluginPath.isEmpty();
 #else
     return false;
 #endif
index f5f2587..abe2967 100644 (file)
@@ -1,3 +1,18 @@
+2012-11-02  Anders Carlsson  <andersca@apple.com>
+
+        Don't instantiate the Java plug-in if it's inactive
+        https://bugs.webkit.org/show_bug.cgi?id=101102
+        <rdar://problem/12595679>
+
+        Reviewed by Andreas Kling.
+
+        Update WebKitSystemInterface to a version that has WKJLReportWebComponentsUsed.
+
+        * WebKitSystemInterface.h:
+        * libWebKitSystemInterfaceLion.a:
+        * libWebKitSystemInterfaceMountainLion.a:
+        Roll WebKitSystemInterface DERPS.
+
 2012-10-25  Dominik Röttsches  <dominik.rottsches@intel.com>
 
         Conditionalize XHR timeout support
index 47279f3..353f0b9 100644 (file)
@@ -153,6 +153,18 @@ void WKGetGlyphsForCharacters(CGFontRef, const UniChar[], CGGlyph[], size_t);
 bool WKGetVerticalGlyphsForCharacters(CTFontRef, const UniChar[], CGGlyph[], size_t);
 
 CTLineRef WKCreateCTLineWithUniCharProvider(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*);
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+enum {
+    WKCTFontTransformApplyShaping = (1 << 0),
+    WKCTFontTransformApplyPositioning = (1 << 1)
+};
+
+typedef int WKCTFontTransformOptions;
+
+bool WKCTFontTransformGlyphs(CTFontRef font, CGGlyph glyphs[], CGSize advances[], CFIndex count, WKCTFontTransformOptions options);
+#endif
+
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
 CTTypesetterRef WKCreateCTTypesetterWithUniCharProviderAndOptions(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*, CFDictionaryRef options);
 
@@ -511,6 +523,7 @@ CGFloat WKNSReboundDeltaForElasticDelta(CGFloat delta);
 
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
 Boolean WKJLIsRuntimeAndWebComponentsInstalled(void);
+void WKJLReportWebComponentsUsed(void);
 #endif
 
 typedef enum {
@@ -548,6 +561,18 @@ bool WKCaptionAppearanceGetRelativeCharacterSize(CGFloat*);
 int WKCaptionAppearanceGetTextEdgeStyle(void);
 CFStringRef WKCaptionAppearanceGetSettingsChangedNotification(void);
 
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+typedef enum {
+    WKOcclusionNotificationTypeApplicationBecameVisible,
+    WKOcclusionNotificationTypeApplicationBecameOccluded
+} WKOcclusionNotificationType;
+
+typedef void (*WKOcclusionNotificationHandler)(uint32_t, void*, uint32_t, void*, uint32_t);
+
+bool WKRegisterOcclusionNotificationHandler(WKOcclusionNotificationType, WKOcclusionNotificationHandler);
+bool WKUnregisterOcclusionNotificationHandler(WKOcclusionNotificationType, WKOcclusionNotificationHandler);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index db8b46c..923d624 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLion.a and b/WebKitLibraries/libWebKitSystemInterfaceLion.a differ
index de95e96..5f7e9ba 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceMountainLion.a and b/WebKitLibraries/libWebKitSystemInterfaceMountainLion.a differ