Title: [228194] trunk/Source/WebKit
Revision
228194
Author
[email protected]
Date
2018-02-06 14:45:24 -0800 (Tue, 06 Feb 2018)

Log Message

Add WKNavigationDelegate SPI to tell the client when an insecure plug-in is blocked
https://bugs.webkit.org/show_bug.cgi?id=182540

Reviewed by Alex Christensen.

* UIProcess/API/APILoaderClient.h:
(API::LoaderClient::didBlockInsecurePluginVersion):
Changed to take a dictionary reference.

* UIProcess/API/APINavigationClient.h:
(API::NavigationClient::didBlockInsecurePluginVersion):
Added.

* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageLoaderClient):
Changed didBlockInsecurePluginVersion() to take a dictionary reference.

* UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
Added -_webView:didBlockInsecurePluginVersionWithInfo:.

* UIProcess/Cocoa/NavigationState.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::setNavigationDelegate):
Initialize webViewDidBlockInsecurePluginVersionWithInfo.

(WebKit::NavigationState::NavigationClient::didBlockInsecurePluginVersion):
Added.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didBlockInsecurePluginVersion):
Remove check for PLATFORM(COCOA) (we don't check for this in didFailToInitializePlugin() where we
also use createPluginInformationDictionary()) and ENABLE(NETSCAPE_PLUGIN_API) (we're already inside
an #if ENABLE(NETSCAPE_PLUGIN_API block) and use auto for pluginInformation. Attempt to use the
navigation client before the loader client.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (228193 => 228194)


--- trunk/Source/WebKit/ChangeLog	2018-02-06 22:42:26 UTC (rev 228193)
+++ trunk/Source/WebKit/ChangeLog	2018-02-06 22:45:24 UTC (rev 228194)
@@ -1,3 +1,40 @@
+2018-02-06  Jeff Miller  <[email protected]>
+
+        Add WKNavigationDelegate SPI to tell the client when an insecure plug-in is blocked
+        https://bugs.webkit.org/show_bug.cgi?id=182540
+
+        Reviewed by Alex Christensen.
+
+        * UIProcess/API/APILoaderClient.h:
+        (API::LoaderClient::didBlockInsecurePluginVersion):
+        Changed to take a dictionary reference.
+
+        * UIProcess/API/APINavigationClient.h:
+        (API::NavigationClient::didBlockInsecurePluginVersion):
+        Added.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetPageLoaderClient):
+        Changed didBlockInsecurePluginVersion() to take a dictionary reference.
+
+        * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
+        Added -_webView:didBlockInsecurePluginVersionWithInfo:.
+
+        * UIProcess/Cocoa/NavigationState.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::setNavigationDelegate):
+        Initialize webViewDidBlockInsecurePluginVersionWithInfo.
+
+        (WebKit::NavigationState::NavigationClient::didBlockInsecurePluginVersion):
+        Added.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didBlockInsecurePluginVersion):
+        Remove check for PLATFORM(COCOA) (we don't check for this in didFailToInitializePlugin() where we
+        also use createPluginInformationDictionary()) and ENABLE(NETSCAPE_PLUGIN_API) (we're already inside
+        an #if ENABLE(NETSCAPE_PLUGIN_API block) and use auto for pluginInformation. Attempt to use the
+        navigation client before the loader client.
+
 2018-02-06  Youenn Fablet  <[email protected]>
 
         HasServiceWorkerRegistration bit should be sent when creating a new page

Modified: trunk/Source/WebKit/UIProcess/API/APILoaderClient.h (228193 => 228194)


--- trunk/Source/WebKit/UIProcess/API/APILoaderClient.h	2018-02-06 22:42:26 UTC (rev 228193)
+++ trunk/Source/WebKit/UIProcess/API/APILoaderClient.h	2018-02-06 22:45:24 UTC (rev 228194)
@@ -105,7 +105,7 @@
 #if ENABLE(NETSCAPE_PLUGIN_API)
     virtual WebKit::PluginModuleLoadPolicy pluginLoadPolicy(WebKit::WebPageProxy&, WebKit::PluginModuleLoadPolicy currentPluginLoadPolicy, API::Dictionary&, WTF::String& /* unavailabilityDescription */) { return currentPluginLoadPolicy; }
     virtual void didFailToInitializePlugin(WebKit::WebPageProxy&, API::Dictionary&) { }
-    virtual void didBlockInsecurePluginVersion(WebKit::WebPageProxy&, API::Dictionary*) { }
+    virtual void didBlockInsecurePluginVersion(WebKit::WebPageProxy&, API::Dictionary&) { }
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 
 #if ENABLE(WEBGL)

Modified: trunk/Source/WebKit/UIProcess/API/APINavigationClient.h (228193 => 228194)


--- trunk/Source/WebKit/UIProcess/API/APINavigationClient.h	2018-02-06 22:42:26 UTC (rev 228193)
+++ trunk/Source/WebKit/UIProcess/API/APINavigationClient.h	2018-02-06 22:45:24 UTC (rev 228194)
@@ -113,6 +113,7 @@
     
 #if ENABLE(NETSCAPE_PLUGIN_API)
     virtual bool didFailToInitializePlugIn(WebKit::WebPageProxy&, API::Dictionary&) { return false; }
+    virtual bool didBlockInsecurePluginVersion(WebKit::WebPageProxy&, API::Dictionary&) { return false; }
     virtual WebKit::PluginModuleLoadPolicy decidePolicyForPluginLoad(WebKit::WebPageProxy&, WebKit::PluginModuleLoadPolicy currentPluginLoadPolicy, Dictionary&, WTF::String&)
     {
         return currentPluginLoadPolicy;

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (228193 => 228194)


--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp	2018-02-06 22:42:26 UTC (rev 228193)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp	2018-02-06 22:45:24 UTC (rev 228194)
@@ -1268,13 +1268,13 @@
                 m_client.pluginDidFail(toAPI(&page), kWKErrorCodeCannotLoadPlugIn, toAPI(&pluginInformation), m_client.base.clientInfo);
         }
 
-        void didBlockInsecurePluginVersion(WebPageProxy& page, API::Dictionary* pluginInformation) override
+        void didBlockInsecurePluginVersion(WebPageProxy& page, API::Dictionary& pluginInformation) override
         {
             if (m_client.pluginDidFail_deprecatedForUseWithV1)
-                m_client.pluginDidFail_deprecatedForUseWithV1(toAPI(&page), kWKErrorCodeInsecurePlugInVersion, toAPI(pluginInformation->get<API::String>(pluginInformationMIMETypeKey())), toAPI(pluginInformation->get<API::String>(pluginInformationBundleIdentifierKey())), toAPI(pluginInformation->get<API::String>(pluginInformationBundleVersionKey())), m_client.base.clientInfo);
+                m_client.pluginDidFail_deprecatedForUseWithV1(toAPI(&page), kWKErrorCodeInsecurePlugInVersion, toAPI(pluginInformation.get<API::String>(pluginInformationMIMETypeKey())), toAPI(pluginInformation.get<API::String>(pluginInformationBundleIdentifierKey())), toAPI(pluginInformation.get<API::String>(pluginInformationBundleVersionKey())), m_client.base.clientInfo);
 
             if (m_client.pluginDidFail)
-                m_client.pluginDidFail(toAPI(&page), kWKErrorCodeInsecurePlugInVersion, toAPI(pluginInformation), m_client.base.clientInfo);
+                m_client.pluginDidFail(toAPI(&page), kWKErrorCodeInsecurePlugInVersion, toAPI(&pluginInformation), m_client.base.clientInfo);
         }
 
         PluginModuleLoadPolicy pluginLoadPolicy(WebPageProxy& page, PluginModuleLoadPolicy currentPluginLoadPolicy, API::Dictionary& pluginInformation, String& unavailabilityDescription) override

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h (228193 => 228194)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h	2018-02-06 22:42:26 UTC (rev 228193)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h	2018-02-06 22:45:24 UTC (rev 228194)
@@ -107,6 +107,7 @@
 - (void)_webView:(WKWebView *)webView resolveWebGLLoadPolicyForURL:(NSURL *)url decisionHandler:(void (^)(_WKWebGLLoadPolicy))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 - (void)_webView:(WKWebView *)webView willGoToBackForwardListItem:(WKBackForwardListItem *)item inPageCache:(BOOL)inPageCache WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 - (void)_webView:(WKWebView *)webView didFailToInitializePlugInWithInfo:(NSDictionary *)info WK_API_AVAILABLE(macosx(WK_MAC_TBA));
+- (void)_webView:(WKWebView *)webView didBlockInsecurePluginVersionWithInfo:(NSDictionary *)info WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 - (_WKPluginModuleLoadPolicy)_webView:(WKWebView *)webView decidePolicyForPluginLoadWithCurrentPolicy:(_WKPluginModuleLoadPolicy)policy pluginInfo:(NSDictionary *)info unavailabilityDescription:(NSString *)unavailabilityDescription WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 - (void)_webView:(WKWebView *)webView backForwardListItemAdded:(WKBackForwardListItem *)itemAdded removed:(NSArray<WKBackForwardListItem *> *)itemsRemoved WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 #endif

Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h (228193 => 228194)


--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h	2018-02-06 22:42:26 UTC (rev 228193)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h	2018-02-06 22:45:24 UTC (rev 228194)
@@ -121,6 +121,7 @@
         void resolveWebGLLoadPolicy(WebPageProxy&, const WebCore::URL&, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const final;
         bool willGoToBackForwardListItem(WebPageProxy&, WebBackForwardListItem&, bool inPageCache, API::Object*) final;
         bool didFailToInitializePlugIn(WebPageProxy&, API::Dictionary&) final;
+        bool didBlockInsecurePluginVersion(WebPageProxy&, API::Dictionary&) final;
         WebKit::PluginModuleLoadPolicy decidePolicyForPluginLoad(WebKit::WebPageProxy&, WebKit::PluginModuleLoadPolicy, API::Dictionary&, WTF::String&) final;
         bool didChangeBackForwardList(WebPageProxy&, WebBackForwardListItem*, const Vector<Ref<WebBackForwardListItem>>&) final;
 #endif
@@ -222,6 +223,7 @@
         bool webViewResolveWebGLLoadPolicyForURL : 1;
         bool webViewBackForwardListItemAddedRemoved : 1;
         bool webViewDidFailToInitializePlugInWithInfo : 1;
+        bool webViewDidBlockInsecurePluginVersionWithInfo : 1;
         bool webViewWillGoToBackForwardListItemInPageCache : 1;
         bool webViewDecidePolicyForPluginLoadWithCurrentPolicyPluginInfoUnavailabilityDescription : 1;
 #endif

Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm (228193 => 228194)


--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2018-02-06 22:42:26 UTC (rev 228193)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2018-02-06 22:45:24 UTC (rev 228194)
@@ -185,6 +185,7 @@
     m_navigationDelegateMethods.webViewResolveWebGLLoadPolicyForURL = [delegate respondsToSelector:@selector(_webView:resolveWebGLLoadPolicyForURL:decisionHandler:)];
     m_navigationDelegateMethods.webViewWillGoToBackForwardListItemInPageCache = [delegate respondsToSelector:@selector(_webView:willGoToBackForwardListItem:inPageCache:)];
     m_navigationDelegateMethods.webViewDidFailToInitializePlugInWithInfo = [delegate respondsToSelector:@selector(_webView:didFailToInitializePlugInWithInfo:)];
+    m_navigationDelegateMethods.webViewDidBlockInsecurePluginVersionWithInfo = [delegate respondsToSelector:@selector(_webView:didBlockInsecurePluginVersionWithInfo:)];
     m_navigationDelegateMethods.webViewBackForwardListItemAddedRemoved = [delegate respondsToSelector:@selector(_webView:backForwardListItemAdded:removed:)];
     m_navigationDelegateMethods.webViewDecidePolicyForPluginLoadWithCurrentPolicyPluginInfoUnavailabilityDescription = [delegate respondsToSelector:@selector(_webView:decidePolicyForPluginLoadWithCurrentPolicy:pluginInfo:unavailabilityDescription:)];
 #endif
@@ -314,6 +315,19 @@
     return true;
 }
 
+bool NavigationState::NavigationClient::didBlockInsecurePluginVersion(WebPageProxy&, API::Dictionary& info)
+{
+    if (!m_navigationState.m_navigationDelegateMethods.webViewDidBlockInsecurePluginVersionWithInfo)
+        return false;
+
+    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
+    if (!navigationDelegate)
+        return false;
+
+    [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState.m_webView didBlockInsecurePluginVersionWithInfo:wrapper(info)];
+    return true;
+}
+
 static WebKit::PluginModuleLoadPolicy pluginModuleLoadPolicy(_WKPluginModuleLoadPolicy policy)
 {
     switch (policy) {

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (228193 => 228194)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-02-06 22:42:26 UTC (rev 228193)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-02-06 22:45:24 UTC (rev 228194)
@@ -6162,20 +6162,12 @@
 
 void WebPageProxy::didBlockInsecurePluginVersion(const String& mimeType, const String& pluginURLString, const String& frameURLString, const String& pageURLString, bool replacementObscured)
 {
-    RefPtr<API::Dictionary> pluginInformation;
-
-#if PLATFORM(COCOA) && ENABLE(NETSCAPE_PLUGIN_API)
     String newMimeType = mimeType;
     PluginModuleInfo plugin = m_process->processPool().pluginInfoStore().findPlugin(newMimeType, URL(URL(), pluginURLString));
-    pluginInformation = createPluginInformationDictionary(plugin, frameURLString, mimeType, pageURLString, String(), String(), replacementObscured);
-#else
-    UNUSED_PARAM(mimeType);
-    UNUSED_PARAM(pluginURLString);
-    UNUSED_PARAM(frameURLString);
-    UNUSED_PARAM(pageURLString);
-    UNUSED_PARAM(replacementObscured);
-#endif
+    auto pluginInformation = createPluginInformationDictionary(plugin, frameURLString, mimeType, pageURLString, String(), String(), replacementObscured);
 
+    if (m_navigationClient->didBlockInsecurePluginVersion(*this, pluginInformation.get()))
+        return;
     m_loaderClient->didBlockInsecurePluginVersion(*this, pluginInformation.get());
 }
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to