Implement getFormValue for WebKit2
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jul 2011 18:14:01 +0000 (18:14 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jul 2011 18:14:01 +0000 (18:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=64294
<rdar://problem/3964087>

Source/WebKit2:

Reviewed by Kevin Decker.

* PluginProcess/PluginControllerProxy.cpp:
(WebKit::PluginControllerProxy::getFormValue):
Call Plugin::getFormValue.

* PluginProcess/PluginControllerProxy.messages.in:
Add new GetFormValue message.

* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::getFormValue):
Get the form value and convert it to a String.

* WebProcess/Plugins/Plugin.h:
Add getFormValue pure virtual member function.

* WebProcess/Plugins/PluginProxy.cpp:
(WebKit::PluginProxy::getFormValue):
Send a GetFormValue message to the plug-in process.

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::getFormValue):
Call Plugin::getFormValue.

LayoutTests:

Remove now passing test.

* platform/wk2/Skipped:

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/wk2/Skipped
Source/WebKit2/ChangeLog
Source/WebKit2/PluginProcess/PluginControllerProxy.cpp
Source/WebKit2/PluginProcess/PluginControllerProxy.h
Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in
Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
Source/WebKit2/WebProcess/Plugins/Plugin.h
Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp
Source/WebKit2/WebProcess/Plugins/PluginProxy.h
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/Plugins/PluginView.h

index d6ec4ea..c924518 100644 (file)
@@ -1,3 +1,13 @@
+2011-07-11  Anders Carlsson  <andersca@apple.com>
+
+        Implement getFormValue for WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=64294
+        <rdar://problem/3964087>
+
+        Remove now passing test.
+
+        * platform/wk2/Skipped:
+
 2011-07-11  Ojan Vafai  <ojan@chromium.org>
 
         Fix syntax error from r90757.
index 06fc66b..0930c4b 100644 (file)
@@ -1852,9 +1852,6 @@ editing/spelling/spellcheck-input-search-crash.html
 # missing window.internals.createShadowContentElement
 fast/dom/shadow/create-content-element.html
 
-# Need to implement getFormValue().
-plugins/form-value.html
-
 ### END OF (2) Classified failures without bug reports (yet)
 ########################################
 
index bae6420..83f6e08 100644 (file)
@@ -1,3 +1,33 @@
+2011-07-11  Anders Carlsson  <andersca@apple.com>
+
+        Implement getFormValue for WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=64294
+        <rdar://problem/3964087>
+
+        Reviewed by Kevin Decker.
+
+        * PluginProcess/PluginControllerProxy.cpp:
+        (WebKit::PluginControllerProxy::getFormValue):
+        Call Plugin::getFormValue.
+
+        * PluginProcess/PluginControllerProxy.messages.in:
+        Add new GetFormValue message.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::getFormValue):
+        Get the form value and convert it to a String.
+
+        * WebProcess/Plugins/Plugin.h:
+        Add getFormValue pure virtual member function.
+
+        * WebProcess/Plugins/PluginProxy.cpp:
+        (WebKit::PluginProxy::getFormValue):
+        Send a GetFormValue message to the plug-in process.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::getFormValue):
+        Call Plugin::getFormValue.
+
 2011-07-11  Ada Chan  <adachan@apple.com>
 
         The original request should be accessible from WebNavigationData.
index 6a35858..b1b586a 100644 (file)
@@ -593,6 +593,11 @@ void PluginControllerProxy::privateBrowsingStateChanged(bool isPrivateBrowsingEn
     m_plugin->privateBrowsingStateChanged(isPrivateBrowsingEnabled);
 }
 
+void PluginControllerProxy::getFormValue(bool& returnValue, String& formValue)
+{
+    returnValue = m_plugin->getFormValue(formValue);
+}
+
 bool PluginControllerProxy::tryToShortCircuitEvaluate(NPObject* npObject, const String& scriptString, NPVariant* result)
 {
     // Only try to short circuit evaluate for plug-ins that have the quirk specified.
index 04375d0..09cff3a 100644 (file)
@@ -140,6 +140,7 @@ private:
 #endif
 
     void privateBrowsingStateChanged(bool);
+    void getFormValue(bool& returnValue, String& formValue);
 
     bool tryToShortCircuitEvaluate(NPObject*, const String& scriptString, NPVariant* result);
 
index 4a5ac6d..ecb1410 100644 (file)
@@ -105,6 +105,9 @@ messages -> PluginControllerProxy {
     
     # Sent when private browsing is enabled or disabled
     PrivateBrowsingStateChanged(bool isPrivateBrowsingEnabled)
+
+    # Gets the string representating the form value of the plug-in
+    GetFormValue() -> (bool returnValue, WTF::String formValue)
 }
 
 #endif
index 05124c6..0c2e554 100644 (file)
@@ -767,6 +767,21 @@ void NetscapePlugin::privateBrowsingStateChanged(bool privateBrowsingEnabled)
     NPP_SetValue(NPNVprivateModeBool, &value);
 }
 
