Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Side by Side Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2709383002: Do not load about:blank if iframe requested to load invalid URL. (Closed)
Patch Set: Corrected frame check Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4461 matching lines...) Expand 10 before | Expand all | Expand 10 after
4472 decisionHandler(WKNavigationActionPolicyCancel); 4472 decisionHandler(WKNavigationActionPolicyCancel);
4473 return; 4473 return;
4474 } 4474 }
4475 4475
4476 // The page will not be changed until this navigation is commited, so the 4476 // The page will not be changed until this navigation is commited, so the
4477 // retrieved state will be pending until |didCommitNavigation| callback. 4477 // retrieved state will be pending until |didCommitNavigation| callback.
4478 [self updatePendingNavigationInfoFromNavigationAction:action]; 4478 [self updatePendingNavigationInfoFromNavigationAction:action];
4479 4479
4480 // Invalid URLs should not be loaded. However, simply doing nothing upon 4480 // Invalid URLs should not be loaded. However, simply doing nothing upon
4481 // tapping a link or button is a jarring user experience. Instead, cancel 4481 // tapping a link or button is a jarring user experience. Instead, cancel
4482 // the invalid navigation and load about:blank. 4482 // the invalid navigation and load about:blank if navigation was requested for
4483 // the main frame.
4483 GURL requestURL = net::GURLWithNSURL(action.request.URL); 4484 GURL requestURL = net::GURLWithNSURL(action.request.URL);
4484 if (!requestURL.is_valid()) { 4485 if (!requestURL.is_valid()) {
4485 decisionHandler(WKNavigationActionPolicyCancel); 4486 decisionHandler(WKNavigationActionPolicyCancel);
4486 GURL aboutBlankURL(url::kAboutBlankURL); 4487 if (action.targetFrame.mainFrame) {
4487 web::NavigationManager::WebLoadParams loadParams(aboutBlankURL); 4488 GURL aboutBlankURL(url::kAboutBlankURL);
4488 loadParams.referrer = [self currentReferrer]; 4489 web::NavigationManager::WebLoadParams loadParams(aboutBlankURL);
4489 self.webState->GetNavigationManager()->LoadURLWithParams(loadParams); 4490 loadParams.referrer = [self currentReferrer];
4491 self.webState->GetNavigationManager()->LoadURLWithParams(loadParams);
4492 }
4490 return; 4493 return;
4491 } 4494 }
4492 4495
4493 BOOL allowLoad = [self shouldAllowLoadWithNavigationAction:action]; 4496 BOOL allowLoad = [self shouldAllowLoadWithNavigationAction:action];
4494 4497
4495 if (allowLoad) { 4498 if (allowLoad) {
4496 allowLoad = self.webStateImpl->ShouldAllowRequest(action.request); 4499 allowLoad = self.webStateImpl->ShouldAllowRequest(action.request);
4497 if (!allowLoad && action.targetFrame.mainFrame) { 4500 if (!allowLoad && action.targetFrame.mainFrame) {
4498 [_pendingNavigationInfo setCancelled:YES]; 4501 [_pendingNavigationInfo setCancelled:YES];
4499 } 4502 }
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
5244 - (void)simulateLoadRequestWithURL:(const GURL&)URL { 5247 - (void)simulateLoadRequestWithURL:(const GURL&)URL {
5245 _lastRegisteredRequestURL = URL; 5248 _lastRegisteredRequestURL = URL;
5246 _loadPhase = web::LOAD_REQUESTED; 5249 _loadPhase = web::LOAD_REQUESTED;
5247 } 5250 }
5248 5251
5249 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5252 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5250 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5253 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5251 } 5254 }
5252 5255
5253 @end 5256 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698