Commit 2ff9d196 authored by weinig@apple.com's avatar weinig@apple.com

Pass values map to willSubmitForm in WebKit2 API

Part of <rdar://problem/8255932>
https://bugs.webkit.org/show_bug.cgi?id=43995

Reviewed by Brady Eidson.

* Platform/CoreIPC/ArgumentCoders.h:
(CoreIPC::):
Add overload for std::pair.

* Shared/ImmutableDictionary.h:
(WebKit::ImmutableDictionary::adopt):
Fix function signature by removing size parameter.

* UIProcess/API/C/WKPage.h:
Add dictionary parameter to callback.

* UIProcess/WebFormClient.cpp:
(WebKit::WebFormClient::willSubmitForm):
Create an ImmutableDictionary from the vector of string pairs.

* UIProcess/WebFormClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didReceiveMessage):
(WebKit::WebPageProxy::willSubmitForm):
* UIProcess/WebPageProxy.h:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchWillSubmitForm):
Plumb through the values vector.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65341 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4cbfdfd4
2010-08-13 Sam Weinig <sam@webkit.org>
Reviewed by Brady Eidson.
Pass values map to willSubmitForm in WebKit2 API
Part of <rdar://problem/8255932>
https://bugs.webkit.org/show_bug.cgi?id=43995
* Platform/CoreIPC/ArgumentCoders.h:
(CoreIPC::):
Add overload for std::pair.
* Shared/ImmutableDictionary.h:
(WebKit::ImmutableDictionary::adopt):
Fix function signature by removing size parameter.
* UIProcess/API/C/WKPage.h:
Add dictionary parameter to callback.
* UIProcess/WebFormClient.cpp:
(WebKit::WebFormClient::willSubmitForm):
Create an ImmutableDictionary from the vector of string pairs.
* UIProcess/WebFormClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didReceiveMessage):
(WebKit::WebPageProxy::willSubmitForm):
* UIProcess/WebPageProxy.h:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchWillSubmitForm):
Plumb through the values vector.
2010-08-13 Sam Weinig <sam@webkit.org>
Reviewed by Brady Eidson.
......
......@@ -28,7 +28,7 @@
#include "ArgumentDecoder.h"
#include "ArgumentEncoder.h"
#include <utility>
#include <wtf/Vector.h>
namespace CoreIPC {
......@@ -45,6 +45,29 @@ template<typename T> struct SimpleArgumentCoder {
}
};
template<typename T, typename U> struct ArgumentCoder<std::pair<T, U> > {
static void encode(ArgumentEncoder* encoder, const std::pair<T, U>& pair)
{
encoder->encode(pair.first);
encoder->encode(pair.second);
}
static bool decode(ArgumentDecoder* decoder, std::pair<T, U>& pair)
{
T first;
if (!decoder->decode(first))
return false;
U second;
if (!decoder->decode(second))
return false;
pair.first = first;
pair.second = second;
return true;
}
};
template<typename T> struct ArgumentCoder<Vector<T> > {
static void encode(ArgumentEncoder* encoder, const Vector<T>& vector)
{
......@@ -59,7 +82,7 @@ template<typename T> struct ArgumentCoder<Vector<T> > {
if (!decoder->decodeUInt64(size))
return false;
// Before allocating the cector, make sure that the decoder buffer is big enough.
// Before allocating the vector, make sure that the decoder buffer is big enough.
if (!decoder->bufferIsLargeEnoughtToContain<T>(size)) {
decoder->markInvalid();
return false;
......
......@@ -46,7 +46,7 @@ public:
{
return adoptRef(new ImmutableDictionary);
}
static PassRefPtr<ImmutableDictionary> adopt(MapType& map, size_t size)
static PassRefPtr<ImmutableDictionary> adopt(MapType& map)
{
return adoptRef(new ImmutableDictionary(map, Adopt));
}
......
......@@ -114,7 +114,7 @@ struct WKPagePolicyClient {
typedef struct WKPagePolicyClient WKPagePolicyClient;
// Form Client.
typedef void (*WKPageWillSubmitFormCallback)(WKPageRef page, WKFrameRef frame, WKFrameRef sourceFrame, WKFormSubmissionListenerRef listener, const void* clientInfo);
typedef void (*WKPageWillSubmitFormCallback)(WKPageRef page, WKFrameRef frame, WKFrameRef sourceFrame, WKDictionaryRef values, WKFormSubmissionListenerRef listener, const void* clientInfo);
struct WKPageFormClient {
int version;
......
......@@ -25,9 +25,10 @@
#include "WebFormClient.h"
#include "ImmutableDictionary.h"
#include "WKAPICast.h"
using namespace WebCore;
#include "WebString.h"
#include <wtf/text/WTFString.h>
namespace WebKit {
......@@ -44,12 +45,17 @@ void WebFormClient::initialize(const WKPageFormClient* client)
memset(&m_pageFormClient, 0, sizeof(m_pageFormClient));
}
bool WebFormClient::willSubmitForm(WebPageProxy* page, WebFrameProxy* frame, WebFrameProxy* sourceFrame, WebFormSubmissionListenerProxy* listener)
bool WebFormClient::willSubmitForm(WebPageProxy* page, WebFrameProxy* frame, WebFrameProxy* sourceFrame, Vector<std::pair<String, String> >& textFieldValues, WebFormSubmissionListenerProxy* listener)
{
if (!m_pageFormClient.willSubmitForm)
return false;
m_pageFormClient.willSubmitForm(toRef(page), toRef(frame), toRef(sourceFrame), toRef(listener), m_pageFormClient.clientInfo);
ImmutableDictionary::MapType map;
for (size_t i = 0; i < textFieldValues.size(); ++i)
map.set(textFieldValues[i].first, WebString::create(textFieldValues[i].second));
RefPtr<ImmutableDictionary> textFieldsMap = ImmutableDictionary::adopt(map);
m_pageFormClient.willSubmitForm(toRef(page), toRef(frame), toRef(sourceFrame), toRef(textFieldsMap.get()), toRef(listener), m_pageFormClient.clientInfo);
return true;
}
......
......@@ -27,7 +27,9 @@
#define WebFormClient_h
#include "WKPage.h"
#include <utility>
#include <wtf/Forward.h>
#include <wtf/Vector.h>
namespace WebKit {
......@@ -40,8 +42,8 @@ public:
WebFormClient();
void initialize(const WKPageFormClient*);
// FIXME: Add value dictionary and form element reference.
bool willSubmitForm(WebPageProxy*, WebFrameProxy*, WebFrameProxy*, WebFormSubmissionListenerProxy*);
// FIXME: Add some type of form element reference or anotated user data.
bool willSubmitForm(WebPageProxy*, WebFrameProxy*, WebFrameProxy*, Vector<std::pair<String, String> >& textFieldValues, WebFormSubmissionListenerProxy*);
private:
WKPageFormClient m_pageFormClient;
......
......@@ -543,10 +543,11 @@ void WebPageProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::M
case WebPageProxyMessage::WillSubmitForm: {
uint64_t frameID;
uint64_t sourceFrameID;
Vector<std::pair<String, String> > textFieldValues;
uint64_t listenerID;
if (!arguments->decode(CoreIPC::Out(frameID, sourceFrameID, listenerID)))
if (!arguments->decode(CoreIPC::Out(frameID, sourceFrameID, textFieldValues, listenerID)))
return;
willSubmitForm(webFrame(frameID), webFrame(sourceFrameID), listenerID);
willSubmitForm(webFrame(frameID), webFrame(sourceFrameID), textFieldValues, listenerID);
break;
}
......@@ -836,10 +837,10 @@ void WebPageProxy::decidePolicyForMIMEType(WebFrameProxy* frame, const String& M
// FormClient
void WebPageProxy::willSubmitForm(WebFrameProxy* frame, WebFrameProxy* sourceFrame, uint64_t listenerID)
void WebPageProxy::willSubmitForm(WebFrameProxy* frame, WebFrameProxy* sourceFrame, Vector<std::pair<String, String> >& textFieldValues, uint64_t listenerID)
{
RefPtr<WebFormSubmissionListenerProxy> listener = frame->setUpFormSubmissionListenerProxy(listenerID);
if (!m_formClient.willSubmitForm(this, frame, sourceFrame, listener.get()))
if (!m_formClient.willSubmitForm(this, frame, sourceFrame, textFieldValues, listener.get()))
listener->continueSubmission();
}
......
......@@ -192,7 +192,7 @@ private:
void decidePolicyForNewWindowAction(WebFrameProxy*, WebCore::NavigationType navigationType, const WTF::String& url, uint64_t listenerID);
void decidePolicyForMIMEType(WebFrameProxy*, const WTF::String& MIMEType, const WTF::String& url, uint64_t listenerID);
void willSubmitForm(WebFrameProxy* frame, WebFrameProxy* frameSource, uint64_t listenerID);
void willSubmitForm(WebFrameProxy* frame, WebFrameProxy* frameSource, Vector<std::pair<WTF::String, WTF::String> >& textFieldValues, uint64_t listenerID);
PassRefPtr<WebPageProxy> createNewPage();
void showPage();
......
......@@ -478,7 +478,7 @@ void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function,
WebFrame* sourceFrame = static_cast<WebFrameLoaderClient*>(formState->sourceFrame()->loader()->client())->webFrame();
WebProcess::shared().connection()->send(WebPageProxyMessage::WillSubmitForm, webPage->pageID(),
CoreIPC::In(m_frame->frameID(), sourceFrame->frameID(), listenerID));
CoreIPC::In(m_frame->frameID(), sourceFrame->frameID(), formState->textFieldValues(), listenerID));
}
void WebFrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment