Skip to content
Permalink
Browse files
2011-03-03 Sam Weinig <sam@webkit.org>
        Reviewed by Anders Carlsson.

        Give the Bundle's policy client the option of deciding the policy
        https://bugs.webkit.org/show_bug.cgi?id=55699

        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
        Add WKBundlePagePolicyAction enum and make it the return value of
        the WKBundlePagePolicyClient functions.

        * WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp:
        (WebKit::InjectedBundlePagePolicyClient::decidePolicyForNavigationAction):
        (WebKit::InjectedBundlePagePolicyClient::decidePolicyForNewWindowAction):
        (WebKit::InjectedBundlePagePolicyClient::decidePolicyForMIMEType):
        * WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.h:
        Pass the return value back to the caller. For unimplemented functions, return WKBundlePagePolicyActionPassThrough.

        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForMIMEType):
        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
        Call the policy function early if the bundle handles it.


Canonical link: https://commits.webkit.org/70170@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@80275 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
weinig committed Mar 3, 2011
1 parent f7e9e39 commit 6a5fed3cc930b365b34e33e769df41484a0f4503
Showing 5 changed files with 64 additions and 18 deletions.
@@ -1,3 +1,27 @@
2011-03-03 Sam Weinig <sam@webkit.org>

Reviewed by Anders Carlsson.

Give the Bundle's policy client the option of deciding the policy
https://bugs.webkit.org/show_bug.cgi?id=55699

* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
Add WKBundlePagePolicyAction enum and make it the return value of
the WKBundlePagePolicyClient functions.

* WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp:
(WebKit::InjectedBundlePagePolicyClient::decidePolicyForNavigationAction):
(WebKit::InjectedBundlePagePolicyClient::decidePolicyForNewWindowAction):
(WebKit::InjectedBundlePagePolicyClient::decidePolicyForMIMEType):
* WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.h:
Pass the return value back to the caller. For unimplemented functions, return WKBundlePagePolicyActionPassThrough.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForMIMEType):
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
Call the policy function early if the bundle handles it.

2011-03-02 Brian Weinstein <bweinstein@apple.com>

Reviewed by Adam Roben.
@@ -114,10 +114,17 @@ struct WKBundlePageLoaderClient {
};
typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient;

enum {
WKBundlePagePolicyActionPassThrough,
WKBundlePagePolicyActionUse
};
typedef uint32_t WKBundlePagePolicyAction;


// Policy Client
typedef void (*WKBundlePageDecidePolicyForNavigationActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo);
typedef void (*WKBundlePageDecidePolicyForNewWindowActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKStringRef frameName, WKTypeRef* userData, const void* clientInfo);
typedef void (*WKBundlePageDecidePolicyForMIMETypeCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKStringRef MIMEType, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo);
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 (*WKBundlePageDecidePolicyForMIMETypeCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKStringRef MIMEType, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo);

struct WKBundlePagePolicyClient {
int version;
@@ -33,40 +33,43 @@ using namespace WebCore;

namespace WebKit {

void InjectedBundlePagePolicyClient::decidePolicyForNavigationAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData)
WKBundlePagePolicyAction InjectedBundlePagePolicyClient::decidePolicyForNavigationAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData)
{
if (!m_client.decidePolicyForNavigationAction)
return;
return WKBundlePagePolicyActionPassThrough;

RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);

WKTypeRef userDataToPass = 0;
m_client.decidePolicyForNavigationAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.get()), &userDataToPass, m_client.clientInfo);
WKBundlePagePolicyAction policy = m_client.decidePolicyForNavigationAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.get()), &userDataToPass, m_client.clientInfo);
userData = adoptRef(toImpl(userDataToPass));
return policy;
}

void InjectedBundlePagePolicyClient::decidePolicyForNewWindowAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, const String& frameName, RefPtr<APIObject>& userData)
WKBundlePagePolicyAction InjectedBundlePagePolicyClient::decidePolicyForNewWindowAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, const String& frameName, RefPtr<APIObject>& userData)
{
if (!m_client.decidePolicyForNewWindowAction)
return;
return WKBundlePagePolicyActionPassThrough;

RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);

