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

Unified Diff: chrome/browser/ui/browser_navigator.cc

Issue 2921753002: NOT YET READY: Making chrome.windows.create establish an actual "opener" relationship.
Patch Set: Adding setSelfAsOpener parameter. Created 3 years, 6 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
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_test.cc ('k') | chrome/browser/ui/browser_navigator_params.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser_navigator.cc
diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc
index abf993f818697581907ccd20f65fb0941d6c09be..83ca1d74092de1f23de08defd81766fa7ef02ae6 100644
--- a/chrome/browser/ui/browser_navigator.cc
+++ b/chrome/browser/ui/browser_navigator.cc
@@ -5,6 +5,8 @@
#include "chrome/browser/ui/browser_navigator.h"
#include <algorithm>
+#include <memory>
+#include <string>
#include "base/command_line.h"
#include "base/macros.h"
@@ -34,6 +36,8 @@
#include "content/public/browser/browser_url_handler.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "extensions/features/features.h"
@@ -356,12 +360,24 @@ class ScopedTargetContentsOwner {
content::WebContents* CreateTargetContents(const chrome::NavigateParams& params,
const GURL& url) {
+ // If |params.opener| is present, then (initially) put the new contents in the
+ // same process as the opener. Note that this is only "initial" placement
+ // (i.e. if subsequent navigation [including the initial navigation] triggers
+ // a cross-process transfer, then the opener and new contents can end up in
+ // separate processes).
+ scoped_refptr<content::SiteInstance> initial_site_instance_for_new_contents =
+ params.opener
+ ? params.opener->GetSiteInstance()
+ : tab_util::GetSiteInstanceForNewTab(params.browser->profile(), url);
+
WebContents::CreateParams create_params(
- params.browser->profile(),
- params.source_site_instance && !params.force_new_process_for_new_contents
- ? params.source_site_instance
- : tab_util::GetSiteInstanceForNewTab(params.browser->profile(), url));
+ params.browser->profile(), initial_site_instance_for_new_contents);
create_params.main_frame_name = params.frame_name;
+ if (params.opener) {
+ create_params.opener_render_frame_id = params.opener->GetRoutingID();
+ create_params.opener_render_process_id =
+ params.opener->GetProcess()->GetID();
+ }
if (params.source_contents) {
create_params.initial_size =
params.source_contents->GetContainerBounds().size();
@@ -473,6 +489,7 @@ void Navigate(NavigateParams* params) {
if (GetSourceProfile(params) != params->browser->profile()) {
// A tab is being opened from a link from a different profile, we must reset
// source information that may cause state to be shared.
+ params->opener = nullptr;
params->source_contents = nullptr;
params->source_site_instance = nullptr;
params->referrer = content::Referrer();
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_test.cc ('k') | chrome/browser/ui/browser_navigator_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698