Clicking "Go Back" on a safe browsing warning before a WKWebView has loaded any page...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Feb 2019 01:58:34 +0000 (01:58 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Feb 2019 01:58:34 +0000 (01:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194914
<rdar://problem/47586889>

Patch by Alex Christensen <achristensen@webkit.org> on 2019-02-21
Reviewed by Geoffrey Garen.

Source/WebKit:

* UIProcess/API/APIUIClient.h:
(API::UIClient::didShowSafeBrowsingWarning):
(API::UIClient::didClickGoBackFromSafeBrowsingWarning): Deleted.
* UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
* UIProcess/Cocoa/UIDelegate.h:
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::setDelegate):
(WebKit::UIDelegate::UIClient::didClickGoBackFromSafeBrowsingWarning): Deleted.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::decidePolicyForNavigationAction):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:
(-[SafeBrowsingNavigationDelegate webViewDidClose:]):
(TEST):
(-[SafeBrowsingNavigationDelegate _webViewDidClickGoBackFromSafeBrowsingWarning:]): Deleted.

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/APIUIClient.h
Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
Source/WebKit/UIProcess/Cocoa/UIDelegate.h
Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
Source/WebKit/UIProcess/WebPageProxy.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm

index f60efbf..d5cca5c 100644 (file)
@@ -1,3 +1,22 @@
+2019-02-21  Alex Christensen  <achristensen@webkit.org>
+
+        Clicking "Go Back" on a safe browsing warning before a WKWebView has loaded any page should request to close the WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=194914
+        <rdar://problem/47586889>
+
+        Reviewed by Geoffrey Garen.
+
+        * UIProcess/API/APIUIClient.h:
+        (API::UIClient::didShowSafeBrowsingWarning):
+        (API::UIClient::didClickGoBackFromSafeBrowsingWarning): Deleted.
+        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+        * UIProcess/Cocoa/UIDelegate.h:
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::UIDelegate::setDelegate):
+        (WebKit::UIDelegate::UIClient::didClickGoBackFromSafeBrowsingWarning): Deleted.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::decidePolicyForNavigationAction):
+
 2019-02-21  Tim Horton  <timothy_horton@apple.com>
 
         Turn a high-value UI-side-compositing assertion into a release assert
index 97ab4cc..3ec6f00 100644 (file)
@@ -182,7 +182,6 @@ public:
     virtual void didExceedBackgroundResourceLimitWhileInForeground(WebKit::WebPageProxy&, WKResourceLimit) { }
     
     virtual void didShowSafeBrowsingWarning() { }
-    virtual void didClickGoBackFromSafeBrowsingWarning() { }
 };
 
 } // namespace API
index 1e89364..5568083 100644 (file)
@@ -102,7 +102,6 @@ struct UIEdgeInsets;
 - (void)_webViewRequestPointerLock:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.12.3));
 - (void)_webViewDidRequestPointerLock:(WKWebView *)webView completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 - (void)_webViewDidShowSafeBrowsingWarning:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
-- (void)_webViewDidClickGoBackFromSafeBrowsingWarning:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 - (void)_webViewDidLosePointerLock:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.12.3));
 - (void)_webView:(WKWebView *)webView hasVideoInPictureInPictureDidChange:(BOOL)hasVideoInPictureInPicture WK_API_AVAILABLE(macosx(10.13), ios(11.0));
 
index b3a4352..1dc2ba1 100644 (file)
@@ -148,7 +148,6 @@ private:
 
         void imageOrMediaDocumentSizeChanged(const WebCore::IntSize&) final;
         void didShowSafeBrowsingWarning() final;
-        void didClickGoBackFromSafeBrowsingWarning() final;
 
         UIDelegate& m_uiDelegate;
     };
@@ -226,7 +225,6 @@ private:
 #endif
         bool webViewHasVideoInPictureInPictureDidChange : 1;
         bool webViewDidShowSafeBrowsingWarning : 1;
-        bool webViewDidClickGoBackFromSafeBrowsingWarning : 1;
     } m_delegateMethods;
 };
 
index 3ff0b28..98712ec 100644 (file)
@@ -173,7 +173,6 @@ void UIDelegate::setDelegate(id <WKUIDelegate> delegate)
     
     m_delegateMethods.webViewHasVideoInPictureInPictureDidChange = [delegate respondsToSelector:@selector(_webView:hasVideoInPictureInPictureDidChange:)];
     m_delegateMethods.webViewDidShowSafeBrowsingWarning = [delegate respondsToSelector:@selector(_webViewDidShowSafeBrowsingWarning:)];
