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

Side by Side Diff: chrome/browser/ui/browser_navigator.cc

Issue 20924002: Try to restore window.opener when opening blocked popups (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser_navigator.h ('k') | chrome/test/data/popup_blocker/check-opener.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "chrome/browser/ui/browser_navigator.h" 5 #include "chrome/browser/ui/browser_navigator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 }; 313 };
314 314
315 content::WebContents* CreateTargetContents(const chrome::NavigateParams& params, 315 content::WebContents* CreateTargetContents(const chrome::NavigateParams& params,
316 const GURL& url) { 316 const GURL& url) {
317 WebContents::CreateParams create_params( 317 WebContents::CreateParams create_params(
318 params.browser->profile(), 318 params.browser->profile(),
319 tab_util::GetSiteInstanceForNewTab(params.browser->profile(), url)); 319 tab_util::GetSiteInstanceForNewTab(params.browser->profile(), url));
320 if (params.source_contents) { 320 if (params.source_contents) {
321 create_params.initial_size = 321 create_params.initial_size =
322 params.source_contents->GetView()->GetContainerSize(); 322 params.source_contents->GetView()->GetContainerSize();
323 if (params.should_set_opener)
324 create_params.opener = params.source_contents;
323 } 325 }
324 #if defined(USE_AURA) 326 #if defined(USE_AURA)
325 if (params.browser->window() && 327 if (params.browser->window() &&
326 params.browser->window()->GetNativeWindow()) { 328 params.browser->window()->GetNativeWindow()) {
327 create_params.context = 329 create_params.context =
328 params.browser->window()->GetNativeWindow(); 330 params.browser->window()->GetNativeWindow();
329 } 331 }
330 #endif 332 #endif
331 333
332 content::WebContents* target_contents = WebContents::Create(create_params); 334 WebContents* target_contents = WebContents::Create(create_params);
335
333 // New tabs can have WebUI URLs that will make calls back to arbitrary 336 // New tabs can have WebUI URLs that will make calls back to arbitrary
334 // tab helpers, so the entire set of tab helpers needs to be set up 337 // tab helpers, so the entire set of tab helpers needs to be set up
335 // immediately. 338 // immediately.
336 BrowserNavigatorWebContentsAdoption::AttachTabHelpers(target_contents); 339 BrowserNavigatorWebContentsAdoption::AttachTabHelpers(target_contents);
337 extensions::TabHelper::FromWebContents(target_contents)-> 340 extensions::TabHelper::FromWebContents(target_contents)->
338 SetExtensionAppById(params.extension_app_id); 341 SetExtensionAppById(params.extension_app_id);
339 // TODO(sky): Figure out why this is needed. Without it we seem to get 342 // TODO(sky): Figure out why this is needed. Without it we seem to get
340 // failures in startup tests. 343 // failures in startup tests.
341 // By default, content believes it is not hidden. When adding contents 344 // By default, content believes it is not hidden. When adding contents
342 // in the background, tell it that it's hidden. 345 // in the background, tell it that it's hidden.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 is_renderer_initiated(false), 389 is_renderer_initiated(false),
387 tabstrip_index(-1), 390 tabstrip_index(-1),
388 tabstrip_add_types(TabStripModel::ADD_ACTIVE), 391 tabstrip_add_types(TabStripModel::ADD_ACTIVE),
389 window_action(NO_ACTION), 392 window_action(NO_ACTION),
390 user_gesture(true), 393 user_gesture(true),
391 path_behavior(RESPECT), 394 path_behavior(RESPECT),
392 ref_behavior(IGNORE_REF), 395 ref_behavior(IGNORE_REF),
393 browser(a_browser), 396 browser(a_browser),
394 initiating_profile(NULL), 397 initiating_profile(NULL),
395 host_desktop_type(GetHostDesktop(a_browser)), 398 host_desktop_type(GetHostDesktop(a_browser)),
396 should_replace_current_entry(false) { 399 should_replace_current_entry(false),
400 should_set_opener(false) {
397 } 401 }
398 402
399 NavigateParams::NavigateParams(Browser* a_browser, 403 NavigateParams::NavigateParams(Browser* a_browser,
400 WebContents* a_target_contents) 404 WebContents* a_target_contents)
401 : target_contents(a_target_contents), 405 : target_contents(a_target_contents),
402 source_contents(NULL), 406 source_contents(NULL),
403 disposition(CURRENT_TAB), 407 disposition(CURRENT_TAB),
404 transition(content::PAGE_TRANSITION_LINK), 408 transition(content::PAGE_TRANSITION_LINK),
405 is_renderer_initiated(false), 409 is_renderer_initiated(false),
406 tabstrip_index(-1), 410 tabstrip_index(-1),
407 tabstrip_add_types(TabStripModel::ADD_ACTIVE), 411 tabstrip_add_types(TabStripModel::ADD_ACTIVE),
408 window_action(NO_ACTION), 412 window_action(NO_ACTION),
409 user_gesture(true), 413 user_gesture(true),
410 path_behavior(RESPECT), 414 path_behavior(RESPECT),
411 ref_behavior(IGNORE_REF), 415 ref_behavior(IGNORE_REF),
412 browser(a_browser), 416 browser(a_browser),
413 initiating_profile(NULL), 417 initiating_profile(NULL),
414 host_desktop_type(GetHostDesktop(a_browser)), 418 host_desktop_type(GetHostDesktop(a_browser)),
415 should_replace_current_entry(false) { 419 should_replace_current_entry(false),
420 should_set_opener(false) {
416 } 421 }
417 422
418 NavigateParams::NavigateParams(Profile* a_profile, 423 NavigateParams::NavigateParams(Profile* a_profile,
419 const GURL& a_url, 424 const GURL& a_url,
420 content::PageTransition a_transition) 425 content::PageTransition a_transition)
421 : url(a_url), 426 : url(a_url),
422 target_contents(NULL), 427 target_contents(NULL),
423 source_contents(NULL), 428 source_contents(NULL),
424 disposition(NEW_FOREGROUND_TAB), 429 disposition(NEW_FOREGROUND_TAB),
425 transition(a_transition), 430 transition(a_transition),
426 is_renderer_initiated(false), 431 is_renderer_initiated(false),
427 tabstrip_index(-1), 432 tabstrip_index(-1),
428 tabstrip_add_types(TabStripModel::ADD_ACTIVE), 433 tabstrip_add_types(TabStripModel::ADD_ACTIVE),
429 window_action(SHOW_WINDOW), 434 window_action(SHOW_WINDOW),
430 user_gesture(true), 435 user_gesture(true),
431 path_behavior(RESPECT), 436 path_behavior(RESPECT),
432 ref_behavior(IGNORE_REF), 437 ref_behavior(IGNORE_REF),
433 browser(NULL), 438 browser(NULL),
434 initiating_profile(a_profile), 439 initiating_profile(a_profile),
435 host_desktop_type(chrome::GetActiveDesktop()), 440 host_desktop_type(chrome::GetActiveDesktop()),
436 should_replace_current_entry(false) { 441 should_replace_current_entry(false),
442 should_set_opener(false) {
437 } 443 }
438 444
439 NavigateParams::~NavigateParams() {} 445 NavigateParams::~NavigateParams() {}
440 446
441 void FillNavigateParamsFromOpenURLParams(chrome::NavigateParams* nav_params, 447 void FillNavigateParamsFromOpenURLParams(chrome::NavigateParams* nav_params,
442 const content::OpenURLParams& params) { 448 const content::OpenURLParams& params) {
443 nav_params->referrer = params.referrer; 449 nav_params->referrer = params.referrer;
444 nav_params->extra_headers = params.extra_headers; 450 nav_params->extra_headers = params.extra_headers;
445 nav_params->disposition = params.disposition; 451 nav_params->disposition = params.disposition;
446 nav_params->override_encoding = params.override_encoding; 452 nav_params->override_encoding = params.override_encoding;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 bool reverse_on_redirect = false; 676 bool reverse_on_redirect = false;
671 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( 677 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary(
672 &rewritten_url, browser_context, &reverse_on_redirect); 678 &rewritten_url, browser_context, &reverse_on_redirect);
673 679
674 // Some URLs are mapped to uber subpages. Do not allow them in incognito. 680 // Some URLs are mapped to uber subpages. Do not allow them in incognito.
675 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && 681 return !(rewritten_url.scheme() == chrome::kChromeUIScheme &&
676 rewritten_url.host() == chrome::kChromeUIUberHost); 682 rewritten_url.host() == chrome::kChromeUIUberHost);
677 } 683 }
678 684
679 } // namespace chrome 685 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_navigator.h ('k') | chrome/test/data/popup_blocker/check-opener.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698