Changeset 141486 in webkit


Ignore:
Timestamp:
Jan 31, 2013 2:17:52 PM (11 years ago)
Author:
bweinstein@apple.com
Message:

Add a call to the page UI client to determine if a plug-in should load
https://bugs.webkit.org/show_bug.cgi?id=108407
<rdar://problem/13066332>

Source/WebKit2:

Reviewed by Anders Carlsson.

This patch adds a client call to the WKPageUIClient to be called to determine
whether or not a plug-in should load.

  • UIProcess/API/C/WKPage.h: Add shouldLoadPlugin.
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::getPluginPath): Moved from WebProcessProxy, and added a call to

m_uiClient.shouldInstantiatePlugin.

  • UIProcess/WebPageProxy.h:
  • UIProcss/WebPageProxy.messages.in: Moved GetPluginPath from WebProcessProxy to WebPageProxy.
  • UIProcess/WebProcessProxy.cpp:

(WebKit::WebProcessProxy::getPluginPath): Moved to WebPageProxy.

  • UIProcess/WebProcessProxy.h:
  • UIProcess/WebUIClient.cpp:

(WebKit::WebUIClient::shouldInstantiatePlugin): Return that we should load the plug-in if

the client function isn't defined, and call the function if it is.

  • UIProcess/WebUIClient.h:
  • UIProcess/mac/WebInspectorProxyMac.mm:

(WebKit::WebInspectorProxy::platformCreateInspectorPage): Add an entry for the new

client function.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::createPlugin): Send the message to the WebPageProxy, not the WebProcessProxy.
(WebKit::WebPage::canPluginHandleResponse): Made a member function, so it can call sendSync, and

send the message to the WebPageProxy, not the WebProcessProxy.

  • WebProcess/WebPage/WebPage.h:

Tools:

Add entries for the new function in the necessary structs.

Reviewed by Anders Carlsson.

  • MiniBrowser/mac/WK2BrowserWindowController.m:

(-[WK2BrowserWindowController awakeFromNib]):

  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::createOtherPage):
(WTR::TestController::createWebViewWithOptions):

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r141484 r141486  
     12013-01-30  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Add a call to the page UI client to determine if a plug-in should load
     4        https://bugs.webkit.org/show_bug.cgi?id=108407
     5        <rdar://problem/13066332>
     6
     7        Reviewed by Anders Carlsson.
     8
     9        This patch adds a client call to the WKPageUIClient to be called to determine
     10        whether or not a plug-in should load.
     11
     12        * UIProcess/API/C/WKPage.h: Add shouldLoadPlugin.
     13        * UIProcess/WebPageProxy.cpp:
     14        (WebKit::WebPageProxy::getPluginPath): Moved from WebProcessProxy, and added a call to
     15            m_uiClient.shouldInstantiatePlugin.
     16        * UIProcess/WebPageProxy.h:
     17        * UIProcss/WebPageProxy.messages.in: Moved GetPluginPath from WebProcessProxy to WebPageProxy.
     18        * UIProcess/WebProcessProxy.cpp:
     19        (WebKit::WebProcessProxy::getPluginPath): Moved to WebPageProxy.
     20        * UIProcess/WebProcessProxy.h:
     21        * UIProcess/WebUIClient.cpp:
     22        (WebKit::WebUIClient::shouldInstantiatePlugin): Return that we should load the plug-in if
     23            the client function isn't defined, and call the function if it is.
     24        * UIProcess/WebUIClient.h:
     25        * UIProcess/mac/WebInspectorProxyMac.mm:
     26        (WebKit::WebInspectorProxy::platformCreateInspectorPage): Add an entry for the new
     27            client function.
     28        * WebProcess/WebPage/WebPage.cpp:
     29        (WebKit::WebPage::createPlugin): Send the message to the WebPageProxy, not the WebProcessProxy.
     30        (WebKit::WebPage::canPluginHandleResponse): Made a member function, so it can call sendSync, and
     31            send the message to the WebPageProxy, not the WebProcessProxy.
     32        * WebProcess/WebPage/WebPage.h:
     33
    1342013-01-31  Anders Carlsson  <andersca@apple.com>
    235
  • trunk/Source/WebKit2/UIProcess/API/C/WKPage.h

    r141448 r141486  
    209209typedef void (*WKPageShowColorPickerCallback)(WKPageRef page, WKStringRef initialColor, WKColorPickerResultListenerRef listener, const void* clientInfo);
    210210typedef void (*WKPageHideColorPickerCallback)(WKPageRef page, const void* clientInfo);
     211typedef bool (*WKPageShouldInstantiatePluginCallback)(WKPageRef page, WKStringRef identifier, WKStringRef displayName, const void* clientInfo);
    211212
    212213// Deprecated   
     
    269270    WKPageShowColorPickerCallback                                       showColorPicker;
    270271    WKPageHideColorPickerCallback                                       hideColorPicker;
     272    WKPageShouldInstantiatePluginCallback                               shouldInstantiatePlugin;
    271273};
    272274typedef struct WKPageUIClient WKPageUIClient;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r141472 r141486  
    12211221}
    12221222
     1223#if ENABLE(NETSCAPE_PLUGIN_API)
     1224void WebPageProxy::getPluginPath(const String& mimeType, const String& urlString, String& pluginPath, uint32_t& pluginLoadPolicy)
     1225{
     1226    MESSAGE_CHECK_URL(urlString);
     1227
     1228    String newMimeType = mimeType.lower();
     1229
     1230    pluginLoadPolicy = PluginModuleLoadNormally;
     1231    PluginModuleInfo plugin = m_process->context()->pluginInfoStore().findPlugin(newMimeType, KURL(KURL(), urlString));
     1232    if (!plugin.path)
     1233        return;
     1234
     1235    pluginLoadPolicy = PluginInfoStore::policyForPlugin(plugin);
     1236    if (pluginLoadPolicy != PluginModuleLoadNormally)
     1237        return;
     1238
     1239    pluginLoadPolicy = m_uiClient.shouldInstantiatePlugin(this, plugin.bundleIdentifier, plugin.info.name) ? PluginModuleLoadNormally : PluginModuleBlocked;
     1240    if (pluginLoadPolicy != PluginModuleLoadNormally)
     1241        return;
     1242
     1243    pluginPath = plugin.path;
     1244}
     1245#endif // ENABLE(NETSCAPE_PLUGIN_API)
     1246
    12231247#if ENABLE(GESTURE_EVENTS)
    12241248void WebPageProxy::handleGestureEvent(const WebGestureEvent& event)
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r141472 r141486  
    10141014    void sendWheelEvent(const WebWheelEvent&);
    10151015
     1016#if ENABLE(NETSCAPE_PLUGIN_API)
     1017    void getPluginPath(const String& mimeType, const String& urlString, String& pluginPath, uint32_t& pluginLoadPolicy);
     1018#endif
     1019
    10161020    PageClient* m_pageClient;
    10171021    WebLoaderClient m_loaderClient;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r141448 r141486  
    314314    OpenPDFFromTemporaryFolderWithNativeApplication(WTF::String pdfUUID)
    315315#endif
     316
     317#if ENABLE(NETSCAPE_PLUGIN_API)
     318GetPluginPath(WTF::String mimeType, WTF::String urlString) -> (WTF::String pluginPath, uint32_t pluginLoadPolicy)
     319#endif
     320
    316321}
  • trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp

    r141448 r141486  
    352352}
    353353
    354 void WebProcessProxy::getPluginPath(const String& mimeType, const String& urlString, String& pluginPath, uint32_t& pluginLoadPolicy)
    355 {
    356     MESSAGE_CHECK_URL(urlString);
    357 
    358     String newMimeType = mimeType.lower();
    359 
    360     pluginLoadPolicy = PluginModuleLoadNormally;
    361     PluginModuleInfo plugin = m_context->pluginInfoStore().findPlugin(newMimeType, KURL(KURL(), urlString));
    362     if (!plugin.path)
    363         return;
    364 
    365     pluginLoadPolicy = PluginInfoStore::policyForPlugin(plugin);
    366     if (pluginLoadPolicy != PluginModuleLoadNormally)
    367         return;
    368 
    369     pluginPath = plugin.path;
    370 }
    371354#endif // ENABLE(NETSCAPE_PLUGIN_API)
    372355
  • trunk/Source/WebKit2/UIProcess/WebProcessProxy.h

    r141448 r141486  
    138138#if ENABLE(NETSCAPE_PLUGIN_API)
    139139    void getPlugins(CoreIPC::Connection*, uint64_t requestID, bool refresh);
    140     void getPluginPath(const String& mimeType, const String& urlString, String& pluginPath, uint32_t& pluginLoadPolicy);
    141140    void handleGetPlugins(uint64_t requestID, bool refresh);
    142141    void sendDidGetPlugins(uint64_t requestID, PassOwnPtr<Vector<WebCore::PluginInfo> >);
  • trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in

    r140605 r141486  
    3737#if ENABLE(NETSCAPE_PLUGIN_API)
    3838    GetPlugins(uint64_t requestID, bool refresh) DispatchOnConnectionQueue
    39     GetPluginPath(WTF::String mimeType, WTF::String urlString) -> (WTF::String pluginPath, uint32_t pluginLoadPolicy)
    4039#endif // ENABLE(NETSCAPE_PLUGIN_API)
    4140#if ENABLE(PLUGIN_PROCESS)
  • trunk/Source/WebKit2/UIProcess/WebUIClient.cpp

    r128553 r141486  
    439439#endif
    440440
     441bool WebUIClient::shouldInstantiatePlugin(WebPageProxy* page, const String& identifier, const String& displayName)
     442{
     443    if (!m_client.shouldInstantiatePlugin)
     444        return true;
     445
     446    return m_client.shouldInstantiatePlugin(toAPI(page), toAPI(identifier.impl()), toAPI(displayName.impl()), m_client.clientInfo);
     447}
     448
    441449} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/WebUIClient.h

    r128553 r141486  
    122122    bool hideColorPicker(WebPageProxy*);
    123123#endif
     124
     125    bool shouldInstantiatePlugin(WebPageProxy*, const String& identifier, const String& displayName);
    124126};
    125127
  • trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm

    r134513 r141486  
    353353        0, // showColorPicker
    354354        0, // hideColorPicker
     355        0, // shouldInstantiatePlugin
    355356    };
    356357
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r141472 r141486  
    502502    String pluginPath;
    503503    uint32_t pluginLoadPolicy;
    504     if (!WebProcess::shared().connection()->sendSync(
    505             Messages::WebProcessProxy::GetPluginPath(parameters.mimeType, parameters.url.string()),
    506             Messages::WebProcessProxy::GetPluginPath::Reply(pluginPath, pluginLoadPolicy), 0)) {
     504    if (!sendSync(
     505            Messages::WebPageProxy::GetPluginPath(parameters.mimeType, parameters.url.string()),
     506            Messages::WebPageProxy::GetPluginPath::Reply(pluginPath, pluginLoadPolicy))) {
    507507        return 0;
    508508    }
     
    36673667}
    36683668
    3669 static bool canPluginHandleResponse(const ResourceResponse& response)
     3669bool WebPage::canPluginHandleResponse(const ResourceResponse& response)
    36703670{
    36713671#if ENABLE(NETSCAPE_PLUGIN_API)
     
    36733673    uint32_t pluginLoadPolicy;
    36743674   
    3675     if (!WebProcess::shared().connection()->sendSync(Messages::WebProcessProxy::GetPluginPath(response.mimeType(), response.url().string()), Messages::WebProcessProxy::GetPluginPath::Reply(pluginPath, pluginLoadPolicy), 0))
     3675    if (!sendSync(Messages::WebPageProxy::GetPluginPath(response.mimeType(), response.url().string()), Messages::WebPageProxy::GetPluginPath::Reply(pluginPath, pluginLoadPolicy)))
    36763676        return false;
    36773677
     
    36823682}
    36833683
    3684 bool WebPage::shouldUseCustomRepresentationForResponse(const ResourceResponse& response) const
     3684bool WebPage::shouldUseCustomRepresentationForResponse(const ResourceResponse& response)
    36853685{
    36863686    if (!m_mimeTypesWithCustomRepresentations.contains(response.mimeType()))
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r141472 r141486  
    572572#endif
    573573
    574     bool shouldUseCustomRepresentationForResponse(const WebCore::ResourceResponse&) const;
     574    bool shouldUseCustomRepresentationForResponse(const WebCore::ResourceResponse&);
     575    bool canPluginHandleResponse(const WebCore::ResourceResponse& response);
    575576
    576577    bool asynchronousPluginInitializationEnabled() const { return m_asynchronousPluginInitializationEnabled; }
  • trunk/Tools/ChangeLog

    r141478 r141486  
     12013-01-30  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Add a call to the page UI client to determine if a plug-in should load
     4        https://bugs.webkit.org/show_bug.cgi?id=108407
     5        <rdar://problem/13066332>
     6
     7        Add entries for the new function in the necessary structs.
     8
     9        Reviewed by Anders Carlsson.
     10
     11        * MiniBrowser/mac/WK2BrowserWindowController.m:
     12        (-[WK2BrowserWindowController awakeFromNib]):
     13        * WebKitTestRunner/TestController.cpp:
     14        (WTR::TestController::createOtherPage):
     15        (WTR::TestController::createWebViewWithOptions):
     16
    1172013-01-31  Florin Malita  <fmalita@chromium.org>
    218
  • trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m

    r133179 r141486  
    704704        0, // showColorPicker
    705705        0, // hideColorPicker
     706        0, // shouldInstantiatePlugin
    706707    };
    707708    WKPageSetPageUIClient(_webView.pageRef, &uiClient);
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r141010 r141486  
    236236        0, // showColorPicker
    237237        0, // hideColorPicker
     238        0, // shouldInstantiatePlugin
    238239    };
    239240    WKPageSetPageUIClient(newPage, &otherPageUIClient);
     
    426427        0, // showColorPicker
    427428        0, // hideColorPicker
     429        0, // shouldInstantiatePlugin
    428430    };
    429431    WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient);
Note: See TracChangeset for help on using the changeset viewer.