Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 2102834

Browse files
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> Patch by Alex Christensen <[email protected]> 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: http://svn.webkit.org/repository/webkit/trunk@241926 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent a511b71 commit 2102834

File tree

8 files changed

+39
-23
lines changed

8 files changed

+39
-23
lines changed

Source/WebKit/ChangeLog

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2019-02-21 Alex Christensen <[email protected]>
2+
3+
Clicking "Go Back" on a safe browsing warning before a WKWebView has loaded any page should request to close the WKWebView
4+
https://bugs.webkit.org/show_bug.cgi?id=194914
5+
<rdar://problem/47586889>
6+
7+
Reviewed by Geoffrey Garen.
8+
9+
* UIProcess/API/APIUIClient.h:
10+
(API::UIClient::didShowSafeBrowsingWarning):
11+
(API::UIClient::didClickGoBackFromSafeBrowsingWarning): Deleted.
12+
* UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
13+
* UIProcess/Cocoa/UIDelegate.h:
14+
* UIProcess/Cocoa/UIDelegate.mm:
15+
(WebKit::UIDelegate::setDelegate):
16+
(WebKit::UIDelegate::UIClient::didClickGoBackFromSafeBrowsingWarning): Deleted.
17+
* UIProcess/WebPageProxy.cpp:
18+
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
19+
120
2019-02-21 Tim Horton <[email protected]>
221

322
Turn a high-value UI-side-compositing assertion into a release assert

Source/WebKit/UIProcess/API/APIUIClient.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ class UIClient {
182182
virtual void didExceedBackgroundResourceLimitWhileInForeground(WebKit::WebPageProxy&, WKResourceLimit) { }
183183

184184
virtual void didShowSafeBrowsingWarning() { }
185-
virtual void didClickGoBackFromSafeBrowsingWarning() { }
186185
};
187186

188187
} // namespace API

Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ struct UIEdgeInsets;
102102
- (void)_webViewRequestPointerLock:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.12.3));
103103
- (void)_webViewDidRequestPointerLock:(WKWebView *)webView completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
104104
- (void)_webViewDidShowSafeBrowsingWarning:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
105-
- (void)_webViewDidClickGoBackFromSafeBrowsingWarning:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
106105
- (void)_webViewDidLosePointerLock:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.12.3));
107106
- (void)_webView:(WKWebView *)webView hasVideoInPictureInPictureDidChange:(BOOL)hasVideoInPictureInPicture WK_API_AVAILABLE(macosx(10.13), ios(11.0));
108107

Source/WebKit/UIProcess/Cocoa/UIDelegate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ class UIDelegate {
148148

149149
void imageOrMediaDocumentSizeChanged(const WebCore::IntSize&) final;
150150
void didShowSafeBrowsingWarning() final;
151-
void didClickGoBackFromSafeBrowsingWarning() final;
152151

153152
UIDelegate& m_uiDelegate;
154153
};
@@ -226,7 +225,6 @@ class UIDelegate {
226225
#endif
227226
bool webViewHasVideoInPictureInPictureDidChange : 1;
228227
bool webViewDidShowSafeBrowsingWarning : 1;
229-
bool webViewDidClickGoBackFromSafeBrowsingWarning : 1;
230228
} m_delegateMethods;
231229
};
232230

Source/WebKit/UIProcess/Cocoa/UIDelegate.mm

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@
173173

174174
m_delegateMethods.webViewHasVideoInPictureInPictureDidChange = [delegate respondsToSelector:@selector(_webView:hasVideoInPictureInPictureDidChange:)];
175175
m_delegateMethods.webViewDidShowSafeBrowsingWarning = [delegate respondsToSelector:@selector(_webViewDidShowSafeBrowsingWarning:)];
176-
m_delegateMethods.webViewDidClickGoBackFromSafeBrowsingWarning = [delegate respondsToSelector:@selector(_webViewDidClickGoBackFromSafeBrowsingWarning:)];
177176
}
178177

179178
#if ENABLE(CONTEXT_MENUS)
@@ -1243,18 +1242,6 @@ static void requestUserMediaAuthorizationForFrame(const WebFrameProxy& frame, AP
12431242
[static_cast<id <WKUIDelegatePrivate>>(delegate) _webViewDidShowSafeBrowsingWarning:m_uiDelegate.m_webView];
12441243
}
12451244

1246-
void UIDelegate::UIClient::didClickGoBackFromSafeBrowsingWarning()
1247-
{
1248-
if (!m_uiDelegate.m_delegateMethods.webViewDidClickGoBackFromSafeBrowsingWarning)
1249-
return;
1250-
1251-
auto delegate = m_uiDelegate.m_delegate.get();
1252-
if (!delegate)
1253-
return;
1254-
1255-
[static_cast<id <WKUIDelegatePrivate>>(delegate) _webViewDidClickGoBackFromSafeBrowsingWarning:m_uiDelegate.m_webView];
1256-
}
1257-
12581245
void UIDelegate::UIClient::hasVideoInPictureInPictureDidChange(WebPageProxy*, bool hasVideoInPictureInPicture)
12591246
{
12601247
if (!m_uiDelegate.m_delegateMethods.webViewHasVideoInPictureInPictureDidChange)

Source/WebKit/UIProcess/WebPageProxy.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4527,7 +4527,8 @@ void WebPageProxy::decidePolicyForNavigationAction(Ref<WebProcessProxy>&& proces
45274527
}, [&] (ContinueUnsafeLoad continueUnsafeLoad) {
45284528
switch (continueUnsafeLoad) {
45294529
case ContinueUnsafeLoad::No:
4530-
protectedThis->m_uiClient->didClickGoBackFromSafeBrowsingWarning();
4530+
if (!protectedThis->hasCommittedAnyProvisionalLoads())
4531+
protectedThis->m_uiClient->close(protectedThis.ptr());
45314532
completionHandler(PolicyAction::Ignore);
45324533
break;
45334534
case ContinueUnsafeLoad::Yes:

Tools/ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2019-02-21 Alex Christensen <[email protected]>
2+
3+
Clicking "Go Back" on a safe browsing warning before a WKWebView has loaded any page should request to close the WKWebView
4+
https://bugs.webkit.org/show_bug.cgi?id=194914
5+
<rdar://problem/47586889>
6+
7+
Reviewed by Geoffrey Garen.
8+
9+
* TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm:
10+
(-[SafeBrowsingNavigationDelegate webViewDidClose:]):
11+
(TEST):
12+
(-[SafeBrowsingNavigationDelegate _webViewDidClickGoBackFromSafeBrowsingWarning:]): Deleted.
13+
114
2019-02-21 David Kilzer <[email protected]>
215

316
Leak of CFErrorRef objects (1.92 Kbytes) in com.apple.WebKit.WebContent.Development running WebKit layout tests on iOS Simulator

Tools/TestWebKitAPI/Tests/WebKitCocoa/SafeBrowsing.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
static bool committedNavigation;
4343
static bool warningShown;
44-
static bool goBackClicked;
44+
static bool didCloseCalled;
4545

4646
@interface SafeBrowsingNavigationDelegate : NSObject <WKNavigationDelegate, WKUIDelegatePrivate>
4747
@end
@@ -58,9 +58,9 @@ - (void)_webViewDidShowSafeBrowsingWarning:(WKWebView *)webView
5858
warningShown = true;
5959
}
6060

61-
- (void)_webViewDidClickGoBackFromSafeBrowsingWarning:(WKWebView *)webView
61+
- (void)webViewDidClose:(WKWebView *)webView
6262
{
63-
goBackClicked = true;
63+
didCloseCalled = true;
6464
}
6565

6666
@end
@@ -231,9 +231,9 @@ static void checkTitleAndClick(UIButton *button, const char* expectedTitle)
231231
TEST(SafeBrowsing, GoBack)
232232
{
233233
auto webView = safeBrowsingView();
234-
EXPECT_FALSE(goBackClicked);
234+
EXPECT_FALSE(didCloseCalled);
235235
goBack([webView _safeBrowsingWarning]);
236-
EXPECT_TRUE(goBackClicked);
236+
EXPECT_TRUE(didCloseCalled);
237237
}
238238

239239
template<typename ViewType> void visitUnsafeSite(ViewType *view)

0 commit comments

Comments
 (0)