| 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())
|
|
|