Commit 43c9159e authored by Yi Su's avatar Yi Su Committed by Commit Bot

Move RequiresContentFilterBlockingWorkaround into wk_web_view_util.

This CL moves RequiresContentFilterBlockingWorkaround function into
wk_web_view_util so that it can be shared by CRWWKNavigationHandler and
CRWWebController.

Bug: 956511
Change-Id: I011413d885233d02daaf6ce7c0ea3c9ff197afe7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1631416Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Yi Su <mrsuyi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663797}
parent 0f454cf3
......@@ -186,19 +186,6 @@ GURL URLEscapedForHistory(const GURL& url) {
return net::GURLWithNSURL(net::NSURLWithGURL(url));
}
// Returns true if workaround for loading restricted URLs should be applied.
// TODO(crbug.com/954332): Remove this workaround when
// https://bugs.webkit.org/show_bug.cgi?id=196930 is fixed.
bool RequiresContentFilterBlockingWorkaround() {
if (!web::GetWebClient()->IsSlimNavigationManagerEnabled())
return false;
if (@available(iOS 12.2, *))
return true;
return false;
}
} // namespace
@interface CRWWebController () <BrowsingDataRemoverObserver,
......@@ -1854,7 +1841,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
WKNavigation* navigation = [self.webView loadRequest:request];
NSError* error = originalContext ? originalContext->GetError() : nil;
if (RequiresContentFilterBlockingWorkaround() &&
if (web::RequiresContentFilterBlockingWorkaround() &&
[error.domain isEqual:base::SysUTF8ToNSString(web::kWebKitErrorDomain)] &&
error.code == web::kWebKitErrorUrlBlockedByContentFilter) {
GURL currentWKItemURL =
......@@ -4186,7 +4173,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
if (web::GetWebClient()->IsSlimNavigationManagerEnabled()) {
// If URL is blocked due to Restriction, do not take any further
// action as WKWebView will show a built-in error.
if (!RequiresContentFilterBlockingWorkaround()) {
if (!web::RequiresContentFilterBlockingWorkaround()) {
return;
} else if (!PageTransitionIsNewNavigation(transition)) {
if (transition & ui::PAGE_TRANSITION_RELOAD) {
......
......@@ -11,6 +11,11 @@ namespace web {
// Returns true if a SafeBrowsing warning is currently displayed within
// |web_view|.
bool IsSafeBrowsingWarningDisplayedInWebView(WKWebView* web_view);
// Returns true if workaround for loading restricted URLs should be applied.
// TODO(crbug.com/954332): Remove this workaround when
// https://bugs.webkit.org/show_bug.cgi?id=196930 is fixed.
bool RequiresContentFilterBlockingWorkaround();
} // namespace web
#endif // IOS_WEB_WEB_VIEW_WK_WEB_VIEW_UTIL_H_
......@@ -4,6 +4,8 @@
#import "ios/web/web_view/wk_web_view_util.h"
#import "ios/web/public/web_client.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
......@@ -31,4 +33,14 @@ bool IsSafeBrowsingWarningDisplayedInWebView(WKWebView* web_view) {
isKindOfClass:[UIButton class]];
}
bool RequiresContentFilterBlockingWorkaround() {
if (!GetWebClient()->IsSlimNavigationManagerEnabled())
return false;
if (@available(iOS 12.2, *))
return true;
return false;
}
} // namespace web
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment