Changeset 160809 in webkit
- Timestamp:
- Dec 18, 2013, 4:52:47 PM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h (modified) (1 diff)
-
WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r160803 r160809 1 2013-12-18 Dan Bernstein <mitz@apple.com> 2 3 [Cocoa] Allow the web process plug-in to intercept resource requests 4 https://bugs.webkit.org/show_bug.cgi?id=125959 5 6 Reviewed by Anders Carlsson. 7 8 * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h: Declared new 9 delegate method. 10 * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm: 11 (willSendRequestForFrame): Implemented this WKBundlePageResourceClient callback by calling 12 the load delegate. 13 (setUpResourceLoadClient): Added. Initializes the resource load client with the above 14 function. 15 (-[WKWebProcessPlugInBrowserContextController setLoadDelegate:]): Added calls to initialize 16 and clear the resource load client. 17 1 18 2013-12-18 Yongjun Zhang <yongjun_zhang@apple.com> 2 19 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h
r160616 r160809 31 31 @protocol WKWebProcessPlugInLoadDelegate <NSObject> 32 32 @optional 33 34 // Frame loading 35 33 36 - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller didStartProvisionalLoadForFrame:(WKWebProcessPlugInFrame *)frame; 34 37 - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller didFinishLoadForFrame:(WKWebProcessPlugInFrame *)frame; 35 38 - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller globalObjectIsAvailableForFrame:(WKWebProcessPlugInFrame *)frame inScriptWorld:(WKWebProcessPlugInScriptWorld *)scriptWorld; 39 40 // Resource loading 41 42 - (NSURLRequest *)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller frame:(WKWebProcessPlugInFrame *)frame willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse; 43 36 44 @end -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm
r160803 r160809 38 38 #import "WKRemoteObjectRegistryInternal.h" 39 39 #import "WKRetainPtr.h" 40 #import "WKURLRequestNS.h" 40 41 #import "WKWebProcessPluginFrameInternal.h" 41 42 #import "WKWebProcessPlugInInternal.h" … … 100 101 } 101 102 103 static WKURLRequestRef willSendRequestForFrame(WKBundlePageRef page, WKBundleFrameRef frame, uint64_t, WKURLRequestRef request, WKURLResponseRef redirectResponse, const void* clientInfo) 104 { 105 WKWebProcessPlugInBrowserContextController *pluginContextController = (WKWebProcessPlugInBrowserContextController *)clientInfo; 106 auto loadDelegate = pluginContextController->_loadDelegate.get(); 107 108 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:willSendRequest:redirectResponse:)]) { 109 NSURLRequest *originalRequest = toImpl(request)->resourceRequest().nsURLRequest(DoNotUpdateHTTPBody); 110 RetainPtr<NSURLRequest> substituteRequest = [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:wrapper(*toImpl(frame)) willSendRequest:originalRequest 111 redirectResponse:toImpl(redirectResponse)->resourceResponse().nsURLResponse()]; 112 113 if (substituteRequest != originalRequest) 114 return substituteRequest ? WKURLRequestCreateWithNSURLRequest(substituteRequest.get()) : nullptr; 115 } 116 117 WKRetain(request); 118 return request; 119 } 120 121 static void setUpResourceLoadClient(WKWebProcessPlugInBrowserContextController *contextController, WebPage& page) 122 { 123 WKBundlePageResourceLoadClientV1 client; 124 memset(&client, 0, sizeof(client)); 125 126 client.base.version = 1; 127 client.base.clientInfo = contextController; 128 client.willSendRequestForFrame = willSendRequestForFrame; 129 130 page.initializeInjectedBundleResourceLoadClient(&client.base); 131 } 132 102 133 - (id <WKWebProcessPlugInLoadDelegate>)loadDelegate 103 134 { … … 109 140 _loadDelegate = loadDelegate; 110 141 111 if (loadDelegate) 142 if (loadDelegate) { 112 143 setUpPageLoaderClient(self, *_page); 113 else 144 setUpResourceLoadClient(self, *_page); 145 } else { 114 146 _page->initializeInjectedBundleLoaderClient(nullptr); 147 _page->initializeInjectedBundleResourceLoadClient(nullptr); 148 } 115 149 } 116 150
Note:
See TracChangeset
for help on using the changeset viewer.