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

Unified Diff: content/browser/tab_contents/tab_contents_view_helper.cc

Issue 9325082: Create window in a new BrowsingInstance when opening a link in a new process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix line break Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_helper.cc ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/tab_contents/tab_contents_view_helper.cc
diff --git a/content/browser/tab_contents/tab_contents_view_helper.cc b/content/browser/tab_contents/tab_contents_view_helper.cc
index 69c21c190ae210070056f7bd1e062f3221ca647e..6038e724f21316645e7bacf4ad474778dae6ea1d 100644
--- a/content/browser/tab_contents/tab_contents_view_helper.cc
+++ b/content/browser/tab_contents/tab_contents_view_helper.cc
@@ -12,6 +12,7 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
+#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_view.h"
@@ -59,16 +60,43 @@ TabContents* TabContentsViewHelper::CreateNewWindow(
if (!should_create)
return NULL;
+ // We usually create the new window in the same BrowsingInstance (group of
+ // script-related windows), by passing in the current SiteInstance. However,
+ // if the opener is being suppressed, we create a new SiteInstance in its own
+ // BrowsingInstance.
+ scoped_refptr<content::SiteInstance> site_instance =
+ params.opener_suppressed ?
+ content::SiteInstance::Create(web_contents->GetBrowserContext()) :
+ web_contents->GetSiteInstance();
+
// Create the new web contents. This will automatically create the new
// WebContentsView. In the future, we may want to create the view separately.
TabContents* new_contents =
new TabContents(web_contents->GetBrowserContext(),
- web_contents->GetSiteInstance(),
+ site_instance,
route_id,
static_cast<TabContents*>(web_contents),
NULL);
new_contents->set_opener_web_ui_type(
web_contents->GetWebUITypeForCurrentState());
+
+ if (params.opener_suppressed) {
+ // When the opener is suppressed, the original renderer cannot access the
+ // new window. As a result, we need to show and navigate the window here.
+ gfx::Rect initial_pos;
+ web_contents->AddNewContents(new_contents,
+ params.disposition,
+ initial_pos,
+ params.user_gesture);
+ content::OpenURLParams open_params(params.target_url, content::Referrer(),
+ CURRENT_TAB,
+ content::PAGE_TRANSITION_LINK,
+ true /* is_renderer_initiated */);
+ WebContents* opened_contents = new_contents->OpenURL(open_params);
+ DCHECK_EQ(new_contents, opened_contents);
+ return new_contents;
+ }
+
content::WebContentsView* new_view = new_contents->GetView();
// TODO(brettw): It seems bogus that we have to call this function on the
@@ -76,6 +104,7 @@ TabContents* TabContentsViewHelper::CreateNewWindow(
new_view->CreateViewForWidget(new_contents->GetRenderViewHost());
// Save the created window associated with the route so we can show it later.
+ DCHECK_NE(MSG_ROUTING_NONE, route_id);
pending_contents_[route_id] = new_contents;
if (web_contents->GetDelegate())
« no previous file with comments | « content/browser/renderer_host/render_widget_helper.cc ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698