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

Unified Diff: content/shell/browser/shell.cc

Issue 2417983002: Form submissions opening in a new window don't need special treatment anymore. (Closed)
Patch Set: Using params.source_site_instance for consistency with //chrome layer. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/shell/browser/shell.cc
diff --git a/content/shell/browser/shell.cc b/content/shell/browser/shell.cc
index a214d2a61a115dee8bce6f6fef68deda6a2b5185..9128b1e2269384e0aa3d1d7f382c3b5e4df667cf 100644
--- a/content/shell/browser/shell.cc
+++ b/content/shell/browser/shell.cc
@@ -176,7 +176,7 @@ gfx::Size Shell::AdjustWindowSize(const gfx::Size& initial_size) {
Shell* Shell::CreateNewWindow(BrowserContext* browser_context,
const GURL& url,
- SiteInstance* site_instance,
+ const scoped_refptr<SiteInstance>& site_instance,
const gfx::Size& initial_size) {
WebContents::CreateParams create_params(browser_context, site_instance);
create_params.initial_size = AdjustWindowSize(initial_size);
@@ -312,9 +312,46 @@ gfx::NativeView Shell::GetContentView() {
WebContents* Shell::OpenURLFromTab(WebContents* source,
const OpenURLParams& params) {
- // This implementation only handles CURRENT_TAB.
- if (params.disposition != WindowOpenDisposition::CURRENT_TAB)
- return nullptr;
+ WebContents* target = nullptr;
+ switch (params.disposition) {
+ case WindowOpenDisposition::CURRENT_TAB:
+ target = source;
+ break;
+
+ // Normally, the difference between NEW_POPUP and NEW_WINDOW is that a popup
+ // should have no toolbar, no status bar, no menu bar, no scrollbars and be
+ // not resizable. For simplicity and to enable new testing scenarios in
+ // content shell and layout tests, popups don't get special treatment below
+ // (i.e. they will have a toolbar and other things described here).
+ case WindowOpenDisposition::NEW_POPUP:
+ case WindowOpenDisposition::NEW_WINDOW: {
+ Shell* new_window =
+ Shell::CreateNewWindow(source->GetBrowserContext(),
+ GURL(), // Don't load anything just yet.
+ params.source_site_instance,
Łukasz Anforowicz 2016/10/20 22:56:42 Using |params.source_site_instance| is consistent
nasko 2016/10/21 16:32:47 Acknowledged.
+ gfx::Size()); // Use default size.
+ target = new_window->web_contents();
+ if (switches::IsRunLayoutTestSwitchPresent())
+ SecondaryTestWindowObserver::CreateForWebContents(target);
+ break;
+ }
+
+ // No tabs in content_shell:
+ case WindowOpenDisposition::SINGLETON_TAB:
+ case WindowOpenDisposition::NEW_FOREGROUND_TAB:
+ case WindowOpenDisposition::NEW_BACKGROUND_TAB:
+ // No incognito mode in content_shell:
+ case WindowOpenDisposition::OFF_THE_RECORD:
+ // TODO(lukasza): Investigate if some layout tests might need support for
+ // SAVE_TO_DISK disposition. This would probably require that
+ // BlinkTestController always sets up and cleans up a temporary directory
+ // as the default downloads destinations for the duration of a test.
+ case WindowOpenDisposition::SAVE_TO_DISK:
+ // Ignoring requests with disposition == IGNORE_ACTION...
+ case WindowOpenDisposition::IGNORE_ACTION:
+ default:
+ return nullptr;
+ }
NavigationController::LoadURLParams load_url_params(params.url);
load_url_params.source_site_instance = params.source_site_instance;
@@ -332,8 +369,8 @@ WebContents* Shell::OpenURLFromTab(WebContents* source,
load_url_params.post_data = params.post_data;
}
- source->GetController().LoadURLWithParams(load_url_params);
- return source;
+ target->GetController().LoadURLWithParams(load_url_params);
+ return target;
}
void Shell::LoadingStateChanged(WebContents* source,

Powered by Google App Engine
This is Rietveld 408576698