Need the ability to get the information for a plug-in with a particular process id...
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 May 2013 21:59:58 +0000 (21:59 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 May 2013 21:59:58 +0000 (21:59 +0000)
be running on a page
https://bugs.webkit.org/show_bug.cgi?id=117090

Reviewed by Anders Carlsson.

* UIProcess/API/C/mac/WKPagePrivateMac.cpp:
(callGetInformationForPlugInWithProcessIDBlockAndDispose):
Get the block from the context, invoke it with the result, and dispose of it.
(WKPageGetInformationForPlugInWithProcessID):
Ask the WebPageProxy and provide it with a dictionary callback that uses the
above function to invoke the passed in block.
* UIProcess/API/C/mac/WKPagePrivateMac.h:
Add WKPageGetInformationForPlugInWithProcessID and a typedef for the callback block.

* UIProcess/Plugins/PluginProcessManager.h:
Add ways to get the PluginProcessProxy associated with a process id or process token.
* UIProcess/Plugins/mac/PluginProcessManagerMac.mm:
(WebKit::PluginProcessManager::plugInProcessWithProcessID):
Return the first PluginProcessProxy with the passed in process ID.
(WebKit::PluginProcessManager::plugInProcessWithToken):
Return the first PluginProcessProxy with the passed in process token.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::close):
Invalidate any outstanding requests for plug-in information.
* UIProcess/WebPageProxy.h:
Keep track of the callbacks for the requests for plug-in information.
* UIProcess/WebPageProxy.messages.in:
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::getInformationForPlugInWithProcessID):
If there are no known plug-ins with the provided process ID, invoke the callback with a null
dictionary of plug-in information.
Otherwise, keep track of the callback and send a message to the web process asking for the
information.
(WebKit::WebPageProxy::containsPlugInCallback):
If the page did not contain the plug-in, invoke the callback with a null dictionary of
plug-in information.
Invoke the callback with a dictionary containing the PlugInModuleInfo.

* WebProcess/Plugins/Netscape/NetscapePlugin.h:
Return 0 for the plugInProcessToken.
* WebProcess/Plugins/PDF/SimplePDFPlugin.h:
Ditto.
* WebProcess/Plugins/Plugin.h:
Add a pure virtual method for plugInProcessToken so it can be accessed from from the Plugin
on the PluginView.
* WebProcess/Plugins/PluginProxy.h:
Return the actual plug-in process token.

* WebProcess/Plugins/PluginView.h:
(WebKit::PluginView::plugIn):
Make it possible to get at the plug-in process token through the Plugin.

* WebProcess/WebPage/WebPageMac.mm:
(WebKit::WebPage::containsPluginViewsWithPluginProcessToken):
If there is an instance of the plug-in with that token, send a confirmation to the ui
process.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

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

17 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.cpp
Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.h
Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h
Source/WebKit2/UIProcess/Plugins/mac/PluginProcessManagerMac.mm
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h
Source/WebKit2/WebProcess/Plugins/Plugin.h
Source/WebKit2/WebProcess/Plugins/PluginProxy.h
Source/WebKit2/WebProcess/Plugins/PluginView.h
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

