Changeset 80275 in webkit
- Timestamp:
- Mar 3, 2011 1:06:05 PM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r80263 r80275 1 2011-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 1 25 2011-03-02 Brian Weinstein <bweinstein@apple.com> 2 26 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
r78418 r80275 115 115 typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient; 116 116 117 enum { 118 WKBundlePagePolicyActionPassThrough, 119 WKBundlePagePolicyActionUse 120 }; 121 typedef uint32_t WKBundlePagePolicyAction; 122 123 117 124 // 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);125 typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForNavigationActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo); 126 typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForNewWindowActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKStringRef frameName, WKTypeRef* userData, const void* clientInfo); 127 typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForMIMETypeCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKStringRef MIMEType, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo); 121 128 122 129 struct WKBundlePagePolicyClient { -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp
r77974 r80275 34 34 namespace WebKit { 35 35 36 voidInjectedBundlePagePolicyClient::decidePolicyForNavigationAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData)36 WKBundlePagePolicyAction InjectedBundlePagePolicyClient::decidePolicyForNavigationAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData) 37 37 { 38 38 if (!m_client.decidePolicyForNavigationAction) 39 return ;39 return WKBundlePagePolicyActionPassThrough; 40 40 41 41 RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest); 42 42 43 43 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); 45 45 userData = adoptRef(toImpl(userDataToPass)); 46 return policy; 46 47 } 47 48 48 voidInjectedBundlePagePolicyClient::decidePolicyForNewWindowAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, const String& frameName, RefPtr<APIObject>& userData)49 WKBundlePagePolicyAction InjectedBundlePagePolicyClient::decidePolicyForNewWindowAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, const String& frameName, RefPtr<APIObject>& userData) 49 50 { 50 51 if (!m_client.decidePolicyForNewWindowAction) 51 return ;52 return WKBundlePagePolicyActionPassThrough; 52 53 53 54 RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest); 54 55 55 56 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); 57 58 userData = adoptRef(toImpl(userDataToPass)); 59 return policy; 58 60 } 59 61 60 voidInjectedBundlePagePolicyClient::decidePolicyForMIMEType(WebPage* page, WebFrame* frame, const String& MIMEType, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData)62 WKBundlePagePolicyAction InjectedBundlePagePolicyClient::decidePolicyForMIMEType(WebPage* page, WebFrame* frame, const String& MIMEType, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData) 61 63 { 62 64 if (!m_client.decidePolicyForMIMEType) 63 return ;65 return WKBundlePagePolicyActionPassThrough; 64 66 65 67 RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest); 66 68 67 69 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); 69 71 userData = adoptRef(toImpl(userDataToPass)); 72 return policy; 70 73 } 71 74 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.h
r77974 r80275 44 44 class InjectedBundlePagePolicyClient : public APIClient<WKBundlePagePolicyClient> { 45 45 public: 46 voiddecidePolicyForNavigationAction(WebPage*, WebFrame*, InjectedBundleNavigationAction*, const WebCore::ResourceRequest&, RefPtr<APIObject>& userData);47 voiddecidePolicyForNewWindowAction(WebPage*, WebFrame*, InjectedBundleNavigationAction*, const WebCore::ResourceRequest&, const String& frameName, RefPtr<APIObject>& userData);48 voiddecidePolicyForMIMEType(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); 49 49 }; 50 50 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r79806 r80275 588 588 589 589 // 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 } 591 595 592 596 uint64_t listenerID = m_frame->setUpPolicyListener(function); … … 615 619 616 620 // 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 } 618 626 619 627 … … 641 649 642 650 // 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 } 644 656 645 657 uint64_t listenerID = m_frame->setUpPolicyListener(function);
Note: See TracChangeset
for help on using the changeset viewer.