Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
2011-03-07 Sam Weinig <sam@webkit.org>
        Reviewed by Anders Carlsson.

        Add unableToImplementPolicy callback for WebKit2 policy client
        <rdar://problem/9071902>
        https://bugs.webkit.org/show_bug.cgi?id=55884

        * UIProcess/API/C/WKPage.h:
        * UIProcess/WebPageProxy.cpp:
        (WebKit::WebPageProxy::unableToImplementPolicy):
        * UIProcess/WebPageProxy.h:
        * UIProcess/WebPageProxy.messages.in:
        * UIProcess/WebPolicyClient.cpp:
        (WebKit::WebPolicyClient::unableToImplementPolicy):
        * UIProcess/WebPolicyClient.h:
        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
        * WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp:
        (WebKit::InjectedBundlePagePolicyClient::unableToImplementPolicy):
        * WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.h:
        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
        (WebKit::WebFrameLoaderClient::dispatchUnableToImplementPolicy):
        Pipe unableToImplementPolicy through both the bundle and the main WebKit2 API.
2011-03-07  Sam Weinig  <sam@webkit.org>

        Reviewed by Anders Carlsson.

        Add unableToImplementPolicy callback for WebKit2 policy client
        <rdar://problem/9071902>
        https://bugs.webkit.org/show_bug.cgi?id=55884

        * MiniBrowser/mac/BrowserWindowController.m:
        (-[BrowserWindowController awakeFromNib]):
        Update policy client initialization struct for new member.


Canonical link: https://commits.webkit.org/70373@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@80479 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
weinig committed Mar 7, 2011
1 parent 864d5ea commit 116b8cb
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 6 deletions.
24 changes: 24 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,27 @@
2011-03-07 Sam Weinig <sam@webkit.org>

Reviewed by Anders Carlsson.

Add unableToImplementPolicy callback for WebKit2 policy client
<rdar://problem/9071902>
https://bugs.webkit.org/show_bug.cgi?id=55884

* UIProcess/API/C/WKPage.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::unableToImplementPolicy):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/WebPolicyClient.cpp:
(WebKit::WebPolicyClient::unableToImplementPolicy):
* UIProcess/WebPolicyClient.h:
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp:
(WebKit::InjectedBundlePagePolicyClient::unableToImplementPolicy):
* WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.h:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchUnableToImplementPolicy):
Pipe unableToImplementPolicy through both the bundle and the main WebKit2 API.

2011-03-07 Sam Weinig <sam@webkit.org>

Reviewed by Anders Carlsson.
Expand Down
2 changes: 2 additions & 0 deletions Source/WebKit2/UIProcess/API/C/WKPage.h
Expand Up @@ -102,13 +102,15 @@ typedef struct WKPageLoaderClient WKPageLoaderClient;
typedef void (*WKPageDecidePolicyForNavigationActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
typedef void (*WKPageDecidePolicyForNewWindowActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
typedef void (*WKPageDecidePolicyForResponseCallback)(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
typedef void (*WKPageUnableToImplementPolicyCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo);

struct WKPagePolicyClient {
int version;
const void * clientInfo;
WKPageDecidePolicyForNavigationActionCallback decidePolicyForNavigationAction;
WKPageDecidePolicyForNewWindowActionCallback decidePolicyForNewWindowAction;
WKPageDecidePolicyForResponseCallback decidePolicyForResponse;
WKPageUnableToImplementPolicyCallback unableToImplementPolicy;
};
typedef struct WKPagePolicyClient WKPagePolicyClient;

Expand Down
13 changes: 13 additions & 0 deletions Source/WebKit2/UIProcess/WebPageProxy.cpp
Expand Up @@ -1688,6 +1688,19 @@ void WebPageProxy::decidePolicyForResponse(uint64_t frameID, const ResourceRespo
}
}

void WebPageProxy::unableToImplementPolicy(uint64_t frameID, const WebCore::ResourceError& error, CoreIPC::ArgumentDecoder* arguments)
{
RefPtr<APIObject> userData;
WebContextUserMessageDecoder messageDecoder(userData, context());
if (!arguments->decode(messageDecoder))
return;

WebFrameProxy* frame = process()->webFrame(frameID);
MESSAGE_CHECK(frame);

m_policyClient.unableToImplementPolicy(this, frame, error, userData.get());
}

// FormClient

void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments)
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit2/UIProcess/WebPageProxy.h
Expand Up @@ -502,6 +502,7 @@ class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {
void decidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const WebCore::ResourceRequest&, uint64_t listenerID, CoreIPC::ArgumentDecoder*, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID);
void decidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const WebCore::ResourceRequest&, const String& frameName, uint64_t listenerID, CoreIPC::ArgumentDecoder*);
void decidePolicyForResponse(uint64_t frameID, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID);
void unableToImplementPolicy(uint64_t frameID, const WebCore::ResourceError&, CoreIPC::ArgumentDecoder* arguments);

void willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, uint64_t listenerID, CoreIPC::ArgumentDecoder*);

Expand Down
1 change: 1 addition & 0 deletions Source/WebKit2/UIProcess/WebPageProxy.messages.in
Expand Up @@ -69,6 +69,7 @@ messages -> WebPageProxy {
DecidePolicyForResponse(uint64_t frameID, WebCore::ResourceResponse response, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID)
DecidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID)
DecidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WebCore::ResourceRequest request, WTF::String frameName, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData)
UnableToImplementPolicy(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData)

# Progress messages
DidChangeProgress(double value)
Expand Down
9 changes: 9 additions & 0 deletions Source/WebKit2/UIProcess/WebPolicyClient.cpp
Expand Up @@ -26,6 +26,7 @@
#include "config.h"
#include "WebPolicyClient.h"

#include "APIObject.h"
#include "WKAPICast.h"
#include "WebURLRequest.h"

Expand Down Expand Up @@ -67,4 +68,12 @@ bool WebPolicyClient::decidePolicyForResponse(WebPageProxy* page, WebFrameProxy*
return true;
}

void WebPolicyClient::unableToImplementPolicy(WebPageProxy* page, WebFrameProxy* frame, const ResourceError& error, APIObject* userData)
{
if (!m_client.unableToImplementPolicy)
return;

m_client.unableToImplementPolicy(toAPI(page), toAPI(frame), toAPI(error), toAPI(userData), m_client.clientInfo);
}

} // namespace WebKit
4 changes: 3 additions & 1 deletion Source/WebKit2/UIProcess/WebPolicyClient.h
Expand Up @@ -27,19 +27,20 @@
#define WebPolicyClient_h

#include "APIClient.h"
#include "APIObject.h"
#include "WKPage.h"
#include "WebEvent.h"
#include <WebCore/FrameLoaderTypes.h>
#include <wtf/Forward.h>

namespace WebCore {
class ResourceError;
class ResourceRequest;
class ResourceResponse;
}

namespace WebKit {

class APIObject;
class WebPageProxy;
class WebFrameProxy;
class WebFramePolicyListenerProxy;
Expand All @@ -49,6 +50,7 @@ class WebPolicyClient : public APIClient<WKPagePolicyClient> {
bool decidePolicyForNavigationAction(WebPageProxy*, WebFrameProxy*, WebCore::NavigationType, WebEvent::Modifiers, WebMouseEvent::Button, const WebCore::ResourceRequest&, WebFramePolicyListenerProxy*, APIObject* userData);
bool decidePolicyForNewWindowAction(WebPageProxy*, WebFrameProxy*, WebCore::NavigationType, WebEvent::Modifiers, WebMouseEvent::Button, const WebCore::ResourceRequest&, const String& frameName, WebFramePolicyListenerProxy*, APIObject* userData);
bool decidePolicyForResponse(WebPageProxy*, WebFrameProxy*, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, WebFramePolicyListenerProxy*, APIObject* userData);
void unableToImplementPolicy(WebPageProxy*, WebFrameProxy*, const WebCore::ResourceError&, APIObject* userData);
};

} // namespace WebKit
Expand Down
5 changes: 3 additions & 2 deletions Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
Expand Up @@ -120,18 +120,19 @@ enum {
};
typedef uint32_t WKBundlePagePolicyAction;


// Policy Client
typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForNavigationActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo);
typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForNewWindowActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKStringRef frameName, WKTypeRef* userData, const void* clientInfo);
typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForResponseCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo);
typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForResponseCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo);
typedef void (*WKBundlePageUnableToImplementPolicyCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef* userData, const void* clientInfo);