index 030342a..13e10ce 100644 (file)
@@ -1,3 +1,66 @@
+2013-05-31  Jessie Berlin  <jberlin@apple.com>
+
+        Need the ability to get the information for a plug-in with a particular process id that may
+        be running on a page
+        https://bugs.webkit.org/show_bug.cgi?id=117090
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/C/mac/WKPagePrivateMac.cpp:
+        (callGetInformationForPlugInWithProcessIDBlockAndDispose):
+        Get the block from the context, invoke it with the result, and dispose of it.
+        (WKPageGetInformationForPlugInWithProcessID):
+        Ask the WebPageProxy and provide it with a dictionary callback that uses the
+        above function to invoke the passed in block.
+        * UIProcess/API/C/mac/WKPagePrivateMac.h:
+        Add WKPageGetInformationForPlugInWithProcessID and a typedef for the callback block.
+
+        * UIProcess/Plugins/PluginProcessManager.h:
+        Add ways to get the PluginProcessProxy associated with a process id or process token.
+        * UIProcess/Plugins/mac/PluginProcessManagerMac.mm:
+        (WebKit::PluginProcessManager::plugInProcessWithProcessID):
+        Return the first PluginProcessProxy with the passed in process ID.
+        (WebKit::PluginProcessManager::plugInProcessWithToken):
+        Return the first PluginProcessProxy with the passed in process token.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::close):
+        Invalidate any outstanding requests for plug-in information.
+        * UIProcess/WebPageProxy.h:
+        Keep track of the callbacks for the requests for plug-in information.
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::getInformationForPlugInWithProcessID):
+        If there are no known plug-ins with the provided process ID, invoke the callback with a null
+        dictionary of plug-in information.
+        Otherwise, keep track of the callback and send a message to the web process asking for the
+        information.
+        (WebKit::WebPageProxy::containsPlugInCallback):
+        If the page did not contain the plug-in, invoke the callback with a null dictionary of
+        plug-in information.
+        Invoke the callback with a dictionary containing the PlugInModuleInfo.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        Return 0 for the plugInProcessToken.
+        * WebProcess/Plugins/PDF/SimplePDFPlugin.h:
+        Ditto.
+        * WebProcess/Plugins/Plugin.h:
+        Add a pure virtual method for plugInProcessToken so it can be accessed from from the Plugin
+        on the PluginView.
+        * WebProcess/Plugins/PluginProxy.h:
+        Return the actual plug-in process token.
+
+        * WebProcess/Plugins/PluginView.h:
+        (WebKit::PluginView::plugIn):
+        Make it possible to get at the plug-in process token through the Plugin.
+
+        * WebProcess/WebPage/WebPageMac.mm:
+        (WebKit::WebPage::containsPluginViewsWithPluginProcessToken):
+        If there is an instance of the plug-in with that token, send a confirmation to the ui
+        process.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2013-05-31  Alexey Proskuryakov  <ap@apple.com>
 
         REGRESSION (r141445): MPEG-4 videos do not play on certain hardware configurations
index 5e45950..1986e64 100644 (file)
@@ -46,3 +46,15 @@ bool WKPageIsURLKnownHSTSHost(WKPageRef page, WKURLRef url)
 
     return webPageProxy->process()->context()->isURLKnownHSTSHost(toImpl(url)->string(), privateBrowsingEnabled);
 }
+
+static void callGetInformationForPlugInWithProcessIDBlockAndDispose(WKDictionaryRef resultValue, WKErrorRef error, void* context)
+{
+    WKPageGetInformationForPlugInWithProcessIDBlock block = (WKPageGetInformationForPlugInWithProcessIDBlock)context;
+    block(resultValue, error);
+    Block_release(block);
+}
+
+void WKPageGetInformationForPlugInWithProcessID(WKPageRef pageRef, pid_t plugInProcessID, WKPageGetInformationForPlugInWithProcessIDBlock block)
+{
+    toImpl(pageRef)->getInformationForPlugInWithProcessID(plugInProcessID, DictionaryCallback::create(Block_copy(block), callGetInformationForPlugInWithProcessIDBlockAndDispose));
+}
index 8357ba5..74d8488 100644 (file)
@@ -35,6 +35,9 @@ extern "C" {
 WK_EXPORT pid_t WKPageGetProcessIdentifier(WKPageRef page);
 WK_EXPORT bool WKPageIsURLKnownHSTSHost(WKPageRef page, WKURLRef url);
 
+typedef void (^WKPageGetInformationForPlugInWithProcessIDBlock)(WKDictionaryRef, WKErrorRef);
+WK_EXPORT void WKPageGetInformationForPlugInWithProcessID(WKPageRef, pid_t plugInProcessID, WKPageGetInformationForPlugInWithProcessIDBlock);
+
 #ifdef __cplusplus
 }
 #endif
index 307c398..42bfeea 100644 (file)
@@ -63,6 +63,8 @@ public:
 
 #if PLATFORM(MAC)
     void setProcessSuppressionEnabled(bool);
+    PluginProcessProxy* plugInProcessWithProcessID(pid_t plugInProcessID) const;
+    PluginProcessProxy* plugInProcessWithToken(uint64_t plugInProcessToken) const;
 #endif
 
 private:
index 771cf78..fa581d2 100644 (file)
@@ -39,6 +39,24 @@ void PluginProcessManager::setProcessSuppressionEnabled(bool processSuppressionE
         m_pluginProcesses[i]->setProcessSuppressionEnabled(processSuppressionEnabled);
 }
 
