summaryrefslogtreecommitdiffstats
path: root/ios
diff options
context:
space:
mode:
authorstuartmorgan <stuartmorgan@chromium.org>2016-01-15 15:57:05 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-15 23:58:01 +0000
commit221cf6eb467969b9d8bcc30bf1794b65a0aa68f6 (patch)
tree54904577f2032420262e7b39349ba256552f39bd /ios
parentc6c22b78728c7f2cb353bf28931b07cf5bb5dcb8 (diff)
downloadchromium_src-221cf6eb467969b9d8bcc30bf1794b65a0aa68f6.zip
chromium_src-221cf6eb467969b9d8bcc30bf1794b65a0aa68f6.tar.gz
chromium_src-221cf6eb467969b9d8bcc30bf1794b65a0aa68f6.tar.bz2
Remove referrer code from window.open/target=_blank path
Referrer should not be plumbed through codepaths that are only for opening blank tabs; this was cruft from earlier versions that opened tabs with a specific URL. BUG=None Review URL: https://codereview.chromium.org/1592723004 Cr-Commit-Position: refs/heads/master@{#369884}
Diffstat (limited to 'ios')
-rw-r--r--ios/web/public/web_state/ui/crw_web_delegate.h4
-rw-r--r--ios/web/shell/view_controller.mm4
-rw-r--r--ios/web/web_state/ui/crw_web_controller+protected.h3
-rw-r--r--ios/web/web_state/ui/crw_web_controller.mm8
-rw-r--r--ios/web/web_state/ui/crw_web_controller_unittest.mm23
-rw-r--r--ios/web/web_state/ui/crw_wk_web_view_web_controller.mm21
6 files changed, 23 insertions, 40 deletions
diff --git a/ios/web/public/web_state/ui/crw_web_delegate.h b/ios/web/public/web_state/ui/crw_web_delegate.h
index a5821b3..5bf73c7 100644
--- a/ios/web/public/web_state/ui/crw_web_delegate.h
+++ b/ios/web/public/web_state/ui/crw_web_delegate.h
@@ -71,9 +71,7 @@ typedef void (^SSLErrorCallback)(BOOL);
// Called when the page wants to open a new window by DOM.
// CRWSessionController's openedByDOM property of the returned CRWWebController
// must be YES.
-- (CRWWebController*)webPageOrderedOpenBlankWithReferrer:
- (const web::Referrer&)referrer
- inBackground:(BOOL)inBackground;
+- (CRWWebController*)webPageOrderedOpen;
// Called when the page calls window.close() on itself. Begin the shut-down
// sequence for this controller.
diff --git a/ios/web/shell/view_controller.mm b/ios/web/shell/view_controller.mm
index f7bc351..c01c23f 100644
--- a/ios/web/shell/view_controller.mm
+++ b/ios/web/shell/view_controller.mm
@@ -286,9 +286,7 @@ NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field";
return nil;
}
-- (CRWWebController*)webPageOrderedOpenBlankWithReferrer:
- (const web::Referrer&)referrer
- inBackground:(BOOL)inBackground {
+- (CRWWebController*)webPageOrderedOpen {
return nil;
}
diff --git a/ios/web/web_state/ui/crw_web_controller+protected.h b/ios/web/web_state/ui/crw_web_controller+protected.h
index 7261210e4..bc77335 100644
--- a/ios/web/web_state/ui/crw_web_controller+protected.h
+++ b/ios/web/web_state/ui/crw_web_controller+protected.h
@@ -342,8 +342,7 @@ struct NewWindowInfo {
// Creates a new opened by DOM window and returns its autoreleased web
// controller.
-- (CRWWebController*)createChildWebControllerWithReferrerURL:
- (const GURL&)referrerURL;
+- (CRWWebController*)createChildWebController;
// Called following navigation completion to generate final navigation lifecycle
// events. Navigation is considered complete when the document has finished
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm
index 9b8ce24..2a4fb13 100644
--- a/ios/web/web_state/ui/crw_web_controller.mm
+++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -1194,12 +1194,8 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
[self.containerView displayWebViewContentView:webViewContentView];
}
-- (CRWWebController*)createChildWebControllerWithReferrerURL:
- (const GURL&)referrerURL {
- web::Referrer referrer(referrerURL, web::ReferrerPolicyDefault);
- CRWWebController* result =
- [self.delegate webPageOrderedOpenBlankWithReferrer:referrer
- inBackground:NO];
+- (CRWWebController*)createChildWebController {
+ CRWWebController* result = [self.delegate webPageOrderedOpen];
DCHECK(!result || result.sessionController.openedByDOM);
return result;
}
diff --git a/ios/web/web_state/ui/crw_web_controller_unittest.mm b/ios/web/web_state/ui/crw_web_controller_unittest.mm
index c97ebe1..ab1d48b 100644
--- a/ios/web/web_state/ui/crw_web_controller_unittest.mm
+++ b/ios/web/web_state/ui/crw_web_controller_unittest.mm
@@ -119,7 +119,7 @@ using web::NavigationManagerImpl;
@synthesize recoverable = _recoverable;
@synthesize shouldContinueCallback = _shouldContinueCallback;
-typedef void (^webPageOrderedOpenBlankBlockType)(const web::Referrer&, BOOL);
+typedef void (^webPageOrderedOpenBlankBlockType)();
typedef void (^webPageOrderedOpenBlockType)(const GURL&,
const web::Referrer&,
NSString*,
@@ -133,11 +133,8 @@ typedef void (^webPageOrderedOpenBlockType)(const GURL&,
return self;
}
-- (CRWWebController*)webPageOrderedOpenBlankWithReferrer:
- (const web::Referrer&)referrer
- inBackground:(BOOL)inBackground {
- static_cast<webPageOrderedOpenBlankBlockType>([self blockForSelector:_cmd])(
- referrer, inBackground);
+- (CRWWebController*)webPageOrderedOpen {
+ static_cast<webPageOrderedOpenBlankBlockType>([self blockForSelector:_cmd])();
return _childWebController;
}
@@ -1436,12 +1433,9 @@ TEST_F(CRWWKWebControllerWindowOpenTest, NoDelegate) {
TEST_F(CRWWKWebControllerWindowOpenTest, OpenWithUserGesture) {
CR_TEST_REQUIRES_WK_WEB_VIEW();
- SEL selector = @selector(webPageOrderedOpenBlankWithReferrer:inBackground:);
+ SEL selector = @selector(webPageOrderedOpen);
[delegate_ onSelector:selector
- callBlockExpectation:^(const web::Referrer& referrer,
- BOOL in_background) {
- EXPECT_EQ("", referrer.url.spec());
- EXPECT_FALSE(in_background);
+ callBlockExpectation:^(){
}];
[webController_ touched:YES];
@@ -1485,12 +1479,9 @@ TEST_F(CRWWKWebControllerWindowOpenTest, DontBlockPopup) {
CR_TEST_REQUIRES_WK_WEB_VIEW();
[delegate_ setBlockPopups:NO];
- SEL selector = @selector(webPageOrderedOpenBlankWithReferrer:inBackground:);
+ SEL selector = @selector(webPageOrderedOpen);
[delegate_ onSelector:selector
- callBlockExpectation:^(const web::Referrer& referrer,
- BOOL in_background) {
- EXPECT_EQ("", referrer.url.spec());
- EXPECT_FALSE(in_background);
+ callBlockExpectation:^(){
}];
EXPECT_NSEQ(@"[object Window]", OpenWindowByDOM());
diff --git a/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm b/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm
index d828b3b..5cebd46 100644
--- a/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm
+++ b/ios/web/web_state/ui/crw_wk_web_view_web_controller.mm
@@ -1972,19 +1972,20 @@ WKWebViewErrorSource WKWebViewErrorSourceFromError(NSError* error) {
forNavigationAction:(WKNavigationAction*)navigationAction
windowFeatures:(WKWindowFeatures*)windowFeatures {
GURL requestURL = net::GURLWithNSURL(navigationAction.request.URL);
- NSString* referer = GetRefererFromNavigationAction(navigationAction);
- GURL referrerURL = referer ? GURL(base::SysNSStringToUTF8(referer)) :
- [self currentURL];
- if (![self userIsInteracting] &&
- [self shouldBlockPopupWithURL:requestURL sourceURL:referrerURL]) {
- [self didBlockPopupWithURL:requestURL sourceURL:referrerURL];
- // Desktop Chrome does not return a window for the blocked popups;
- // follow the same approach by returning nil;
- return nil;
+ if (![self userIsInteracting]) {
+ NSString* referer = GetRefererFromNavigationAction(navigationAction);
+ GURL referrerURL =
+ referer ? GURL(base::SysNSStringToUTF8(referer)) : [self currentURL];
+ if ([self shouldBlockPopupWithURL:requestURL sourceURL:referrerURL]) {
+ [self didBlockPopupWithURL:requestURL sourceURL:referrerURL];
+ // Desktop Chrome does not return a window for the blocked popups;
+ // follow the same approach by returning nil;
+ return nil;
+ }
}
- id child = [self createChildWebControllerWithReferrerURL:referrerURL];
+ id child = [self createChildWebController];
// WKWebView requires WKUIDelegate to return a child view created with
// exactly the same |configuration| object (exception is raised if config is
// different). |configuration| param and config returned by