Changeset 241026 in webkit
- Timestamp:
- Feb 6, 2019 9:58:23 AM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r241013 r241026 1 2019-02-06 Per Arne Vollan <pvollan@apple.com> 2 3 Roll out parts of r238819 since it is a PLT performance regression. 4 https://bugs.webkit.org/show_bug.cgi?id=194346 5 6 Unreviewed performance fix. 7 8 * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm: 9 (didStartProvisionalLoadForFrame): 10 (didReceiveServerRedirectForProvisionalLoadForFrame): 11 (didFinishLoadForFrame): 12 (globalObjectIsAvailableForFrame): 13 (didRemoveFrameFromHierarchy): 14 (didCommitLoadForFrame): 15 (didFinishDocumentLoadForFrame): 16 (didFailProvisionalLoadWithErrorForFrame): 17 (didFailLoadWithErrorForFrame): 18 (didSameDocumentNavigationForFrame): 19 (didLayoutForFrame): 20 (didReachLayoutMilestone): 21 (didFirstVisuallyNonEmptyLayoutForFrame): 22 (didHandleOnloadEventsForFrame): 23 (userAgentForURL): 24 (setUpPageLoaderClient): 25 (willSendRequestForFrame): 26 (didInitiateLoadForResource): 27 (didFinishLoadForResource): 28 (didFailLoadForResource): 29 (setUpResourceLoadClient): 30 (-[WKWebProcessPlugInBrowserContextController setLoadDelegate:]): 31 (ResourceLoadClient::ResourceLoadClient): Deleted. 32 (ResourceLoadClient::loadDelegate const): Deleted. 33 (ResourceLoadClient::pluginContextController const): Deleted. 34 (PageLoaderClient::PageLoaderClient): Deleted. 35 (PageLoaderClient::loadDelegate const): Deleted. 36 (PageLoaderClient::pluginContextController const): Deleted. 37 (PageLoaderClient::didStartProvisionalLoadForFrame): Deleted. 38 (PageLoaderClient::didReceiveServerRedirectForProvisionalLoadForFrame): Deleted. 39 (PageLoaderClient::didFinishLoadForFrame): Deleted. 40 (PageLoaderClient::globalObjectIsAvailableForFrame): Deleted. 41 (PageLoaderClient::didRemoveFrameFromHierarchy): Deleted. 42 (PageLoaderClient::didCommitLoadForFrame): Deleted. 43 (PageLoaderClient::didFinishDocumentLoadForFrame): Deleted. 44 (PageLoaderClient::didFailProvisionalLoadWithErrorForFrame): Deleted. 45 (PageLoaderClient::didFailLoadWithErrorForFrame): Deleted. 46 (PageLoaderClient::didSameDocumentNavigationForFrame): Deleted. 47 (PageLoaderClient::didLayoutForFrame): Deleted. 48 (PageLoaderClient::didReachLayoutMilestone): Deleted. 49 (PageLoaderClient::didFirstVisuallyNonEmptyLayoutForFrame): Deleted. 50 (PageLoaderClient::layoutMilestones const): Deleted. 51 (PageLoaderClient::didHandleOnloadEventsForFrame): Deleted. 52 (PageLoaderClient::userAgentForURL const): Deleted. 53 (ResourceLoadClient::willSendRequestForFrame): Deleted. 54 (ResourceLoadClient::didInitiateLoadForResource): Deleted. 55 (ResourceLoadClient::didFinishLoadForResource): Deleted. 56 (ResourceLoadClient::didFailLoadForResource): Deleted. 57 1 58 2019-02-06 Michael Catanzaro <mcatanzaro@igalia.com> 2 59 -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm
r240808 r241026 30 30 31 31 #import "APIData.h" 32 #import "CompletionHandlerCallChecker.h"33 32 #import "RemoteObjectRegistry.h" 34 33 #import "RemoteObjectRegistryMessages.h" … … 66 65 #import <WebCore/HTMLInputElement.h> 67 66 #import <pal/spi/cocoa/NSKeyedArchiverSPI.h> 68 #import <wtf/BlockPtr.h>69 67 #import <wtf/WeakObjCPtr.h> 70 68 … … 72 70 - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didSameDocumentNavigationForFrame:(WKWebProcessPlugInFrame *)frame; 73 71 @end 74 75 class ResourceLoadClient : public API::InjectedBundle::ResourceLoadClient {76 public:77 explicit ResourceLoadClient(WKWebProcessPlugInBrowserContextController *controller, id <WKWebProcessPlugInLoadDelegate> delegate)78 : m_controller(controller)79 , m_delegate(delegate) { }80 81 void didInitiateLoadForResource(WebKit::WebPage&, WebKit::WebFrame&, uint64_t identifier, const WebCore::ResourceRequest&, bool) override;82 void willSendRequestForFrame(WebKit::WebPage&, WebKit::WebFrame&, uint64_t identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse&) override;83 void didFinishLoadForResource(WebKit::WebPage&, WebKit::WebFrame&, uint64_t identifier) override;84 void didFailLoadForResource(WebKit::WebPage&, WebKit::WebFrame&, uint64_t identifier, const WebCore::ResourceError&) override;85 86 private:87 id <WKWebProcessPlugInLoadDelegate> loadDelegate() const { return m_delegate.get().get(); }88 WKWebProcessPlugInBrowserContextController *pluginContextController() const { return m_controller.get().get(); }89 90 WeakObjCPtr<WKWebProcessPlugInBrowserContextController> m_controller;91 WeakObjCPtr<id <WKWebProcessPlugInLoadDelegate>> m_delegate;92 };93 94 class PageLoaderClient : public API::InjectedBundle::PageLoaderClient {95 public:96 explicit PageLoaderClient(WKWebProcessPlugInBrowserContextController *controller, id <WKWebProcessPlugInLoadDelegate> delegate)97 : m_controller(controller)98 , m_delegate(delegate) { }99 100 void didStartProvisionalLoadForFrame(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) override;101 void didReceiveServerRedirectForProvisionalLoadForFrame(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) override;102 void didFailProvisionalLoadWithErrorForFrame(WebKit::WebPage&, WebKit::WebFrame&, const WebCore::ResourceError&, RefPtr<API::Object>&) override;103 void didCommitLoadForFrame(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) override;104 void didFinishDocumentLoadForFrame(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) override;105 void didFinishLoadForFrame(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) override;106 void didFailLoadWithErrorForFrame(WebKit::WebPage&, WebKit::WebFrame&, const WebCore::ResourceError&, RefPtr<API::Object>&) override;107 void didSameDocumentNavigationForFrame(WebKit::WebPage&, WebKit::WebFrame&, WebKit::SameDocumentNavigationType, RefPtr<API::Object>&) override;108 void didRemoveFrameFromHierarchy(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) override;109 110 void didFirstVisuallyNonEmptyLayoutForFrame(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) override;111 void didLayoutForFrame(WebKit::WebPage&, WebKit::WebFrame&) override;112 void didReachLayoutMilestone(WebKit::WebPage&, OptionSet<WebCore::LayoutMilestone>, RefPtr<API::Object>&) override;113 OptionSet<WebCore::LayoutMilestone> layoutMilestones() const override;114 115 void didHandleOnloadEventsForFrame(WebKit::WebPage&, WebKit::WebFrame&) override;116 117 void globalObjectIsAvailableForFrame(WebKit::WebPage&, WebKit::WebFrame&, WebCore::DOMWrapperWorld&) override;118 119 WTF::String userAgentForURL(WebKit::WebFrame&, const URL&) const override;120 121 private:122 id <WKWebProcessPlugInLoadDelegate> loadDelegate() const { return m_delegate.get().get(); }123 WKWebProcessPlugInBrowserContextController *pluginContextController() const { return m_controller.get().get(); }124 125 WeakObjCPtr<WKWebProcessPlugInBrowserContextController> m_controller;126 WeakObjCPtr<id <WKWebProcessPlugInLoadDelegate>> m_delegate;127 };128 72 129 73 @implementation WKWebProcessPlugInBrowserContextController { … … 136 80 } 137 81 138 void PageLoaderClient::didStartProvisionalLoadForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, RefPtr<API::Object>&) 139 { 140 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didStartProvisionalLoadForFrame:)]) 141 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didStartProvisionalLoadForFrame:wrapper(frame)]; 142 } 143 144 void PageLoaderClient::didReceiveServerRedirectForProvisionalLoadForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, RefPtr<API::Object>&) 145 { 146 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didReceiveServerRedirectForProvisionalLoadForFrame:)]) 147 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didReceiveServerRedirectForProvisionalLoadForFrame:wrapper(frame)]; 148 } 149 150 void PageLoaderClient::didFinishLoadForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, RefPtr<API::Object>&) 151 { 152 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFinishLoadForFrame:)]) 153 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didFinishLoadForFrame:wrapper(frame)]; 154 } 155 156 void PageLoaderClient::globalObjectIsAvailableForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, WebCore::DOMWrapperWorld& scriptWorld) 157 { 158 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:globalObjectIsAvailableForFrame:inScriptWorld:)]) 159 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() globalObjectIsAvailableForFrame:wrapper(frame) inScriptWorld:API::wrapper(WebKit::InjectedBundleScriptWorld::getOrCreate(scriptWorld))]; 160 } 161 162 void PageLoaderClient::didRemoveFrameFromHierarchy(WebKit::WebPage&, WebKit::WebFrame& frame, RefPtr<API::Object>&) 163 { 164 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didRemoveFrameFromHierarchy:)]) 165 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didRemoveFrameFromHierarchy:wrapper(frame)]; 166 } 167 168 void PageLoaderClient::didCommitLoadForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, RefPtr<API::Object>&) 169 { 170 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didCommitLoadForFrame:)]) 171 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didCommitLoadForFrame:wrapper(frame)]; 172 } 173 174 void PageLoaderClient::didFinishDocumentLoadForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, RefPtr<API::Object>&) 175 { 176 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFinishDocumentLoadForFrame:)]) 177 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didFinishDocumentLoadForFrame:wrapper(frame)]; 178 } 179 180 void PageLoaderClient::didFailProvisionalLoadWithErrorForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, const WebCore::ResourceError& error, RefPtr<API::Object>&) 181 { 182 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFailProvisionalLoadWithErrorForFrame:error:)]) 183 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didFailProvisionalLoadWithErrorForFrame:wrapper(frame) error:error]; 184 } 185 186 void PageLoaderClient::didFailLoadWithErrorForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, const WebCore::ResourceError& error, RefPtr<API::Object>&) 187 { 188 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFailLoadWithErrorForFrame:error:)]) 189 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didFailLoadWithErrorForFrame:wrapper(frame) error:error]; 190 } 191 192 void PageLoaderClient::didSameDocumentNavigationForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, WebKit::SameDocumentNavigationType type, RefPtr<API::Object>&) 193 { 194 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didSameDocumentNavigation:forFrame:)]) 195 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didSameDocumentNavigation:toWKSameDocumentNavigationType(type) forFrame:wrapper(frame)]; 82 static void didStartProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userDataRef, const void *clientInfo) 83 { 84 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 85 auto loadDelegate = pluginContextController->_loadDelegate.get(); 86 87 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didStartProvisionalLoadForFrame:)]) 88 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didStartProvisionalLoadForFrame:wrapper(*WebKit::toImpl(frame))]; 89 } 90 91 static void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef *userDataRef, const void *clientInfo) 92 { 93 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 94 auto loadDelegate = pluginContextController->_loadDelegate.get(); 95 96 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didReceiveServerRedirectForProvisionalLoadForFrame:)]) 97 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didReceiveServerRedirectForProvisionalLoadForFrame:wrapper(*WebKit::toImpl(frame))]; 98 } 99 100 static void didFinishLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo) 101 { 102 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 103 auto loadDelegate = pluginContextController->_loadDelegate.get(); 104 105 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFinishLoadForFrame:)]) 106 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didFinishLoadForFrame:wrapper(*WebKit::toImpl(frame))]; 107 } 108 109 static void globalObjectIsAvailableForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleScriptWorldRef scriptWorld, const void* clientInfo) 110 { 111 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 112 auto loadDelegate = pluginContextController->_loadDelegate.get(); 113 114 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:globalObjectIsAvailableForFrame:inScriptWorld:)]) 115 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController globalObjectIsAvailableForFrame:wrapper(*WebKit::toImpl(frame)) inScriptWorld:wrapper(*WebKit::toImpl(scriptWorld))]; 116 } 117 118 static void didRemoveFrameFromHierarchy(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void* clientInfo) 119 { 120 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 121 auto loadDelegate = pluginContextController->_loadDelegate.get(); 122 123 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didRemoveFrameFromHierarchy:)]) 124 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didRemoveFrameFromHierarchy:wrapper(*WebKit::toImpl(frame))]; 125 } 126 127 static void didCommitLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo) 128 { 129 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 130 auto loadDelegate = pluginContextController->_loadDelegate.get(); 131 132 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didCommitLoadForFrame:)]) 133 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didCommitLoadForFrame:wrapper(*WebKit::toImpl(frame))]; 134 } 135 136 static void didFinishDocumentLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo) 137 { 138 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 139 auto loadDelegate = pluginContextController->_loadDelegate.get(); 140 141 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFinishDocumentLoadForFrame:)]) 142 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didFinishDocumentLoadForFrame:wrapper(*WebKit::toImpl(frame))]; 143 } 144 145 static void didFailProvisionalLoadWithErrorForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef wkError, WKTypeRef* userData, const void *clientInfo) 146 { 147 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 148 auto loadDelegate = pluginContextController->_loadDelegate.get(); 149 150 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFailProvisionalLoadWithErrorForFrame:error:)]) 151 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didFailProvisionalLoadWithErrorForFrame:wrapper(*WebKit::toImpl(frame)) error:wrapper(*WebKit::toImpl(wkError))]; 152 } 153 154 static void didFailLoadWithErrorForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef wkError, WKTypeRef* userData, const void *clientInfo) 155 { 156 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 157 auto loadDelegate = pluginContextController->_loadDelegate.get(); 158 159 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFailLoadWithErrorForFrame:error:)]) 160 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didFailLoadWithErrorForFrame:wrapper(*WebKit::toImpl(frame)) error:wrapper(*WebKit::toImpl(wkError))]; 161 } 162 163 static void didSameDocumentNavigationForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef* userData, const void *clientInfo) 164 { 165 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 166 auto loadDelegate = pluginContextController->_loadDelegate.get(); 167 168 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didSameDocumentNavigation:forFrame:)]) 169 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didSameDocumentNavigation:toWKSameDocumentNavigationType(WebKit::toSameDocumentNavigationType(type)) forFrame:wrapper(*WebKit::toImpl(frame))]; 196 170 else { 197 171 // FIXME: Remove this once clients switch to implementing the above delegate method. 198 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didSameDocumentNavigationForFrame:)]) 199 [(NSObject *)loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didSameDocumentNavigationForFrame:wrapper(frame)]; 200 } 201 } 202 203 void PageLoaderClient::didLayoutForFrame(WebKit::WebPage&, WebKit::WebFrame& frame) 204 { 205 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didLayoutForFrame:)]) 206 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didLayoutForFrame:wrapper(frame)]; 207 } 208 209 void PageLoaderClient::didReachLayoutMilestone(WebKit::WebPage&, OptionSet<WebCore::LayoutMilestone> milestones, RefPtr<API::Object>&) 210 { 211 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:renderingProgressDidChange:)]) 212 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() renderingProgressDidChange:renderingProgressEvents(milestones)]; 213 } 214 215 void PageLoaderClient::didFirstVisuallyNonEmptyLayoutForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, RefPtr<API::Object>&) 216 { 217 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFirstVisuallyNonEmptyLayoutForFrame:)]) 218 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didFirstVisuallyNonEmptyLayoutForFrame:wrapper(frame)]; 219 } 220 221 OptionSet<WebCore::LayoutMilestone> PageLoaderClient::layoutMilestones() const 222 { 223 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextControllerRenderingProgressEvents:)]) { 224 _WKRenderingProgressEvents milestones = [loadDelegate() webProcessPlugInBrowserContextControllerRenderingProgressEvents:pluginContextController()]; 225 return WebKit::toLayoutMilestones(static_cast<WKLayoutMilestones>(milestones)); 226 } 227 228 return { }; 229 } 230 231 void PageLoaderClient::didHandleOnloadEventsForFrame(WebKit::WebPage&, WebKit::WebFrame& frame) 232 { 233 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didHandleOnloadEventsForFrame:)]) 234 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didHandleOnloadEventsForFrame:wrapper(frame)]; 235 } 236 237 WTF::String PageLoaderClient::userAgentForURL(WebKit::WebFrame& frame, const URL& url) const 238 { 239 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:userAgentForURL:)]) 240 return [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() frame:wrapper(frame) userAgentForURL:url]; 241 return { }; 242 } 243 244 void ResourceLoadClient::willSendRequestForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, uint64_t resourceIdentifier, WebCore::ResourceRequest& request, const WebCore::ResourceResponse& redirectResponse) 245 { 246 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:willSendRequestForResource:request:redirectResponse:)]) { 247 RetainPtr<NSURLRequest> originalRequest = request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody); 248 RetainPtr<NSURLRequest> substituteRequest = [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() frame:wrapper(frame) willSendRequestForResource:resourceIdentifier 249 request:originalRequest.get() redirectResponse:redirectResponse.nsURLResponse()]; 250 251 if (substituteRequest != originalRequest) { 252 request = substituteRequest.get(); 253 return; 254 } 255 } else if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:willSendRequest:redirectResponse:)]) { 256 RetainPtr<NSURLRequest> originalRequest = request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody); 257 RetainPtr<NSURLRequest> substituteRequest = [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() frame:wrapper(frame) willSendRequest:originalRequest.get() 258 redirectResponse:redirectResponse.nsURLResponse()]; 259 260 if (substituteRequest != originalRequest) { 261 request = substituteRequest.get(); 262 return; 263 } 264 } 265 } 266 267 void ResourceLoadClient::didInitiateLoadForResource(WebKit::WebPage&, WebKit::WebFrame& frame, uint64_t resourceIdentifier, const WebCore::ResourceRequest& request, bool pageIsProvisionallyLoading) 268 { 269 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didInitiateLoadForResource:request:pageIsProvisionallyLoading:)]) { 270 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() frame:wrapper(frame) didInitiateLoadForResource:resourceIdentifier request:request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody) 172 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didSameDocumentNavigationForFrame:)]) 173 [(NSObject *)loadDelegate webProcessPlugInBrowserContextController:pluginContextController didSameDocumentNavigationForFrame:wrapper(*WebKit::toImpl(frame))]; 174 } 175 } 176 177 static void didLayoutForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void* clientInfo) 178 { 179 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 180 auto loadDelegate = pluginContextController->_loadDelegate.get(); 181 182 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didLayoutForFrame:)]) 183 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didLayoutForFrame:wrapper(*WebKit::toImpl(frame))]; 184 } 185 186 static void didReachLayoutMilestone(WKBundlePageRef page, WKLayoutMilestones milestones, WKTypeRef* userData, const void *clientInfo) 187 { 188 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 189 auto loadDelegate = pluginContextController->_loadDelegate.get(); 190 191 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:renderingProgressDidChange:)]) 192 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController renderingProgressDidChange:renderingProgressEvents(WebKit::toLayoutMilestones(milestones))]; 193 } 194 195 static void didFirstVisuallyNonEmptyLayoutForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo) 196 { 197 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 198 auto loadDelegate = pluginContextController->_loadDelegate.get(); 199 200 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFirstVisuallyNonEmptyLayoutForFrame:)]) 201 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didFirstVisuallyNonEmptyLayoutForFrame:wrapper(*WebKit::toImpl(frame))]; 202 } 203 204 static void didHandleOnloadEventsForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void* clientInfo) 205 { 206 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 207 auto loadDelegate = pluginContextController->_loadDelegate.get(); 208 209 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didHandleOnloadEventsForFrame:)]) 210 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didHandleOnloadEventsForFrame:wrapper(*WebKit::toImpl(frame))]; 211 } 212 213 static WKStringRef userAgentForURL(WKBundleFrameRef frame, WKURLRef url, const void* clientInfo) 214 { 215 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 216 auto loadDelegate = pluginContextController->_loadDelegate.get(); 217 218 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:userAgentForURL:)]) { 219 WKWebProcessPlugInFrame *newFrame = wrapper(*WebKit::toImpl(frame)); 220 NSString *string = [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:newFrame userAgentForURL:wrapper(*WebKit::toImpl(url))]; 221 if (!string) 222 return nullptr; 223 224 return WKStringCreateWithCFString((__bridge CFStringRef)string); 225 } 226 227 return nullptr; 228 } 229 230 static void setUpPageLoaderClient(WKWebProcessPlugInBrowserContextController *contextController, WebKit::WebPage& page) 231 { 232 WKBundlePageLoaderClientV9 client; 233 memset(&client, 0, sizeof(client)); 234 235 client.base.version = 8; 236 client.base.clientInfo = (__bridge void*)contextController; 237 client.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame; 238 client.didReceiveServerRedirectForProvisionalLoadForFrame = didReceiveServerRedirectForProvisionalLoadForFrame; 239 client.didCommitLoadForFrame = didCommitLoadForFrame; 240 client.didFinishDocumentLoadForFrame = didFinishDocumentLoadForFrame; 241 client.didFailProvisionalLoadWithErrorForFrame = didFailProvisionalLoadWithErrorForFrame; 242 client.didFailLoadWithErrorForFrame = didFailLoadWithErrorForFrame; 243 client.didSameDocumentNavigationForFrame = didSameDocumentNavigationForFrame; 244 client.didFinishLoadForFrame = didFinishLoadForFrame; 245 client.globalObjectIsAvailableForFrame = globalObjectIsAvailableForFrame; 246 client.didRemoveFrameFromHierarchy = didRemoveFrameFromHierarchy; 247 client.didHandleOnloadEventsForFrame = didHandleOnloadEventsForFrame; 248 client.didFirstVisuallyNonEmptyLayoutForFrame = didFirstVisuallyNonEmptyLayoutForFrame; 249 client.userAgentForURL = userAgentForURL; 250 251 client.didLayoutForFrame = didLayoutForFrame; 252 client.didLayout = didReachLayoutMilestone; 253 254 WKBundlePageSetPageLoaderClient(toAPI(&page), &client.base); 255 } 256 257 static WKURLRequestRef willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, WKURLResponseRef redirectResponse, const void* clientInfo) 258 { 259 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 260 auto loadDelegate = pluginContextController->_loadDelegate.get(); 261 262 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:willSendRequestForResource:request:redirectResponse:)]) { 263 NSURLRequest *originalRequest = wrapper(*WebKit::toImpl(request)); 264 RetainPtr<NSURLRequest> substituteRequest = [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:wrapper(*WebKit::toImpl(frame)) willSendRequestForResource:resourceIdentifier 265 request:originalRequest redirectResponse:WebKit::toImpl(redirectResponse)->resourceResponse().nsURLResponse()]; 266 267 if (substituteRequest != originalRequest) 268 return substituteRequest ? WKURLRequestCreateWithNSURLRequest(substituteRequest.get()) : nullptr; 269 } else if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:willSendRequest:redirectResponse:)]) { 270 NSURLRequest *originalRequest = wrapper(*WebKit::toImpl(request)); 271 RetainPtr<NSURLRequest> substituteRequest = [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:wrapper(*WebKit::toImpl(frame)) willSendRequest:originalRequest 272 redirectResponse:WebKit::toImpl(redirectResponse)->resourceResponse().nsURLResponse()]; 273 274 if (substituteRequest != originalRequest) 275 return substituteRequest ? WKURLRequestCreateWithNSURLRequest(substituteRequest.get()) : nullptr; 276 } 277 278 WKRetain(request); 279 return request; 280 } 281 282 static void didInitiateLoadForResource(WKBundlePageRef, WKBundleFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, bool pageIsProvisionallyLoading, const void* clientInfo) 283 { 284 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 285 auto loadDelegate = pluginContextController->_loadDelegate.get(); 286 287 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didInitiateLoadForResource:request:pageIsProvisionallyLoading:)]) { 288 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:wrapper(*WebKit::toImpl(frame)) didInitiateLoadForResource:resourceIdentifier request:wrapper(*WebKit::toImpl(request)) 271 289 pageIsProvisionallyLoading:pageIsProvisionallyLoading]; 272 } else if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didInitiateLoadForResource:request:)]) { 273 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() frame:wrapper(frame) didInitiateLoadForResource:resourceIdentifier request:request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody)]; 274 } 275 } 276 277 void ResourceLoadClient::didFinishLoadForResource(WebKit::WebPage&, WebKit::WebFrame& frame, uint64_t resourceIdentifier) 278 { 279 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didFinishLoadForResource:)]) { 280 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() frame:wrapper(frame) didFinishLoadForResource:resourceIdentifier]; 281 } 282 } 283 284 void ResourceLoadClient::didFailLoadForResource(WebKit::WebPage&, WebKit::WebFrame& frame, uint64_t resourceIdentifier, const WebCore::ResourceError& error) 285 { 286 if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didFailLoadForResource:error:)]) { 287 [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() frame:wrapper(frame) didFailLoadForResource:resourceIdentifier error:error]; 288 } 290 } else if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didInitiateLoadForResource:request:)]) { 291 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:wrapper(*WebKit::toImpl(frame)) didInitiateLoadForResource:resourceIdentifier request:wrapper(*WebKit::toImpl(request))]; 292 } 293 } 294 295 static void didFinishLoadForResource(WKBundlePageRef, WKBundleFrameRef frame, uint64_t resourceIdentifier, const void* clientInfo) 296 { 297 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 298 auto loadDelegate = pluginContextController->_loadDelegate.get(); 299 300 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didFinishLoadForResource:)]) { 301 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:wrapper(*WebKit::toImpl(frame)) didFinishLoadForResource:resourceIdentifier]; 302 } 303 } 304 305 static void didFailLoadForResource(WKBundlePageRef, WKBundleFrameRef frame, uint64_t resourceIdentifier, WKErrorRef error, const void* clientInfo) 306 { 307 auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; 308 auto loadDelegate = pluginContextController->_loadDelegate.get(); 309 310 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didFailLoadForResource:error:)]) { 311 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:wrapper(*WebKit::toImpl(frame)) didFailLoadForResource:resourceIdentifier error:wrapper(*WebKit::toImpl(error))]; 312 } 313 } 314 315 static void setUpResourceLoadClient(WKWebProcessPlugInBrowserContextController *contextController, WebKit::WebPage& page) 316 { 317 WKBundlePageResourceLoadClientV1 client; 318 memset(&client, 0, sizeof(client)); 319 320 client.base.version = 1; 321 client.base.clientInfo = (__bridge void*) contextController; 322 client.willSendRequestForFrame = willSendRequestForFrame; 323 client.didInitiateLoadForResource = didInitiateLoadForResource; 324 client.didFinishLoadForResource = didFinishLoadForResource; 325 client.didFailLoadForResource = didFailLoadForResource; 326 327 WKBundlePageSetResourceLoadClient(toAPI(&page), &client.base); 289 328 } 290 329 … … 299 338 300 339 if (loadDelegate) { 301 _page->setInjectedBundlePageLoaderClient(std::make_unique<PageLoaderClient>(self, loadDelegate));302 _page->setInjectedBundleResourceLoadClient(std::make_unique<ResourceLoadClient>(self, loadDelegate));340 setUpPageLoaderClient(self, *_page); 341 setUpResourceLoadClient(self, *_page); 303 342 } else { 304 _page->setInjectedBundlePageLoaderClient(nullptr);305 _page->setInjectedBundleResourceLoadClient(nullptr);343 WKBundlePageSetPageLoaderClient(toAPI(_page.get()), nullptr); 344 WKBundlePageSetResourceLoadClient(toAPI(_page.get()), nullptr); 306 345 } 307 346 }
Note: See TracChangeset
for help on using the changeset viewer.