+PluginProcessProxy* PluginProcessManager::plugInProcessWithProcessID(pid_t plugInProcessID) const
+{
+    for (size_t i = 0; i < m_pluginProcesses.size(); ++i) {
+        if (m_pluginProcesses[i]->processIdentifier() == plugInProcessID)
+            return m_pluginProcesses[i].get();
+    }
+    return 0;
+}
+
+PluginProcessProxy* PluginProcessManager::plugInProcessWithToken(uint64_t plugInProcessToken) const
+{
+    for (size_t i = 0; i < m_pluginProcesses.size(); ++i) {
+        if (m_pluginProcesses[i]->pluginProcessToken() == plugInProcessToken)
+            return m_pluginProcesses[i].get();
+    }
+    return 0;
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(PLUGIN_PROCESS)
index 594cfda..189319b 100644 (file)
@@ -615,6 +615,9 @@ void WebPageProxy::close()
 #if PLATFORM(GTK)
     invalidateCallbackMap(m_printFinishedCallbacks);
 #endif
+#if PLATFORM(MAC)
+    invalidateCallbackMap(m_plugInInformationCallbacks);
+#endif
 
     Vector<WebEditCommandProxy*> editCommandVector;
     copyToVector(m_editCommandSet, editCommandVector);
index 532ec3f..2ce702f 100644 (file)
@@ -166,6 +166,7 @@ class WebGestureEvent;
 class WebVibrationProxy;
 #endif
 
+typedef GenericCallback<WKDictionaryRef> DictionaryCallback;
 typedef GenericCallback<WKStringRef, StringImpl*> StringCallback;
 typedef GenericCallback<WKSerializedScriptValueRef, WebSerializedScriptValue*> ScriptValueCallback;
 
@@ -536,6 +537,9 @@ public:
     void makeFirstResponder();
 
     ColorSpaceData colorSpace();
+
+    void getInformationForPlugInWithProcessID(pid_t plugInProcessID, PassRefPtr<DictionaryCallback>);
+    void containsPlugInCallback(bool containsPlugIn, uint64_t plugInToken, uint64_t callbackID);
 #endif
 
     void pageScaleFactorDidChange(double);
@@ -1099,6 +1103,9 @@ private:
 #if PLATFORM(GTK)
     HashMap<uint64_t, RefPtr<PrintFinishedCallback>> m_printFinishedCallbacks;
 #endif
+#if PLATFORM(MAC)
+    HashMap<uint64_t, RefPtr<DictionaryCallback>> m_plugInInformationCallbacks;
+#endif
 
     HashSet<WebEditCommandProxy*> m_editCommandSet;
 
index 86213f1..8c1de90 100644 (file)
@@ -264,6 +264,7 @@ messages -> WebPageProxy {
     # Plug-in complex text input support messages
     PluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus)
     SetPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, uint64_t complexTextInputState)
+    ContainsPlugInCallback(bool containsPlugIn, uint64_t plugInProcessToken, uint64_t callbackID)
 
     # Speech messages
     GetIsSpeaking() -> (bool isSpeaking)
index a7339c6..76931f3 100644 (file)
@@ -35,6 +35,9 @@
 #import "PluginComplexTextInputState.h"
 #import "PageClient.h"
 #import "PageClientImpl.h"
+#import "PluginInformation.h"
+#import "PluginProcessManager.h"
+#import "PluginProcessProxy.h"
 #import "StringUtilities.h"
 #import "TextChecker.h"
 #import "WebPageMessages.h"
@@ -456,6 +459,46 @@ void WebPageProxy::setPluginComplexTextInputState(uint64_t pluginComplexTextInpu
     m_pageClient->setPluginComplexTextInputState(pluginComplexTextInputIdentifier, static_cast<PluginComplexTextInputState>(pluginComplexTextInputState));
 }
 
