Chromium Code Reviews| Index: ios/web/web_state/ui/crw_web_controller.mm |
| diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm |
| index a1f5aa0211eef998ec0e47ebedb88e7325a85d75..5b5067b64d770efc0c576afc1b9a00de2227d07f 100644 |
| --- a/ios/web/web_state/ui/crw_web_controller.mm |
| +++ b/ios/web/web_state/ui/crw_web_controller.mm |
| @@ -4963,6 +4963,18 @@ - (void)webView:(WKWebView*)webView |
| // retrieved state will be pending until |didCommitNavigation| callback. |
| [self updatePendingNavigationInfoFromNavigationAction:action]; |
| + // Invalid URLs should not be loaded. However, simply doing nothing upon |
| + // tapping a link or button is a jarring user experience. Instead, cancel |
| + // the invalid navigation and load about:blank. |
| + GURL requestURL = net::GURLWithNSURL(action.request.URL); |
| + if (!requestURL.is_valid()) { |
|
Eugene But (OOO till 7-30)
2016/10/05 00:58:39
What |requestURL.is_valid()| would return for "abo
kkhorimoto
2016/10/05 01:16:26
GURL("about:blank").is_valid() is true, so that's
|
| + decisionHandler(WKNavigationActionPolicyCancel); |
| + web::NavigationManager::WebLoadParams loadParams(GURL("about:blank")); |
|
Eugene But (OOO till 7-30)
2016/10/05 01:41:44
s/"about:blank"/kAboutBlankURL
kkhorimoto
2016/10/05 04:09:19
Done.
|
| + loadParams.referrer = [self currentReferrer]; |
| + self.webState->GetNavigationManager()->LoadURLWithParams(loadParams); |
| + return; |
| + } |
| + |
| BOOL allowLoad = [self shouldAllowLoadWithNavigationAction:action]; |
| if (allowLoad) { |