+bool NetscapePlugin::getFormValue(String& formValue)
+{
+    ASSERT(m_isStarted);
+
+    char* formValueString = 0;
+    if (NPP_GetValue(NPPVformValue, &formValueString) != NPERR_NO_ERROR)
+        return false;
+
+    formValue = String::fromUTF8(formValueString);
+
+    // The plug-in allocates the form value string with NPN_MemAlloc so it needs to be freed with NPN_MemFree.
+    npnMemFree(formValueString);
+    return true;
+}
+
 bool NetscapePlugin::supportsSnapshotting() const
 {
 #if PLATFORM(MAC)
index a8dfda3..b397fa8 100644 (file)
@@ -193,6 +193,7 @@ private:
 #endif
 
     virtual void privateBrowsingStateChanged(bool);
+    virtual bool getFormValue(String& formValue);
 
     bool supportsSnapshotting() const;
 
index a76cf45..731b877 100644 (file)
@@ -192,6 +192,9 @@ public:
     // Called when the private browsing state for this plug-in changes.
     virtual void privateBrowsingStateChanged(bool) = 0;
 
+    // Gets the form value representation for the plug-in, letting plug-ins participate in form submission.
+    virtual bool getFormValue(String& formValue) = 0;
+
 protected:
     Plugin();
 
index 85af396..b5c44ec 100644 (file)
@@ -373,6 +373,15 @@ void PluginProxy::privateBrowsingStateChanged(bool isPrivateBrowsingEnabled)
     m_connection->connection()->send(Messages::PluginControllerProxy::PrivateBrowsingStateChanged(isPrivateBrowsingEnabled), m_pluginInstanceID);
 }
 
+bool PluginProxy::getFormValue(String& formValue)
+{
+    bool returnValue;
+    if (!m_connection->connection()->sendSync(Messages::PluginControllerProxy::GetFormValue(), Messages::PluginControllerProxy::GetFormValue::Reply(returnValue, formValue), m_pluginInstanceID))
+        return false;
+
+    return returnValue;
+}
+
 void PluginProxy::loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, const HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups)
 {
     controller()->loadURL(requestID, method, urlString, target, headerFields, httpBody, allowPopups);
index 1b3444c..2f20980 100644 (file)
@@ -101,6 +101,7 @@ private:
 #endif
 
     virtual void privateBrowsingStateChanged(bool);
+    virtual bool getFormValue(String& formValue);
 
     bool needsBackingStore() const;
     uint64_t windowNPObjectID();
index 626967d..dba4325 100644 (file)
@@ -507,6 +507,15 @@ void PluginView::privateBrowsingStateChanged(bool privateBrowsingEnabled)
     m_plugin->privateBrowsingStateChanged(privateBrowsingEnabled);
 }
 
+bool PluginView::getFormValue(String& formValue)
+{
+    // The plug-in can be null here if it failed to initialize.
+    if (!m_isInitialized || !m_plugin)
+        return false;
+
+    return m_plugin->getFormValue(formValue);
+}
+
 void PluginView::setFrameRect(const WebCore::IntRect& rect)
 {
     Widget::setFrameRect(rect);
index abaf4b2..938e595 100644 (file)
@@ -102,7 +102,8 @@ private:
 #endif
     virtual JSC::JSObject* scriptObject(JSC::JSGlobalObject*);
     virtual void privateBrowsingStateChanged(bool);
-    
+    virtual bool getFormValue(String&);
+
     // WebCore::Widget
     virtual void setFrameRect(const WebCore::IntRect&);
     virtual void setBoundsSize(const WebCore::IntSize&);