+void WebPageProxy::getInformationForPlugInWithProcessID(pid_t plugInProcessID, PassRefPtr<DictionaryCallback> prpCallback)
+{
+    RefPtr<DictionaryCallback> callback = prpCallback;
+    if (!isValid()) {
+        callback->invalidate();
+        return;
+    }
+
+    PluginProcessProxy* pluginProcessProxy = PluginProcessManager::shared().plugInProcessWithProcessID(plugInProcessID);
+    if (!pluginProcessProxy)
+        callback->performCallbackWithReturnValue(0);
+
+    uint64_t callbackID = callback->callbackID();
+    m_plugInInformationCallbacks.set(callbackID, callback.get());
+    m_process->send(Messages::WebPage::ContainsPluginViewsWithPluginProcessToken(pluginProcessProxy->pluginProcessToken(), callbackID), m_pageID);
+}
+
+void WebPageProxy::containsPlugInCallback(bool containsPlugIn, uint64_t plugInToken, uint64_t callbackID)
+{
+    RefPtr<DictionaryCallback> callback = m_plugInInformationCallbacks.take(callbackID);
+    if (!callback) {
+        // FIXME: Log error or assert.
+        return;
+    }
+
+    if (!containsPlugIn) {
+        callback->performCallbackWithReturnValue(0);
+        return;
+    }
+
+    PluginProcessProxy* plugInProcessProxy = PluginProcessManager::shared().plugInProcessWithToken(plugInToken);
+    ASSERT(plugInProcessProxy);
+
+    ImmutableDictionary::MapType map;
+    getPluginModuleInformation(plugInProcessProxy->pluginProcessAttributes().moduleInfo, map);
+    RefPtr<ImmutableDictionary> plugInInformation = ImmutableDictionary::adopt(map);
+
+    callback->performCallbackWithReturnValue(plugInInformation.get());
+}
+
 void WebPageProxy::executeSavedCommandBySelector(const String& selector, bool& handled)
 {
     MESSAGE_CHECK(isValidKeypressCommandName(selector));
index 651dc4d..c35ee38 100644 (file)
@@ -260,6 +260,8 @@ private:
 
     virtual String getSelectionString() const OVERRIDE { return String(); }
 
+    virtual uint64_t plugInProcessToken() const OVERRIDE { return 0; }
+
     void updateNPNPrivateMode();
 
 #if PLUGIN_ARCHITECTURE(WIN)
index 1d9e97c..1a1ea09 100644 (file)
@@ -191,6 +191,8 @@ protected:
 
     virtual String getSelectionString() const OVERRIDE { return String(); }
 
+    virtual uint64_t plugInProcessToken() const OVERRIDE { return 0; }
+
     WebCore::IntSize m_scrollOffset;
 
 private:
index f8de5a7..a1343db 100644 (file)
@@ -277,6 +277,8 @@ public:
 
     virtual String getSelectionString() const = 0;
 
+    virtual uint64_t plugInProcessToken() const = 0;
+
 protected:
     Plugin();
 
index 1ab6b07..f2c0a1e 100644 (file)
@@ -139,6 +139,8 @@ private:
 
     virtual String getSelectionString() const OVERRIDE { return String(); }
 
+    virtual uint64_t plugInProcessToken() const OVERRIDE { return m_pluginProcessToken; }
+
     float contentsScaleFactor();
     bool needsBackingStore() const;
     bool updateBackingStore();
index d0a2a85..f8c43a6 100644 (file)
@@ -80,6 +80,7 @@ public:
 #endif
 
     WebCore::HTMLPlugInElement* pluginElement() const { return m_pluginElement.get(); }
+    Plugin* plugIn() const { return m_plugin.get(); }
     const Plugin::Parameters& initialParameters() const { return m_parameters; }
 
     // FIXME: Remove this; nobody should have to know about the plug-in view's renderer except the plug-in view itself.
index 1699cc3..5b8f3ba 100644 (file)
@@ -368,7 +368,9 @@ public:
     void setBottomOverhangImage(PassRefPtr<WebImage>);
 
     void updateHeaderAndFooterLayersForDeviceScaleChange(float scaleFactor);
-#endif
+
+    void containsPluginViewsWithPluginProcessToken(uint64_t plugInProcessToken, uint64_t callbackID);
+#endif // PLATFORM(MAC)
 
     bool windowIsFocused() const;
     bool windowAndWebPageAreFocused() const;
index adfb610..47a67b9 100644 (file)
@@ -263,6 +263,8 @@ messages -> WebPage LegacyReceiver {
     # Complex text input support for plug-ins.
     SendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, String textInput)
 
+    ContainsPluginViewsWithPluginProcessToken(uint64_t plugInProcessToken, uint64_t callbackID)
+
     SetWindowIsVisible(bool windowIsVisible)
     WindowAndViewFramesChanged(WebCore::FloatRect windowFrameInScreenCoordinates, WebCore::FloatRect windowFrameInUnflippedScreenCoordinates, WebCore::FloatRect viewFrameInWindowCoordinates, WebCore::FloatPoint accessibilityViewCoordinates)
     ViewExposedRectChanged(WebCore::FloatRect exposedRect)
index e54c881..f33a485 100644 (file)
@@ -970,4 +970,17 @@ void WebPage::drawPagesToPDFFromPDFDocument(CGContextRef context, PDFDocument *p
     }
 }
 
+void WebPage::containsPluginViewsWithPluginProcessToken(uint64_t plugInProcessToken, uint64_t callbackID)
+{
+    bool containsPlugIn = false;
+    for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it) {
+        if ((*it)->plugIn()->plugInProcessToken() == plugInProcessToken) {
+            containsPlugIn = true;
+            break;
+        }
+    }
+
+    send(Messages::WebPageProxy::ContainsPlugInCallback(containsPlugIn, plugInProcessToken, callbackID));
+}
+
 } // namespace WebKit