Chromium Code Reviews| Index: content/browser/web_contents/web_contents_impl.cc |
| diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc |
| index fe34bc0ef8a11d9eafcc62fa09f5e9829945b869..8d2a92f831dd0da8499e139df606c195f4f2746c 100644 |
| --- a/content/browser/web_contents/web_contents_impl.cc |
| +++ b/content/browser/web_contents/web_contents_impl.cc |
| @@ -287,6 +287,46 @@ WebContents* WebContents::CreateWithSessionStorage( |
| return new_contents; |
| } |
| +// static |
| +WebContents* WebContents::CreateWithOpener( |
| + const WebContents::CreateParams& params, |
| + WebContents* opener, |
| + bool propagate_opener) { |
|
Charlie Reis
2013/07/30 01:26:30
Why switch from suppress_opener, which is used com
|
| + WebContentsImpl* new_contents = new WebContentsImpl( |
| + params.browser_context, |
| + propagate_opener ? static_cast<WebContentsImpl*>(opener) : NULL); |
| + |
| + if (opener) { |
| + // To clone the session storage namespace, we need a site instance. |
| + CHECK(params.site_instance); |
|
Bernhard Bauer
2013/07/30 08:34:50
I assume you have good reasons for using a CHECK o
|
| + |
| + // It's not possible to use a guest as opener. |
|
Charlie Reis
2013/07/30 01:26:30
That's not true. Fady changed WebContentsImpl::Cr
|
| + CHECK(!opener->GetRenderProcessHost()->IsGuest()); |
| + |
| + // Clone the session storage namespace of the opener. |
|
Charlie Reis
2013/07/30 01:26:30
This code only copies the session storage namespac
jochen (gone - plz use gerrit)
2013/07/30 14:50:39
No. it clones it (see line 320).
Charlie Reis
2013/07/31 17:16:16
You're only cloning a single SessionStorageNamespa
|
| + const std::string& partition_id = |
| + GetContentClient()->browser()-> |
|
Bernhard Bauer
2013/07/30 08:34:50
Nit: This needs to be indented four spaces more.
|
| + GetStoragePartitionIdForSite(opener->GetBrowserContext(), |
| + params.site_instance->GetSiteURL()); |
| + StoragePartition* partition = BrowserContext::GetStoragePartition( |
| + opener->GetBrowserContext(), params.site_instance); |
| + DOMStorageContextImpl* dom_storage_context = |
| + static_cast<DOMStorageContextImpl*>(partition->GetDOMStorageContext()); |
| + SessionStorageNamespaceMap::const_iterator old_namespace = opener |
| + ->GetController().GetSessionStorageNamespaceMap().find(partition_id); |
|
Charlie Reis
2013/07/30 01:26:30
nit: Please be consistent about -> being at the en
|
| + CHECK(old_namespace != |
| + opener->GetController().GetSessionStorageNamespaceMap().end()); |
|
Bernhard Bauer
2013/07/30 08:34:50
If the partition ID isn't found, you'll crash late
|
| + scoped_refptr<SessionStorageNamespaceImpl> cloned_namespace = |
| + new SessionStorageNamespaceImpl(dom_storage_context, |
| + old_namespace->second->id()); |
| + new_contents->GetController() |
| + .SetSessionStorageNamespace(partition_id, cloned_namespace.get()); |
| + } |
| + |
| + new_contents->Init(params); |
| + return new_contents; |
| +} |
| + |
| void WebContents::AddCreatedCallback(const CreatedCallback& callback) { |
| g_created_callbacks.Get().push_back(callback); |
| } |