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 4286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4297 _webProcessIsDead = NO; | 4297 _webProcessIsDead = NO; |
| 4298 if (_isBeingDestroyed) { | 4298 if (_isBeingDestroyed) { |
| 4299 decisionHandler(WKNavigationActionPolicyCancel); | 4299 decisionHandler(WKNavigationActionPolicyCancel); |
| 4300 return; | 4300 return; |
| 4301 } | 4301 } |
| 4302 | 4302 |
| 4303 // The page will not be changed until this navigation is commited, so the | 4303 // The page will not be changed until this navigation is commited, so the |
| 4304 // retrieved state will be pending until |didCommitNavigation| callback. | 4304 // retrieved state will be pending until |didCommitNavigation| callback. |
| 4305 [self updatePendingNavigationInfoFromNavigationAction:action]; | 4305 [self updatePendingNavigationInfoFromNavigationAction:action]; |
| 4306 | 4306 |
| 4307 // Invalid URLs should not be loaded. However, simply doing nothing upon | 4307 // Invalid URLs should not be loaded. |
| 4308 // tapping a link or button is a jarring user experience. Instead, cancel | |
| 4309 // the invalid navigation and load about:blank if navigation was requested for | |
| 4310 // the main frame. | |
| 4311 GURL requestURL = net::GURLWithNSURL(action.request.URL); | 4308 GURL requestURL = net::GURLWithNSURL(action.request.URL); |
| 4312 if (!requestURL.is_valid()) { | 4309 if (!requestURL.is_valid()) { |
| 4313 decisionHandler(WKNavigationActionPolicyCancel); | 4310 decisionHandler(WKNavigationActionPolicyCancel); |
| 4314 if (action.targetFrame.mainFrame) { | 4311 // The HTML5 spec indicates that window.open with an invalid URL should open |
| 4312 // about:blank. | |
| 4313 BOOL isFirstLoadInOpenedWindow = | |
| 4314 self.webState->HasOpener() && | |
| 4315 !self.webState->GetNavigationManager()->GetLastCommittedItem(); | |
| 4316 BOOL isMainFrame = action.targetFrame.mainFrame; | |
| 4317 if (isFirstLoadInOpenedWindow && isMainFrame) { | |
|
Eugene But (OOO till 7-30)
2017/04/06 18:34:19
I thought this will break CRWWebControllerInvalidU
kkhorimoto
2017/04/07 00:03:40
It looks like WKWebView's |-loadHTMLString:baseURL
Eugene But (OOO till 7-30)
2017/04/07 01:03:36
Sorry looks like that test was useless :( I will d
| |
| 4315 GURL aboutBlankURL(url::kAboutBlankURL); | 4318 GURL aboutBlankURL(url::kAboutBlankURL); |
| 4316 web::NavigationManager::WebLoadParams loadParams(aboutBlankURL); | 4319 web::NavigationManager::WebLoadParams loadParams(aboutBlankURL); |
| 4317 loadParams.referrer = [self currentReferrer]; | 4320 loadParams.referrer = [self currentReferrer]; |
| 4318 self.webState->GetNavigationManager()->LoadURLWithParams(loadParams); | 4321 self.webState->GetNavigationManager()->LoadURLWithParams(loadParams); |
| 4319 } | 4322 } |
| 4320 return; | 4323 return; |
| 4321 } | 4324 } |
| 4322 | 4325 |
| 4323 BOOL allowLoad = [self shouldAllowLoadWithNavigationAction:action]; | 4326 BOOL allowLoad = [self shouldAllowLoadWithNavigationAction:action]; |
| 4324 | 4327 |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5069 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5072 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
| 5070 _lastRegisteredRequestURL = URL; | 5073 _lastRegisteredRequestURL = URL; |
| 5071 _loadPhase = web::LOAD_REQUESTED; | 5074 _loadPhase = web::LOAD_REQUESTED; |
| 5072 } | 5075 } |
| 5073 | 5076 |
| 5074 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5077 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5075 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5078 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5076 } | 5079 } |
| 5077 | 5080 |
| 5078 @end | 5081 @end |
| OLD | NEW |