Modernize NavigationState
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jul 2018 20:14:32 +0000 (20:14 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jul 2018 20:14:32 +0000 (20:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187966

Reviewed by Andy Estes.

Don't ignore switch warnings any more.
Use BlockPtr.

* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
(WebKit::NavigationState::NavigationClient::decidePolicyForNavigationResponse):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234169 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/NavigationState.mm

index 1224398..2833d5d 100644 (file)
@@ -1,5 +1,19 @@
 2018-07-24  Alex Christensen  <achristensen@webkit.org>
 
+        Modernize NavigationState
+        https://bugs.webkit.org/show_bug.cgi?id=187966
+
+        Reviewed by Andy Estes.
+
+        Don't ignore switch warnings any more.
+        Use BlockPtr.
+
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
+        (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationResponse):
+
+2018-07-24  Alex Christensen  <achristensen@webkit.org>
+
         Remove WebFramePolicyListenerProxy::changeWebsiteDataStore
         https://bugs.webkit.org/show_bug.cgi?id=187967
 
index ab17f1d..6fd0293 100644 (file)
@@ -542,11 +542,7 @@ void NavigationState::NavigationClient::decidePolicyForNavigationAction(WebPageP
 
         switch (actionPolicy) {
         case WKNavigationActionPolicyAllow:
-// FIXME: Once we have a new enough compiler everywhere we don't need to ignore -Wswitch.
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wswitch"
         case _WKNavigationActionPolicyAllowInNewProcess:
-#pragma clang diagnostic pop
             tryAppLink(WTFMove(navigationAction), mainFrameURLString, [actionPolicy, localListener = WTFMove(localListener), websitePolicies = WTFMove(apiWebsitePolicies)](bool followedLinkToApp) mutable {
                 if (followedLinkToApp) {
                     localListener->ignore();
@@ -562,14 +558,10 @@ void NavigationState::NavigationClient::decidePolicyForNavigationAction(WebPageP
             localListener->ignore();
             break;
 
-// FIXME: Once we have a new enough compiler everywhere we don't need to ignore -Wswitch.
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wswitch"
         case _WKNavigationActionPolicyDownload:
             localListener->download();
             break;
         case _WKNavigationActionPolicyAllowWithoutTryingAppLink:
-#pragma clang diagnostic pop
             localListener->use(apiWebsitePolicies.get());
             break;
         }
@@ -637,10 +629,8 @@ void NavigationState::NavigationClient::decidePolicyForNavigationResponse(WebPag
     if (!navigationDelegate)
         return;
 
-    RefPtr<WebFramePolicyListenerProxy> localListener = WTFMove(listener);
-    RefPtr<CompletionHandlerCallChecker> checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), @selector(webView:decidePolicyForNavigationResponse:decisionHandler:));
-    RefPtr<API::NavigationResponse> navigationResponseRefPtr(navigationResponse.ptr());
-    [navigationDelegate webView:m_navigationState.m_webView decidePolicyForNavigationResponse:wrapper(navigationResponse) decisionHandler:[localListener, checker](WKNavigationResponsePolicy responsePolicy) {
+    auto checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), @selector(webView:decidePolicyForNavigationResponse:decisionHandler:));
+    [navigationDelegate webView:m_navigationState.m_webView decidePolicyForNavigationResponse:wrapper(navigationResponse) decisionHandler:BlockPtr<void(WKNavigationResponsePolicy)>::fromCallable([localListener = WTFMove(listener), checker = WTFMove(checker)](WKNavigationResponsePolicy responsePolicy) {
         if (checker->completionHandlerHasBeenCalled())
             return;
         checker->didCallCompletionHandler();
@@ -654,15 +644,11 @@ void NavigationState::NavigationClient::decidePolicyForNavigationResponse(WebPag
             localListener->ignore();
             break;
 
-// FIXME: Once we have a new enough compiler everywhere we don't need to ignore -Wswitch.
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wswitch"
         case _WKNavigationResponsePolicyBecomeDownload:
             localListener->download();
-#pragma clang diagnostic pop
             break;
         }
-    }];
+    }).get()];
 }
 
 void NavigationState::NavigationClient::didStartProvisionalNavigation(WebPageProxy& page, API::Navigation* navigation, API::Object* userInfo)