Changeset 80275 in webkit


Ignore:
Timestamp:
Mar 3, 2011 1:06:05 PM (13 years ago)
Author:
weinig@apple.com
Message:

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.
Location:
trunk/Source/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r80263 r80275  
     12011-03-03  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Give the Bundle's policy client the option of deciding the policy
     6        https://bugs.webkit.org/show_bug.cgi?id=55699
     7
     8        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
     9        Add WKBundlePagePolicyAction enum and make it the return value of
     10        the WKBundlePagePolicyClient functions.
     11
     12        * WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp:
     13        (WebKit::InjectedBundlePagePolicyClient::decidePolicyForNavigationAction):
     14        (WebKit::InjectedBundlePagePolicyClient::decidePolicyForNewWindowAction):
     15        (WebKit::InjectedBundlePagePolicyClient::decidePolicyForMIMEType):
     16        * WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.h:
     17        Pass the return value back to the caller. For unimplemented functions, return WKBundlePagePolicyActionPassThrough.
     18
     19        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     20        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForMIMEType):
     21        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
     22        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
     23        Call the policy function early if the bundle handles it.
     24
    1252011-03-02  Brian Weinstein  <bweinstein@apple.com>
    226
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h

    r78418 r80275  
    115115typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient;
    116116
     117enum {
     118    WKBundlePagePolicyActionPassThrough,
     119    WKBundlePagePolicyActionUse
     120};
     121typedef uint32_t WKBundlePagePolicyAction;
     122
     123   
    117124// Policy Client
    118 typedef void (*WKBundlePageDecidePolicyForNavigationActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo);
    119 typedef void (*WKBundlePageDecidePolicyForNewWindowActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKStringRef frameName, WKTypeRef* userData, const void* clientInfo);
    120 typedef void (*WKBundlePageDecidePolicyForMIMETypeCallback)(WKBundlePageRef page, WKBundleFrameRef frame,  WKStringRef MIMEType, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo);
     125typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForNavigationActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo);
     126typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForNewWindowActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKStringRef frameName, WKTypeRef* userData, const void* clientInfo);
     127typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForMIMETypeCallback)(WKBundlePageRef page, WKBundleFrameRef frame,  WKStringRef MIMEType, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo);
    121128
    122129struct WKBundlePagePolicyClient {
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp

    r77974 r80275  
    3434namespace WebKit {
    3535
    36 void InjectedBundlePagePolicyClient::decidePolicyForNavigationAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData)
     36WKBundlePagePolicyAction InjectedBundlePagePolicyClient::decidePolicyForNavigationAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData)
    3737{
    3838    if (!m_client.decidePolicyForNavigationAction)
    39         return;
     39        return WKBundlePagePolicyActionPassThrough;
    4040
    4141    RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
    4242
    4343    WKTypeRef userDataToPass = 0;
    44     m_client.decidePolicyForNavigationAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.get()), &userDataToPass, m_client.clientInfo);
     44    WKBundlePagePolicyAction policy = m_client.decidePolicyForNavigationAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.get()), &userDataToPass, m_client.clientInfo);
    4545    userData = adoptRef(toImpl(userDataToPass));
     46    return policy;
    4647}
    4748
    48 void InjectedBundlePagePolicyClient::decidePolicyForNewWindowAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, const String& frameName, RefPtr<APIObject>& userData)
     49WKBundlePagePolicyAction InjectedBundlePagePolicyClient::decidePolicyForNewWindowAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, const String& frameName, RefPtr<APIObject>& userData)
    4950{
    5051    if (!m_client.decidePolicyForNewWindowAction)
    51         return;
     52        return WKBundlePagePolicyActionPassThrough;
    5253
    5354    RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
    5455
    5556    WKTypeRef userDataToPass = 0;
    56     m_client.decidePolicyForNewWindowAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.get()), toAPI(frameName.impl()), &userDataToPass, m_client.clientInfo);
     57    WKBundlePagePolicyAction policy = m_client.decidePolicyForNewWindowAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.get()), toAPI(frameName.impl()), &userDataToPass, m_client.clientInfo);
    5758    userData = adoptRef(toImpl(userDataToPass));
     59    return policy;
    5860}
    5961
    60 void InjectedBundlePagePolicyClient::decidePolicyForMIMEType(WebPage* page, WebFrame* frame, const String& MIMEType, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData)
     62WKBundlePagePolicyAction InjectedBundlePagePolicyClient::decidePolicyForMIMEType(WebPage* page, WebFrame* frame, const String& MIMEType, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData)
    6163{
    6264    if (!m_client.decidePolicyForMIMEType)
    63         return;
     65        return WKBundlePagePolicyActionPassThrough;
    6466
    6567    RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
    6668
    6769    WKTypeRef userDataToPass = 0;
    68     m_client.decidePolicyForMIMEType(toAPI(page), toAPI(frame), toAPI(MIMEType.impl()), toAPI(request.get()), &userDataToPass, m_client.clientInfo);
     70    WKBundlePagePolicyAction policy = m_client.decidePolicyForMIMEType(toAPI(page), toAPI(frame), toAPI(MIMEType.impl()), toAPI(request.get()), &userDataToPass, m_client.clientInfo);
    6971    userData = adoptRef(toImpl(userDataToPass));
     72    return policy;
    7073}
    7174
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.h

    r77974 r80275  
    4444class InjectedBundlePagePolicyClient : public APIClient<WKBundlePagePolicyClient> {
    4545public:
    46     void decidePolicyForNavigationAction(WebPage*, WebFrame*, InjectedBundleNavigationAction*, const WebCore::ResourceRequest&, RefPtr<APIObject>& userData);
    47     void decidePolicyForNewWindowAction(WebPage*, WebFrame*, InjectedBundleNavigationAction*, const WebCore::ResourceRequest&, const String& frameName, RefPtr<APIObject>& userData);
    48     void decidePolicyForMIMEType(WebPage*, WebFrame*, const String& MIMEType, const WebCore::ResourceRequest&, RefPtr<APIObject>& userData);
     46    WKBundlePagePolicyAction decidePolicyForNavigationAction(WebPage*, WebFrame*, InjectedBundleNavigationAction*, const WebCore::ResourceRequest&, RefPtr<APIObject>& userData);
     47    WKBundlePagePolicyAction decidePolicyForNewWindowAction(WebPage*, WebFrame*, InjectedBundleNavigationAction*, const WebCore::ResourceRequest&, const String& frameName, RefPtr<APIObject>& userData);
     48    WKBundlePagePolicyAction decidePolicyForMIMEType(WebPage*, WebFrame*, const String& MIMEType, const WebCore::ResourceRequest&, RefPtr<APIObject>& userData);
    4949};
    5050
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r79806 r80275  
    588588
    589589    // Notify the bundle client.
    590     webPage->injectedBundlePolicyClient().decidePolicyForMIMEType(webPage, m_frame, MIMEType, request, userData);
     590    WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForMIMEType(webPage, m_frame, MIMEType, request, userData);
     591    if (policy == WKBundlePagePolicyActionUse) {
     592        (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse);
     593        return;
     594    }
    591595
    592596    uint64_t listenerID = m_frame->setUpPolicyListener(function);
     
    615619
    616620    // Notify the bundle client.
    617     webPage->injectedBundlePolicyClient().decidePolicyForNewWindowAction(webPage, m_frame, action.get(), request, frameName, userData);
     621    WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForNewWindowAction(webPage, m_frame, action.get(), request, frameName, userData);
     622    if (policy == WKBundlePagePolicyActionUse) {
     623        (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse);
     624        return;
     625    }
    618626
    619627
     
    641649
    642650    // Notify the bundle client.
    643     webPage->injectedBundlePolicyClient().decidePolicyForNavigationAction(webPage, m_frame, action.get(), request, userData);
     651    WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForNavigationAction(webPage, m_frame, action.get(), request, userData);
     652    if (policy == WKBundlePagePolicyActionUse) {
     653        (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyUse);
     654        return;
     655    }
    644656
    645657    uint64_t listenerID = m_frame->setUpPolicyListener(function);
Note: See TracChangeset for help on using the changeset viewer.