WKTypeRef userDataToPass = 0;
m_client.decidePolicyForNewWindowAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.get()), toAPI(frameName.impl()), &userDataToPass, m_client.clientInfo);
WKBundlePagePolicyAction policy = m_client.decidePolicyForNewWindowAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.get()), toAPI(frameName.impl()), &userDataToPass, m_client.clientInfo);
userData = adoptRef(toImpl(userDataToPass));
return policy;
}

void InjectedBundlePagePolicyClient::decidePolicyForMIMEType(WebPage* page, WebFrame* frame, const String& MIMEType, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData)
WKBundlePagePolicyAction InjectedBundlePagePolicyClient::decidePolicyForMIMEType(WebPage* page, WebFrame* frame, const String& MIMEType, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData)
{
if (!m_client.decidePolicyForMIMEType)
return;
return WKBundlePagePolicyActionPassThrough;

RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);

WKTypeRef userDataToPass = 0;
m_client.decidePolicyForMIMEType(toAPI(page), toAPI(frame), toAPI(MIMEType.impl()), toAPI(request.get()), &userDataToPass, m_client.clientInfo);
WKBundlePagePolicyAction policy = m_client.decidePolicyForMIMEType(toAPI(page), toAPI(frame), toAPI(MIMEType.impl()), toAPI(request.get()), &userDataToPass, m_client.clientInfo);
userData = adoptRef(toImpl(userDataToPass));
return policy;
}

} // namespace WebKit
@@ -43,9 +43,9 @@ class WebPage;

class InjectedBundlePagePolicyClient : public APIClient<WKBundlePagePolicyClient> {
public:
void decidePolicyForNavigationAction(WebPage*, WebFrame*, InjectedBundleNavigationAction*, const WebCore::ResourceRequest&, RefPtr<APIObject>& userData);
void decidePolicyForNewWindowAction(WebPage*, WebFrame*, InjectedBundleNavigationAction*, const WebCore::ResourceRequest&, const String& frameName, RefPtr<APIObject>& userData);
void decidePolicyForMIMEType(WebPage*, WebFrame*, const String& MIMEType, const WebCore::ResourceRequest&, RefPtr<APIObject>& userData);
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 decidePolicyForMIMEType(WebPage*, WebFrame*, const String& MIMEType, const WebCore::ResourceRequest&, RefPtr<APIObject>& userData);
};

} // namespace WebKit
@@ -587,7 +587,11 @@ void WebFrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction f
RefPtr<APIObject> userData;

// Notify the bundle client.
webPage->injectedBundlePolicyClient().decidePolicyForMIMEType(webPage, m_frame, MIMEType, request, userData);
WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForMIMEType(webPage, m_frame, MIMEType, request, userData);
if (policy == WKBundlePagePolicyActionUse) {
(m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse);
return;
}

uint64_t listenerID = m_frame->setUpPolicyListener(function);
bool receivedPolicyAction;
@@ -614,7 +618,11 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFun
RefPtr<InjectedBundleNavigationAction> action = InjectedBundleNavigationAction::create(m_frame, navigationAction, formState);

// Notify the bundle client.
webPage->injectedBundlePolicyClient().decidePolicyForNewWindowAction(webPage, m_frame, action.get(), request, frameName, userData);
WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForNewWindowAction(webPage, m_frame, action.get(), request, frameName, userData);
if (policy == WKBundlePagePolicyActionUse) {
(m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse);
return;
}


uint64_t listenerID = m_frame->setUpPolicyListener(function);
@@ -640,7 +648,11 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFu
RefPtr<InjectedBundleNavigationAction> action = InjectedBundleNavigationAction::create(m_frame, navigationAction, formState);

// Notify the bundle client.
webPage->injectedBundlePolicyClient().decidePolicyForNavigationAction(webPage, m_frame, action.get(), request, userData);
WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForNavigationAction(webPage, m_frame, action.get(), request, userData);
if (policy == WKBundlePagePolicyActionUse) {
(m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse);
return;
}

uint64_t listenerID = m_frame->setUpPolicyListener(function);
bool receivedPolicyAction;

0 comments on commit 6a5fed3

Please sign in to comment.