struct WKBundlePagePolicyClient {
int version;
const void * clientInfo;
WKBundlePageDecidePolicyForNavigationActionCallback decidePolicyForNavigationAction;
WKBundlePageDecidePolicyForNewWindowActionCallback decidePolicyForNewWindowAction;
WKBundlePageDecidePolicyForResponseCallback decidePolicyForResponse;
WKBundlePageUnableToImplementPolicyCallback unableToImplementPolicy;
};
typedef struct WKBundlePagePolicyClient WKBundlePagePolicyClient;

Expand Down
Expand Up @@ -27,6 +27,7 @@
#include "InjectedBundlePagePolicyClient.h"

#include "WKBundleAPICast.h"
#include "WebError.h"
#include "WebURLRequest.h"

using namespace WebCore;
Expand Down Expand Up @@ -73,4 +74,14 @@ WKBundlePagePolicyAction InjectedBundlePagePolicyClient::decidePolicyForResponse
return policy;
}

void InjectedBundlePagePolicyClient::unableToImplementPolicy(WebPage* page, WebFrame* frame, const WebCore::ResourceError& error, RefPtr<APIObject>& userData)
{
if (!m_client.unableToImplementPolicy)
return;

WKTypeRef userDataToPass = 0;
m_client.unableToImplementPolicy(toAPI(page), toAPI(frame), toAPI(error), &userDataToPass, m_client.clientInfo);
userData = adoptRef(toImpl(userDataToPass));
}

} // namespace WebKit
Expand Up @@ -32,6 +32,7 @@
#include <wtf/Forward.h>

namespace WebCore {
class ResourceError;
class ResourceRequest;
class ResourceResponse;
}
Expand All @@ -47,6 +48,7 @@ class InjectedBundlePagePolicyClient : public APIClient<WKBundlePagePolicyClient
WKBundlePagePolicyAction decidePolicyForNavigationAction(WebPage*, WebFrame*, InjectedBundleNavigationAction*, const WebCore::ResourceRequest&, RefPtr<APIObject>& userData);
WKBundlePagePolicyAction decidePolicyForNewWindowAction(WebPage*, WebFrame*, InjectedBundleNavigationAction*, const WebCore::ResourceRequest&, const String& frameName, RefPtr<APIObject>& userData);
WKBundlePagePolicyAction decidePolicyForResponse(WebPage*, WebFrame*, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, RefPtr<APIObject>& userData);
void unableToImplementPolicy(WebPage*, WebFrame*, const WebCore::ResourceError&, RefPtr<APIObject>& userData);
};

} // namespace WebKit
Expand Down
14 changes: 12 additions & 2 deletions Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Expand Up @@ -673,9 +673,19 @@ void WebFrameLoaderClient::cancelPolicyCheck()
m_frame->invalidatePolicyListener();
}

void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&)
void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError& error)
{
notImplemented();
WebPage* webPage = m_frame->page();
if (!webPage)
return;

RefPtr<APIObject> userData;

// Notify the bundle client.
webPage->injectedBundlePolicyClient().unableToImplementPolicy(webPage, m_frame, error, userData);

// Notify the UIProcess.
webPage->send(Messages::WebPageProxy::UnableToImplementPolicy(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get())));
}

void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, PassRefPtr<FormState> prpFormState)
Expand Down
12 changes: 12 additions & 0 deletions Tools/ChangeLog
@@ -1,3 +1,15 @@
2011-03-07 Sam Weinig <sam@webkit.org>

Reviewed by Anders Carlsson.

Add unableToImplementPolicy callback for WebKit2 policy client
<rdar://problem/9071902>
https://bugs.webkit.org/show_bug.cgi?id=55884

* MiniBrowser/mac/BrowserWindowController.m:
(-[BrowserWindowController awakeFromNib]):
Update policy client initialization struct for new member.

2011-03-07 Sam Weinig <sam@webkit.org>

Reviewed by Anders Carlsson.
Expand Down
3 changes: 2 additions & 1 deletion Tools/MiniBrowser/mac/BrowserWindowController.m
Expand Up @@ -607,7 +607,8 @@ - (void)awakeFromNib
self, /* clientInfo */
decidePolicyForNavigationAction,
decidePolicyForNewWindowAction,
decidePolicyForResponse
decidePolicyForResponse,
0 /* unableToImplementPolicy */
};
WKPageSetPagePolicyClient(_webView.pageRef, &policyClient);

Expand Down

0 comments on commit 116b8cb

Please sign in to comment.