Changeset 243210 in webkit
- Timestamp:
- Mar 20, 2019, 9:41:15 AM (7 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 8 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/API/APIUIClient.h (modified) (2 diffs)
-
UIProcess/API/C/WKPage.cpp (modified) (2 diffs)
-
UIProcess/Cocoa/UIDelegate.h (modified) (3 diffs)
-
UIProcess/Cocoa/UIDelegate.mm (modified) (4 diffs)
-
UIProcess/Cocoa/WKStorageAccessAlert.h (modified) (1 diff)
-
UIProcess/Cocoa/WKStorageAccessAlert.mm (modified) (2 diffs)
-
UIProcess/WebPageProxy.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r243205 r243210 1 2019-03-20 Brent Fulgham <bfulgham@apple.com> 2 3 Adopt RegistrableDomain in the Storage Access API prompt code paths 4 https://bugs.webkit.org/show_bug.cgi?id=195957 5 <rdar://problem/49048028> 6 7 Reviewed by Chris Dumez. 8 9 While making the code changes in Bug 195866 we noticed that strings were being 10 used to pass the origins for the API calls. We should adopt the RegistrableDomain 11 class to improve type safety and avoid introducing bugs in the future. 12 13 * UIProcess/API/APIUIClient.h: 14 (API::UIClient::requestStorageAccessConfirm): 15 * UIProcess/API/C/WKPage.cpp: 16 (WKPageSetPageUIClient): 17 * UIProcess/Cocoa/UIDelegate.h: 18 * UIProcess/Cocoa/UIDelegate.mm: 19 (WebKit::UIDelegate::UIClient::requestStorageAccessConfirm): 20 * UIProcess/Cocoa/WKStorageAccessAlert.h: 21 * UIProcess/Cocoa/WKStorageAccessAlert.mm: 22 (WebKit::presentStorageAccessAlert): 23 * UIProcess/WebPageProxy.cpp: 24 (WebKit::WebPageProxy::requestStorageAccessConfirm): 25 1 26 2019-03-20 Chris Dumez <cdumez@apple.com> 2 27 -
trunk/Source/WebKit/UIProcess/API/APIUIClient.h
r242823 r243210 40 40 41 41 namespace WebCore { 42 class RegistrableDomain; 42 43 class ResourceRequest; 43 44 struct FontAttributes; … … 133 134 virtual void checkUserMediaPermissionForOrigin(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, SecurityOrigin&, SecurityOrigin&, WebKit::UserMediaPermissionCheckProxy& request) { request.deny(); } 134 135 virtual void decidePolicyForNotificationPermissionRequest(WebKit::WebPageProxy&, SecurityOrigin&, Function<void(bool)>&& completionHandler) { completionHandler(false); } 135 virtual void requestStorageAccessConfirm(WebKit::WebPageProxy&, WebKit::WebFrameProxy*, const W TF::String& requestingDomain, const WTF::String& currentDomain, CompletionHandler<void(bool)>&& completionHandler) { completionHandler(true); }136 virtual void requestStorageAccessConfirm(WebKit::WebPageProxy&, WebKit::WebFrameProxy*, const WebCore::RegistrableDomain& requestingDomain, const WebCore::RegistrableDomain& currentDomain, CompletionHandler<void(bool)>&& completionHandler) { completionHandler(true); } 136 137 137 138 // Printing. -
trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp
r242823 r243210 1889 1889 } 1890 1890 1891 void requestStorageAccessConfirm(WebPageProxy& page, WebFrameProxy* frame, const W TF::String& requestingDomain, const WTF::String& currentDomain, CompletionHandler<void(bool)>&& completionHandler) final1891 void requestStorageAccessConfirm(WebPageProxy& page, WebFrameProxy* frame, const WebCore::RegistrableDomain& requestingDomain, const WebCore::RegistrableDomain& currentDomain, CompletionHandler<void(bool)>&& completionHandler) final 1892 1892 { 1893 1893 if (!m_client.requestStorageAccessConfirm) { … … 1897 1897 1898 1898 auto listener = RequestStorageAccessConfirmResultListener::create(WTFMove(completionHandler)); 1899 m_client.requestStorageAccessConfirm(toAPI(&page), toAPI(frame), toAPI(requestingDomain. impl()), toAPI(currentDomain.impl()), toAPI(listener.ptr()), m_client.base.clientInfo);1899 m_client.requestStorageAccessConfirm(toAPI(&page), toAPI(frame), toAPI(requestingDomain.string().impl()), toAPI(currentDomain.string().impl()), toAPI(listener.ptr()), m_client.base.clientInfo); 1900 1900 } 1901 1901 -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h
r243173 r243210 42 42 } 43 43 44 namespace WebCore { 45 class RegistrableDomain; 46 } 47 44 48 namespace WebKit { 45 49 … … 89 93 void runJavaScriptPrompt(WebPageProxy*, const WTF::String&, const WTF::String&, WebFrameProxy*, const WebCore::SecurityOriginData&, Function<void(const WTF::String&)>&&) final; 90 94 void presentStorageAccessConfirmDialog(const WTF::String& requestingDomain, const WTF::String& currentDomain, CompletionHandler<void(bool)>&&); 91 void requestStorageAccessConfirm(WebPageProxy&, WebFrameProxy*, const W TF::String& requestingDomain, const WTF::String& currentDomain, CompletionHandler<void(bool)>&&) final;95 void requestStorageAccessConfirm(WebPageProxy&, WebFrameProxy*, const WebCore::RegistrableDomain& requestingDomain, const WebCore::RegistrableDomain& currentDomain, CompletionHandler<void(bool)>&&) final; 92 96 void decidePolicyForGeolocationPermissionRequest(WebPageProxy&, WebFrameProxy&, API::SecurityOrigin&, Function<void(bool)>&) final; 93 97 bool canRunBeforeUnloadConfirmPanel() const final; … … 164 168 bool webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler : 1; 165 169 bool webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler : 1; 166 bool webViewRequestStorageAccessPanel ForTopPrivatelyControlledDomainUnderFirstPartyTopPrivatelyControlledDomainCompletionHandler : 1;170 bool webViewRequestStorageAccessPanelUnderFirstPartyCompletionHandler : 1; 167 171 bool webViewRunBeforeUnloadConfirmPanelWithMessageInitiatedByFrameCompletionHandler : 1; 168 172 bool webViewRequestGeolocationPermissionForFrameDecisionHandler : 1; -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
r243178 r243210 105 105 m_delegateMethods.webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)]; 106 106 m_delegateMethods.webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:)]; 107 m_delegateMethods.webViewRequestStorageAccessPanel ForTopPrivatelyControlledDomainUnderFirstPartyTopPrivatelyControlledDomainCompletionHandler = [delegate respondsToSelector:@selector(_webView:requestStorageAccessPanelForDomain:underCurrentDomain:completionHandler:)];107 m_delegateMethods.webViewRequestStorageAccessPanelUnderFirstPartyCompletionHandler = [delegate respondsToSelector:@selector(_webView:requestStorageAccessPanelForDomain:underCurrentDomain:completionHandler:)]; 108 108 m_delegateMethods.webViewRunBeforeUnloadConfirmPanelWithMessageInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(_webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:)]; 109 109 m_delegateMethods.webViewRequestGeolocationPermissionForFrameDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestGeolocationPermissionForFrame:decisionHandler:)]; … … 338 338 } 339 339 340 void UIDelegate::UIClient::requestStorageAccessConfirm(WebPageProxy&, WebFrameProxy*, const W TF::String& requestingDomain, const WTF::String& currentDomain, CompletionHandler<void(bool)>&& completionHandler)340 void UIDelegate::UIClient::requestStorageAccessConfirm(WebPageProxy&, WebFrameProxy*, const WebCore::RegistrableDomain& requestingDomain, const WebCore::RegistrableDomain& currentDomain, CompletionHandler<void(bool)>&& completionHandler) 341 341 { 342 342 auto delegate = m_uiDelegate.m_delegate.get(); … … 346 346 } 347 347 348 if (!m_uiDelegate.m_delegateMethods.webViewRequestStorageAccessPanel ForTopPrivatelyControlledDomainUnderFirstPartyTopPrivatelyControlledDomainCompletionHandler) {348 if (!m_uiDelegate.m_delegateMethods.webViewRequestStorageAccessPanelUnderFirstPartyCompletionHandler) { 349 349 #if !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) 350 350 presentStorageAccessAlert(m_uiDelegate.m_webView, requestingDomain, currentDomain, WTFMove(completionHandler)); … … 354 354 355 355 auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:requestStorageAccessPanelForDomain:underCurrentDomain:completionHandler:)); 356 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView requestStorageAccessPanelForDomain:requestingDomain underCurrentDomain:currentDomaincompletionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)] (BOOL result) mutable {356 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView requestStorageAccessPanelForDomain:requestingDomain.string() underCurrentDomain:currentDomain.string() completionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)] (BOOL result) mutable { 357 357 if (checker->completionHandlerHasBeenCalled()) 358 358 return; -
trunk/Source/WebKit/UIProcess/Cocoa/WKStorageAccessAlert.h
r243173 r243210 36 36 } 37 37 38 namespace WebCore { 39 class RegistrableDomain; 40 } 41 38 42 namespace WebKit { 39 43 40 void presentStorageAccessAlert(WKWebView *, const W TF::String& requestingDomain, const WTF::String& currentDomain, CompletionHandler<void(bool)>&&);44 void presentStorageAccessAlert(WKWebView *, const WebCore::RegistrableDomain& requestingDomain, const WebCore::RegistrableDomain& currentDomain, CompletionHandler<void(bool)>&&); 41 45 42 46 } -
trunk/Source/WebKit/UIProcess/Cocoa/WKStorageAccessAlert.mm
r243173 r243210 31 31 #import "WKWebViewInternal.h" 32 32 #import <WebCore/LocalizedStrings.h> 33 #import <WebCore/RegistrableDomain.h> 33 34 #import <wtf/BlockPtr.h> 34 35 35 36 namespace WebKit { 36 37 37 void presentStorageAccessAlert(WKWebView *webView, const W TF::String& requestingDomain, const WTF::String& currentDomain, CompletionHandler<void(bool)>&& completionHandler)38 void presentStorageAccessAlert(WKWebView *webView, const WebCore::RegistrableDomain& requesting, const WebCore::RegistrableDomain& current, CompletionHandler<void(bool)>&& completionHandler) 38 39 { 39 40 auto completionBlock = makeBlockPtr([completionHandler = WTFMove(completionHandler)](bool shouldAllow) mutable { … … 41 42 }); 42 43 44 auto requestingDomain = requesting.string().createCFString(); 45 auto currentDomain = current.string().createCFString(); 46 43 47 #if PLATFORM(MAC) 44 NSString *alertTitle = [NSString stringWithFormat:WEB_UI_NSSTRING(@"Do you want to allow \"%@\" to use cookies and website data while browsing \"%@\"?", @"Message for requesting cross-site cookie and website data access."), requestingDomain. createCFString().get(), currentDomain.createCFString().get()];48 NSString *alertTitle = [NSString stringWithFormat:WEB_UI_NSSTRING(@"Do you want to allow \"%@\" to use cookies and website data while browsing \"%@\"?", @"Message for requesting cross-site cookie and website data access."), requestingDomain.get(), currentDomain.get()]; 45 49 #else 46 NSString *alertTitle = [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow \"%@\" to use cookies and website data while browsing \"%@\"?", @"Message for requesting cross-site cookie and website data access."), requestingDomain. createCFString().get(), currentDomain.createCFString().get()];50 NSString *alertTitle = [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow \"%@\" to use cookies and website data while browsing \"%@\"?", @"Message for requesting cross-site cookie and website data access."), requestingDomain.get(), currentDomain.get()]; 47 51 #endif 48 52 49 NSString *informativeText = [NSString stringWithFormat:WEB_UI_NSSTRING(@"This will allow \"%@\" to track your activity.", @"Informative text for requesting cross-site cookie and website data access."), requestingDomain. createCFString().get()];53 NSString *informativeText = [NSString stringWithFormat:WEB_UI_NSSTRING(@"This will allow \"%@\" to track your activity.", @"Informative text for requesting cross-site cookie and website data access."), requestingDomain.get()]; 50 54 NSString *allowButtonString = WEB_UI_STRING_KEY(@"Allow", "Allow (cross-site cookie and website data access)", @"Button title in Storage Access API prompt"); 51 55 NSString *doNotAllowButtonString = WEB_UI_STRING_KEY(@"Don't Allow", "Don't Allow (cross-site cookie and website data access)", @"Button title in Storage Access API prompt"); -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r243205 r243210 8460 8460 void WebPageProxy::requestStorageAccessConfirm(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, CompletionHandler<void(bool)>&& completionHandler) 8461 8461 { 8462 m_uiClient->requestStorageAccessConfirm(*this, m_process->webFrame(frameID), subFrameDomain .string(), topFrameDomain.string(), WTFMove(completionHandler));8462 m_uiClient->requestStorageAccessConfirm(*this, m_process->webFrame(frameID), subFrameDomain, topFrameDomain, WTFMove(completionHandler)); 8463 8463 } 8464 8464 #endif
Note:
See TracChangeset
for help on using the changeset viewer.