Changeset 170330 in webkit
- Timestamp:
- Jun 23, 2014 4:15:10 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r170329 r170330 1 2014-06-23 Grant Kennell <gkennell@apple.com> 2 3 Add SPI for Injected Bundle to provide user agent for a given URL. 4 https://bugs.webkit.org/show_bug.cgi?id=133562 5 6 Reviewed by Sam Weinig. 7 8 * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h: 9 Added delegate method to WebProcess PluIn protocol to provide UserAgent per URL. 10 * WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h: 11 Added new typedef for function pointer for this new delegate call. 12 Added new version (V8) of bundle loader client struct containing 13 a function pointer of that new type. 14 * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm: 15 (userAgentForURL): Makes delegate call with the new method. 16 (setUpPageLoaderClient): Sets the struct's new function pointer to the new method. 17 * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp: 18 (WebKit::InjectedBundlePageLoaderClient::userAgentForURL): 19 * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h: 20 * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: 21 (WebKit::WebFrameLoaderClient::userAgent): 22 * WebProcess/WebPage/WebPage.cpp: 23 (WebKit::WebPage::userAgent): Began using the new API to ask for user agent 24 instead of simply returning what had been stored. 25 * WebProcess/WebPage/WebPage.h: 26 (WebKit::WebPage::userAgent): Deleted. 27 1 28 2014-06-23 Commit Queue <commit-queue@webkit.org> 2 29 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h
r168541 r170330 58 58 - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller frame:(WKWebProcessPlugInFrame *)frame didFailLoadForResource:(uint64_t)resource error:(NSError *)error; 59 59 60 - (NSString *)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller frame:(WKWebProcessPlugInFrame *)frame userAgentForURL:(NSURL *)url; 61 60 62 @end -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h
r168541 r170330 63 63 typedef void (*WKBundlePageWillLoadDataRequestCallback)(WKBundlePageRef page, WKURLRequestRef request, WKDataRef data, WKStringRef MIMEType, WKStringRef encodingName, WKURLRef unreachableURL, WKTypeRef userData, const void *clientInfo); 64 64 typedef void (*WKBundlePageWillDestroyFrame)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo); 65 typedef WKStringRef (*WKBundlePageUserAgentForURLCallback)(WKBundleFrameRef frame, WKURLRef url, const void *clientInfo); 65 66 66 67 typedef struct WKBundlePageLoaderClientBase { … … 407 408 } WKBundlePageLoaderClientV7; 408 409 409 enum { kWKBundlePageLoaderClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 7 }; 410 typedef struct WKBundlePageLoaderClientV8 { 411 WKBundlePageLoaderClientBase base; 412 413 // Version 0. 414 WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame; 415 WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame; 416 WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame; 417 WKBundlePageDidCommitLoadForFrameCallback didCommitLoadForFrame; 418 WKBundlePageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame; 419 WKBundlePageDidFinishLoadForFrameCallback didFinishLoadForFrame; 420 WKBundlePageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame; 421 WKBundlePageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame; 422 WKBundlePageDidReceiveTitleForFrameCallback didReceiveTitleForFrame; 423 WKBundlePageDidFirstLayoutForFrameCallback didFirstLayoutForFrame; 424 WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame; 425 WKBundlePageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy; 426 WKBundlePageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame; 427 WKBundlePageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame; 428 WKBundlePageDidClearWindowObjectForFrameCallback didClearWindowObjectForFrame; 429 WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame; 430 WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame; 431 WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame; 432 433 // Version 1. 434 WKBundlePageDidLayoutForFrameCallback didLayoutForFrame; 435 void * didNewFirstVisuallyNonEmptyLayout_unavailable; 436 WKBundlePageDidDetectXSSForFrameCallback didDetectXSSForFrame; 437 WKBundlePageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem; 438 WKBundlePageGlobalObjectIsAvailableForFrameCallback globalObjectIsAvailableForFrame; 439 WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback willDisconnectDOMWindowExtensionFromGlobalObject; 440 WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback didReconnectDOMWindowExtensionToGlobalObject; 441 WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback willDestroyGlobalObjectForDOMWindowExtension; 442 443 // Version 2 444 WKBundlePageDidFinishProgressCallback didFinishProgress; 445 WKBundlePageShouldForceUniversalAccessFromLocalURLCallback shouldForceUniversalAccessFromLocalURL; 446 447 // Version 3 448 void * didReceiveIntentForFrame_unavailable; 449 void * registerIntentServiceForFrame_unavailable; 450 451 // Version 4 452 WKBundlePageDidLayoutCallback didLayout; 453 454 // Version 5 455 WKBundlePageFeaturesUsedInPageCallback featuresUsedInPage; 456 457 // Version 6 458 WKBundlePageWillLoadURLRequestCallback willLoadURLRequest; 459 WKBundlePageWillLoadDataRequestCallback willLoadDataRequest; 460 461 // Version 7 462 WKBundlePageWillDestroyFrame willDestroyFrame; 463 464 // Version 8 465 WKBundlePageUserAgentForURLCallback userAgentForURL; 466 } WKBundlePageLoaderClientV8; 467 468 enum { kWKBundlePageLoaderClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 8 }; 410 469 typedef struct WKBundlePageLoaderClient { 411 470 int version; -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm
r169807 r170330 39 39 #import "WKNSDictionary.h" 40 40 #import "WKNSError.h" 41 #import "WKNSString.h" 42 #import "WKNSURL.h" 41 43 #import "WKNSURLRequest.h" 42 44 #import "WKRenderingProgressEventsInternal.h" 43 45 #import "WKRetainPtr.h" 46 #import "WKStringCF.h" 44 47 #import "WKURLRequestNS.h" 45 48 #import "WKWebProcessPluginFrameInternal.h" … … 177 180 [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didHandleOnloadEventsForFrame:wrapper(*toImpl(frame))]; 178 181 } 182 183 static WKStringRef userAgentForURL(WKBundleFrameRef frame, WKURLRef url, const void* clientInfo) 184 { 185 WKWebProcessPlugInBrowserContextController *pluginContextController = (WKWebProcessPlugInBrowserContextController *)clientInfo; 186 auto loadDelegate = pluginContextController->_loadDelegate.get(); 187 188 if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:userAgentForURL:)]) { 189 WKWebProcessPlugInFrame *newFrame = wrapper(*toImpl(frame)); 190 NSString *string = [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:newFrame userAgentForURL:wrapper(*toImpl(url))]; 191 if (!string) 192 return nullptr; 193 194 WKStringRef wkString = WKStringCreateWithCFString((CFStringRef)string); 195 return wkString; 196 } 197 198 return nullptr; 199 } 200 179 201 static void setUpPageLoaderClient(WKWebProcessPlugInBrowserContextController *contextController, WebPage& page) 180 202 { 181 WKBundlePageLoaderClientV 7client;203 WKBundlePageLoaderClientV8 client; 182 204 memset(&client, 0, sizeof(client)); 183 205 184 client.base.version = 7;206 client.base.version = 8; 185 207 client.base.clientInfo = contextController; 186 208 client.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame; … … 194 216 client.didHandleOnloadEventsForFrame = didHandleOnloadEventsForFrame; 195 217 client.didFirstVisuallyNonEmptyLayoutForFrame = didFirstVisuallyNonEmptyLayoutForFrame; 218 client.userAgentForURL = userAgentForURL; 196 219 197 220 client.didLayoutForFrame = didLayoutForFrame; -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp
r160971 r170330 30 30 #include "APIData.h" 31 31 #include "APIError.h" 32 #include "APIURL.h" 32 33 #include "APIURLRequest.h" 33 34 #include "InjectedBundleDOMWindowExtension.h" … … 35 36 #include "WKAPICast.h" 36 37 #include "WKBundleAPICast.h" 38 #include "WKSharedAPICast.h" 37 39 #include <WebCore/SharedBuffer.h> 38 40 #include <wtf/text/WTFString.h> … … 352 354 m_client.willDestroyFrame(toAPI(page), toAPI(frame), m_client.base.clientInfo); 353 355 } 354 356 357 API::String* InjectedBundlePageLoaderClient::userAgentForURL(WebFrame* frame, API::URL* url) const 358 { 359 if (!m_client.userAgentForURL) 360 return nullptr; 361 WKStringRef userAgent = m_client.userAgentForURL(toAPI(frame), toAPI(url), m_client.base.clientInfo); 362 return toImpl(userAgent); 363 } 364 355 365 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h
r160653 r170330 28 28 29 29 #include "APIClient.h" 30 #include "APIString.h" 31 #include "APIURL.h" 30 32 #include "SameDocumentNavigationType.h" 31 33 #include "WKBundlePage.h" … … 39 41 40 42 template<> struct ClientTraits<WKBundlePageLoaderClientBase> { 41 typedef std::tuple<WKBundlePageLoaderClientV0, WKBundlePageLoaderClientV1, WKBundlePageLoaderClientV2, WKBundlePageLoaderClientV3, WKBundlePageLoaderClientV4, WKBundlePageLoaderClientV5, WKBundlePageLoaderClientV6, WKBundlePageLoaderClientV7 > Versions;43 typedef std::tuple<WKBundlePageLoaderClientV0, WKBundlePageLoaderClientV1, WKBundlePageLoaderClientV2, WKBundlePageLoaderClientV3, WKBundlePageLoaderClientV4, WKBundlePageLoaderClientV5, WKBundlePageLoaderClientV6, WKBundlePageLoaderClientV7, WKBundlePageLoaderClientV8> Versions; 42 44 }; 43 45 } … … 100 102 101 103 void willDestroyFrame(WebPage*, WebFrame*); 104 API::String* userAgentForURL(WebFrame*, API::URL*) const; 102 105 }; 103 106 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r170163 r170330 37 37 #include "NavigationActionData.h" 38 38 #include "PluginView.h" 39 #include "WKBundleAPICast.h" 39 40 #include "WebBackForwardListProxy.h" 40 41 #include "WebContextMessages.h" … … 1188 1189 return String(); 1189 1190 1190 return webPage->userAgent( url);1191 return webPage->userAgent(m_frame, url); 1191 1192 } 1192 1193 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r170325 r170330 56 56 #include "TelephoneNumberOverlayController.h" 57 57 #include "VisitedLinkTableController.h" 58 #include "WKBundleAPICast.h" 59 #include "WKRetainPtr.h" 58 60 #include "WKSharedAPICast.h" 61 #include "WKStringCF.h" 59 62 #include "WebAlternativeTextClient.h" 60 63 #include "WebBackForwardListItem.h" … … 2272 2275 } 2273 2276 2274 void WebPage::setUserAgent(const String& userAgent) 2275 { 2276 m_userAgent = userAgent; 2277 } 2278 2279 String WebPage::userAgent(const URL& url) const 2280 { 2281 String userAgent = platformUserAgent(url); 2277 String WebPage::userAgent(const URL& webCoreURL) const 2278 { 2279 return userAgent(nullptr, webCoreURL); 2280 } 2281 2282 String WebPage::userAgent(WebFrame* frame, const URL& webcoreURL) const 2283 { 2284 if (frame && m_loaderClient.client().userAgentForURL) { 2285 RefPtr<API::URL> url = API::URL::create(webcoreURL); 2286 2287 API::String* apiString = m_loaderClient.userAgentForURL(frame, url.get()); 2288 if (apiString) 2289 return apiString->string(); 2290 } 2291 2292 String userAgent = platformUserAgent(webcoreURL); 2282 2293 if (!userAgent.isEmpty()) 2283 2294 return userAgent; 2284 2285 2295 return m_userAgent; 2296 } 2297 2298 void WebPage::setUserAgent(const String& userAgent) 2299 { 2300 m_userAgent = userAgent; 2286 2301 } 2287 2302 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r170325 r170330 256 256 void show(); 257 257 String userAgent(const WebCore::URL&) const; 258 String userAgent(WebFrame*, const WebCore::URL&) const; 258 259 String platformUserAgent(const WebCore::URL&) const; 259 260 WebCore::IntRect windowResizerRect() const; -
trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
r168961 r170330 269 269 , m_world(AdoptWK, WKBundleScriptWorldCreateWorld()) 270 270 { 271 WKBundlePageLoaderClientV 7loaderClient = {272 { 7, this },271 WKBundlePageLoaderClientV8 loaderClient = { 272 { 8, this }, 273 273 didStartProvisionalLoadForFrame, 274 274 didReceiveServerRedirectForProvisionalLoadForFrame, … … 306 306 0, // willLoadDataRequest 307 307 0, // willDestroyFrame 308 0, // userAgentForURL 308 309 }; 309 310 WKBundlePageSetPageLoaderClient(m_page, &loaderClient.base);
Note: See TracChangeset
for help on using the changeset viewer.