Changeset 221920 in webkit
- Timestamp:
- Sep 12, 2017, 9:32:39 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r221907 r221920 1 2017-09-12 Alex Christensen <achristensen@webkit.org> 2 3 Add WKUIDelegatePrivate equivalent of WKPageUIClient's decidePolicyForNotificationPermissionRequest 4 https://bugs.webkit.org/show_bug.cgi?id=176768 5 <rdar://problem/29270035> 6 7 Reviewed by Tim Horton. 8 9 Covered by a new API test. 10 11 * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: 12 * UIProcess/Cocoa/UIDelegate.h: 13 * UIProcess/Cocoa/UIDelegate.mm: 14 (WebKit::UIDelegate::setDelegate): 15 (WebKit::UIDelegate::UIClient::runBeforeUnloadConfirmPanel): 16 (WebKit::UIDelegate::UIClient::exceededDatabaseQuota): 17 (WebKit::UIDelegate::UIClient::decidePolicyForNotificationPermissionRequest): 18 (WebKit::UIDelegate::UIClient::reachedApplicationCacheOriginQuota): 19 1 20 2017-09-11 Wenson Hsieh <wenson_hsieh@apple.com> 2 21 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
r221873 r221920 161 161 - (void)_webView:(WKWebView *)webView getToolbarsAreVisibleWithCompletionHandler:(void(^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 162 162 - (void)_webView:(WKWebView *)webView saveDataToFile:(NSData *)data suggestedFilename:(NSString *)suggestedFilename mimeType:(NSString *)mimeType originatingURL:(NSURL *)url WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 163 - (void)_webView:(WKWebView *)webView requestNotificationPermissionForSecurityOrigin:(WKSecurityOrigin *)securityOrigin decisionHandler:(void (^)(BOOL))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 163 164 - (void)_webView:(WKWebView *)webview mouseDidMoveOverElement:(_WKHitTestResult *)hitTestResult withFlags:(NSEventModifierFlags)flags userInfo:(id <NSSecureCoding>)userInfo; 164 165 - (void)_webView:(WKWebView *)webView didExceedBackgroundResourceLimitWhileInForeground:(_WKResourceLimit)limit WK_API_AVAILABLE(macosx(WK_MAC_TBA)); -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h
r221899 r221920 41 41 namespace API { 42 42 class FrameInfo; 43 class SecurityOrigin; 43 44 } 44 45 … … 100 101 void pageDidScroll(WebPageProxy*) final; 101 102 void didNotHandleWheelEvent(WebPageProxy*, const NativeWebWheelEvent&) final; 103 void decidePolicyForNotificationPermissionRequest(WebPageProxy&, API::SecurityOrigin&, Function<void(bool)>&&) final; 102 104 void handleAutoplayEvent(WebPageProxy&, WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) final; 103 105 void unavailablePluginButtonClicked(WebPageProxy&, WKPluginUnavailabilityReason, API::Dictionary&) final; … … 162 164 bool webViewSaveDataToFileSuggestedFilenameMimeTypeOriginatingURL : 1; 163 165 bool webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler : 1; 166 bool webViewRequestNotificationPermissionForSecurityOriginDecisionHandler : 1; 164 167 #endif 165 168 bool webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1; -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
r221899 r221920 121 121 m_delegateMethods.webViewSaveDataToFileSuggestedFilenameMimeTypeOriginatingURL = [delegate respondsToSelector:@selector(_webView:saveDataToFile:suggestedFilename:mimeType:originatingURL:)]; 122 122 m_delegateMethods.webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:)]; 123 m_delegateMethods.webViewRequestNotificationPermissionForSecurityOriginDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestNotificationPermissionForSecurityOrigin:decisionHandler:)]; 123 124 #endif 124 125 m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)]; … … 341 342 } 342 343 343 RefPtr<CompletionHandlerCallChecker>checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:));344 auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:)); 344 345 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView runBeforeUnloadConfirmPanelWithMessage:message initiatedByFrame:wrapper(API::FrameInfo::create(*webFrameProxy, securityOriginData.securityOrigin())) completionHandler:BlockPtr<void (BOOL)>::fromCallable([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)](BOOL result) { 345 346 if (checker->completionHandlerHasBeenCalled()) … … 368 369 369 370 ASSERT(securityOrigin); 370 RefPtr<CompletionHandlerCallChecker>checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:));371 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView decideDatabaseQuotaForSecurityOrigin:wrapper(*securityOrigin) currentQuota:currentQuota currentOriginUsage:currentOriginUsage currentDatabaseUsage:currentUsage expectedUsage:expectedUsage decisionHandler:BlockPtr<void 371 auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)); 372 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView decideDatabaseQuotaForSecurityOrigin:wrapper(*securityOrigin) currentQuota:currentQuota currentOriginUsage:currentOriginUsage currentDatabaseUsage:currentUsage expectedUsage:expectedUsage decisionHandler:BlockPtr<void(unsigned long long newQuota)>::fromCallable([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)](unsigned long long newQuota) { 372 373 if (checker->completionHandlerHasBeenCalled()) 373 374 return; … … 618 619 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView saveDataToFile:wrapper(data) suggestedFilename:suggestedFilename mimeType:mimeType originatingURL:originatingURL]; 619 620 } 620 621 622 void UIDelegate::UIClient::decidePolicyForNotificationPermissionRequest(WebKit::WebPageProxy&, API::SecurityOrigin& securityOrigin, WTF::Function<void(bool)>&& completionHandler) 623 { 624 if (!m_uiDelegate.m_delegateMethods.webViewRequestNotificationPermissionForSecurityOriginDecisionHandler) 625 return completionHandler(false); 626 627 auto delegate = m_uiDelegate.m_delegate.get(); 628 if (!delegate) 629 return completionHandler(false); 630 631 auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:requestNotificationPermissionForSecurityOrigin:decisionHandler:)); 632 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView requestNotificationPermissionForSecurityOrigin:wrapper(securityOrigin) decisionHandler:BlockPtr<void(BOOL)>::fromCallable([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)](BOOL result) { 633 if (checker->completionHandlerHasBeenCalled()) 634 return; 635 checker->didCallCompletionHandler(); 636 completionHandler(result); 637 }).get()]; 638 } 639 621 640 bool UIDelegate::UIClient::runOpenPanel(WebPageProxy*, WebFrameProxy* webFrameProxy, const WebCore::SecurityOriginData& securityOriginData, API::OpenPanelParameters* openPanelParameters, WebOpenPanelResultListenerProxy* listener) 622 641 { … … 811 830 } 812 831 813 RefPtr<CompletionHandlerCallChecker>checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:decideWebApplicationCacheQuotaForSecurityOrigin:currentQuota:totalBytesNeeded:decisionHandler:));814 RefPtr<API::SecurityOrigin>apiOrigin = API::SecurityOrigin::create(securityOrigin);815 816 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView decideWebApplicationCacheQuotaForSecurityOrigin:wrapper( *apiOrigin) currentQuota:currentQuota totalBytesNeeded:totalBytesNeeded decisionHandler:BlockPtr<void(unsigned long long)>::fromCallable([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)](unsigned long long newQuota) {832 auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:decideWebApplicationCacheQuotaForSecurityOrigin:currentQuota:totalBytesNeeded:decisionHandler:)); 833 auto apiOrigin = API::SecurityOrigin::create(securityOrigin); 834 835 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView decideWebApplicationCacheQuotaForSecurityOrigin:wrapper(apiOrigin.get()) currentQuota:currentQuota totalBytesNeeded:totalBytesNeeded decisionHandler:BlockPtr<void(unsigned long long)>::fromCallable([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)](unsigned long long newQuota) { 817 836 if (checker->completionHandlerHasBeenCalled()) 818 837 return; -
trunk/Tools/ChangeLog
r221917 r221920 1 2017-09-12 Alex Christensen <achristensen@webkit.org> 2 3 Add WKUIDelegatePrivate equivalent of WKPageUIClient's decidePolicyForNotificationPermissionRequest 4 https://bugs.webkit.org/show_bug.cgi?id=176768 5 <rdar://problem/29270035> 6 7 Reviewed by Tim Horton. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm: 10 (-[NotificationDelegate initWithAllowNotifications:]): 11 (-[NotificationDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): 12 (-[NotificationDelegate _webView:requestNotificationPermissionForSecurityOrigin:decisionHandler:]): 13 (TEST): 14 1 15 2017-09-12 Brent Fulgham <bfulgham@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm
r221873 r221920 203 203 } 204 204 205 @interface NotificationDelegate : NSObject <WKUIDelegatePrivate> { 206 bool _allowNotifications; 207 } 208 - (id)initWithAllowNotifications:(bool)allowNotifications; 209 @end 210 211 @implementation NotificationDelegate 212 213 - (id)initWithAllowNotifications:(bool)allowNotifications 214 { 215 if (!(self = [super init])) 216 return nil; 217 _allowNotifications = allowNotifications; 218 return self; 219 } 220 221 - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler 222 { 223 if (_allowNotifications) 224 EXPECT_STREQ(message.UTF8String, "permission granted"); 225 else 226 EXPECT_STREQ(message.UTF8String, "permission denied"); 227 completionHandler(); 228 done = true; 229 } 230 231 - (void)_webView:(WKWebView *)webView requestNotificationPermissionForSecurityOrigin:(WKSecurityOrigin *)securityOrigin decisionHandler:(void (^)(BOOL))decisionHandler 232 { 233 if (_allowNotifications) 234 EXPECT_STREQ(securityOrigin.host.UTF8String, "example.org"); 235 else 236 EXPECT_STREQ(securityOrigin.host.UTF8String, "example.com"); 237 decisionHandler(_allowNotifications); 238 } 239 240 @end 241 242 TEST(WebKit, NotificationPermission) 243 { 244 NSString *html = @"<script>Notification.requestPermission(function(p){alert('permission '+p)})</script>"; 245 auto webView = adoptNS([[WKWebView alloc] init]); 246 [webView setUIDelegate:[[[NotificationDelegate alloc] initWithAllowNotifications:YES] autorelease]]; 247 [webView loadHTMLString:html baseURL:[NSURL URLWithString:@"http://example.org"]]; 248 TestWebKitAPI::Util::run(&done); 249 done = false; 250 [webView setUIDelegate:[[[NotificationDelegate alloc] initWithAllowNotifications:NO] autorelease]]; 251 [webView loadHTMLString:html baseURL:[NSURL URLWithString:@"http://example.com"]]; 252 TestWebKitAPI::Util::run(&done); 253 } 205 254 206 255 @interface PlugInDelegate : NSObject <WKUIDelegatePrivate>
Note:
See TracChangeset
for help on using the changeset viewer.