-    m_delegateMethods.webViewDidClickGoBackFromSafeBrowsingWarning = [delegate respondsToSelector:@selector(_webViewDidClickGoBackFromSafeBrowsingWarning:)];
 }
 
 #if ENABLE(CONTEXT_MENUS)
@@ -1243,18 +1242,6 @@ void UIDelegate::UIClient::didShowSafeBrowsingWarning()
     [static_cast<id <WKUIDelegatePrivate>>(delegate) _webViewDidShowSafeBrowsingWarning:m_uiDelegate.m_webView];
 }
 
-void UIDelegate::UIClient::didClickGoBackFromSafeBrowsingWarning()
-{
-    if (!m_uiDelegate.m_delegateMethods.webViewDidClickGoBackFromSafeBrowsingWarning)
-        return;
-    
-    auto delegate = m_uiDelegate.m_delegate.get();
-    if (!delegate)
-        return;
-
-    [static_cast<id <WKUIDelegatePrivate>>(delegate) _webViewDidClickGoBackFromSafeBrowsingWarning:m_uiDelegate.m_webView];
-}
-
 void UIDelegate::UIClient::hasVideoInPictureInPictureDidChange(WebPageProxy*, bool hasVideoInPictureInPicture)
 {
     if (!m_uiDelegate.m_delegateMethods.webViewHasVideoInPictureInPictureDidChange)
index b08a1bf..4a01bf2 100644 (file)
@@ -4527,7 +4527,8 @@ void WebPageProxy::decidePolicyForNavigationAction(Ref<WebProcessProxy>&& proces
                 }, [&] (ContinueUnsafeLoad continueUnsafeLoad) {
                     switch (continueUnsafeLoad) {
                     case ContinueUnsafeLoad::No:
-                        protectedThis->m_uiClient->didClickGoBackFromSafeBrowsingWarning();
+                        if (!protectedThis->hasCommittedAnyProvisionalLoads())
+                            protectedThis->m_uiClient->close(protectedThis.ptr());
                         completionHandler(PolicyAction::Ignore);
                         break;
                     case ContinueUnsafeLoad::Yes:
index 2fd4eb0..1e025d4 100644 (file)
@@ -1,3 +1,16 @@
+2019-02-21  Alex Christensen  <achristensen@webkit.org>
+
+        Clicking "Go Back" on a safe browsing warning before a WKWebView has loaded any page should request to close the WKWebView
+        https://bugs.webkit.org/show_bug.cgi?id=194914
+        <rdar://problem/47586889>
+
+        Reviewed by Geoffrey Garen.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:
+        (-[SafeBrowsingNavigationDelegate webViewDidClose:]):
+        (TEST):
+        (-[SafeBrowsingNavigationDelegate _webViewDidClickGoBackFromSafeBrowsingWarning:]): Deleted.
+
 2019-02-21  David Kilzer  <ddkilzer@apple.com>
 
         Leak of CFErrorRef objects (1.92 Kbytes) in com.apple.WebKit.WebContent.Development running WebKit layout tests on iOS Simulator
index f2cc7e1..d08e54e 100644 (file)
@@ -41,7 +41,7 @@
 
 static bool committedNavigation;
 static bool warningShown;
-static bool goBackClicked;
+static bool didCloseCalled;
 
 @interface SafeBrowsingNavigationDelegate : NSObject <WKNavigationDelegate, WKUIDelegatePrivate>
 @end
@@ -58,9 +58,9 @@ static bool goBackClicked;
     warningShown = true;
 }
 
-- (void)_webViewDidClickGoBackFromSafeBrowsingWarning:(WKWebView *)webView
+- (void)webViewDidClose:(WKWebView *)webView
 {
-    goBackClicked = true;
+    didCloseCalled = true;
 }
 
 @end
@@ -231,9 +231,9 @@ template<typename ViewType> void goBack(ViewType *view)
 TEST(SafeBrowsing, GoBack)
 {
     auto webView = safeBrowsingView();
-    EXPECT_FALSE(goBackClicked);
+    EXPECT_FALSE(didCloseCalled);
     goBack([webView _safeBrowsingWarning]);
-    EXPECT_TRUE(goBackClicked);
+    EXPECT_TRUE(didCloseCalled);
 }
 
 template<typename ViewType> void visitUnsafeSite(ViewType *view)