Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/web/web_state/ui/crw_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_web_controller.h" |
| 6 | 6 |
| 7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
| 8 | 8 |
| 9 #import <objc/runtime.h> | 9 #import <objc/runtime.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 4945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4956 _webProcessIsDead = NO; | 4956 _webProcessIsDead = NO; |
| 4957 if (_isBeingDestroyed) { | 4957 if (_isBeingDestroyed) { |
| 4958 decisionHandler(WKNavigationActionPolicyCancel); | 4958 decisionHandler(WKNavigationActionPolicyCancel); |
| 4959 return; | 4959 return; |
| 4960 } | 4960 } |
| 4961 | 4961 |
| 4962 // The page will not be changed until this navigation is commited, so the | 4962 // The page will not be changed until this navigation is commited, so the |
| 4963 // retrieved state will be pending until |didCommitNavigation| callback. | 4963 // retrieved state will be pending until |didCommitNavigation| callback. |
| 4964 [self updatePendingNavigationInfoFromNavigationAction:action]; | 4964 [self updatePendingNavigationInfoFromNavigationAction:action]; |
| 4965 | 4965 |
| 4966 // Invalid URLs should not be loaded. However, simply doing nothing upon | |
| 4967 // tapping a link or button is a jarring user experience. Instead, cancel | |
| 4968 // the invalid navigation and load about:blank. | |
| 4969 GURL requestURL = net::GURLWithNSURL(action.request.URL); | |
| 4970 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
| |
| 4971 decisionHandler(WKNavigationActionPolicyCancel); | |
| 4972 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.
| |
| 4973 loadParams.referrer = [self currentReferrer]; | |
| 4974 self.webState->GetNavigationManager()->LoadURLWithParams(loadParams); | |
| 4975 return; | |
| 4976 } | |
| 4977 | |
| 4966 BOOL allowLoad = [self shouldAllowLoadWithNavigationAction:action]; | 4978 BOOL allowLoad = [self shouldAllowLoadWithNavigationAction:action]; |
| 4967 | 4979 |
| 4968 if (allowLoad) { | 4980 if (allowLoad) { |
| 4969 allowLoad = self.webStateImpl->ShouldAllowRequest(action.request); | 4981 allowLoad = self.webStateImpl->ShouldAllowRequest(action.request); |
| 4970 if (!allowLoad && action.targetFrame.mainFrame) { | 4982 if (!allowLoad && action.targetFrame.mainFrame) { |
| 4971 [_pendingNavigationInfo setCancelled:YES]; | 4983 [_pendingNavigationInfo setCancelled:YES]; |
| 4972 } | 4984 } |
| 4973 } | 4985 } |
| 4974 | 4986 |
| 4975 decisionHandler(allowLoad ? WKNavigationActionPolicyAllow | 4987 decisionHandler(allowLoad ? WKNavigationActionPolicyAllow |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5632 } | 5644 } |
| 5633 | 5645 |
| 5634 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5646 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 5635 } | 5647 } |
| 5636 | 5648 |
| 5637 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5649 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 5638 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5650 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 5639 } | 5651 } |
| 5640 | 5652 |
| 5641 @end | 5653 @end |
| OLD | NEW |