Add SPI to inform an application that "Go Back" has been clicked from a safe browsing...
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Jan 2019 23:16:46 +0000 (23:16 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Jan 2019 23:16:46 +0000 (23:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193802
<rdar://problem/46010580>

Reviewed by Andy Estes.

Source/WebKit:

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

Tools:

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

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240516 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 99c99aa..059839b 100644 (file)
@@ -1,3 +1,21 @@
+2019-01-25  Alex Christensen  <achristensen@webkit.org>
+
+        Add SPI to inform an application that "Go Back" has been clicked from a safe browsing warning
+        https://bugs.webkit.org/show_bug.cgi?id=193802
+        <rdar://problem/46010580>
+
+        Reviewed by Andy Estes.
+
+        * UIProcess/API/APIUIClient.h:
+        (API::UIClient::didClickGoBackFromSafeBrowsingWarning):
+        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+        * UIProcess/Cocoa/UIDelegate.h:
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::UIDelegate::setDelegate):
+        (WebKit::UIDelegate::UIClient::didClickGoBackFromSafeBrowsingWarning):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::decidePolicyForNavigationAction):
+
 2019-01-25  Daniel Bates  <dabates@apple.com>
 
         [iOS] Pressing Tab key doesn't move to next cell with Google Sheets
index 81ec069..d788a50 100644 (file)
@@ -182,6 +182,7 @@ public:
     virtual void didExceedBackgroundResourceLimitWhileInForeground(WebKit::WebPageProxy&, WKResourceLimit) { }
     
     virtual void didShowSafeBrowsingWarning() { }
+    virtual void didClickGoBackFromSafeBrowsingWarning() { }
 };
 
 } // namespace API
index 5568083..1e89364 100644 (file)
@@ -102,6 +102,7 @@ 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 5990ccf..f5a9473 100644 (file)
@@ -147,6 +147,7 @@ private:
 
         void imageOrMediaDocumentSizeChanged(const WebCore::IntSize&) final;
         void didShowSafeBrowsingWarning() final;
+        void didClickGoBackFromSafeBrowsingWarning() final;
 
         UIDelegate& m_uiDelegate;
     };
@@ -224,6 +225,7 @@ private:
 #endif
         bool webViewHasVideoInPictureInPictureDidChange : 1;
         bool webViewDidShowSafeBrowsingWarning : 1;
+        bool webViewDidClickGoBackFromSafeBrowsingWarning : 1;
     } m_delegateMethods;
 };
 
index 3a35a5f..b8ab985 100644 (file)
@@ -172,6 +172,7 @@ 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)
@@ -1257,6 +1258,18 @@ 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 bdec81a..fd29374 100644 (file)
@@ -4439,6 +4439,7 @@ void WebPageProxy::decidePolicyForNavigationAction(Ref<WebProcessProxy>&& proces
                 }, [&] (ContinueUnsafeLoad continueUnsafeLoad) {
                     switch (continueUnsafeLoad) {
                     case ContinueUnsafeLoad::No:
+                        protectedThis->m_uiClient->didClickGoBackFromSafeBrowsingWarning();
                         completionHandler(PolicyAction::Ignore);
                         break;
                     case ContinueUnsafeLoad::Yes:
index e4e45bd..265a2d9 100644 (file)
@@ -1,3 +1,15 @@
+2019-01-25  Alex Christensen  <achristensen@webkit.org>
+
+        Add SPI to inform an application that "Go Back" has been clicked from a safe browsing warning
+        https://bugs.webkit.org/show_bug.cgi?id=193802
+        <rdar://problem/46010580>
+
+        Reviewed by Andy Estes.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:
+        (-[SafeBrowsingNavigationDelegate _webViewDidClickGoBackFromSafeBrowsingWarning:]):
+        (TEST):
+
 2019-01-25  Daniel Bates  <dabates@apple.com>
 
         [iOS] uiController.keyDown() does not translate Control modified key
index 438757e..637f755 100644 (file)
@@ -40,6 +40,7 @@
 
 static bool committedNavigation;
 static bool warningShown;
+static bool goBackClicked;
 
 @interface SafeBrowsingNavigationDelegate : NSObject <WKNavigationDelegate, WKUIDelegatePrivate>
 @end
@@ -56,6 +57,11 @@ static bool warningShown;
     warningShown = true;
 }
 
+- (void)_webViewDidClickGoBackFromSafeBrowsingWarning:(WKWebView *)webView
+{
+    goBackClicked = true;
+}
+
 @end
 
 @interface TestServiceLookupResult : NSObject {
@@ -221,7 +227,9 @@ template<typename ViewType> void goBack(ViewType *view)
 TEST(SafeBrowsing, GoBack)
 {
     auto webView = safeBrowsingView();
+    EXPECT_FALSE(goBackClicked);
     goBack([webView _safeBrowsingWarning]);
+    EXPECT_TRUE(goBackClicked);
 }
 
 template<typename ViewType> void visitUnsafeSite(ViewType *view)