Chromium Code Reviews| Index: chrome/browser/ui/browser_navigator.cc |
| diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc |
| index 72505692db50fb265dc6bf352d0ffa1524e72157..6971036362d28314e787be02ab3483d39ad24b4b 100644 |
| --- a/chrome/browser/ui/browser_navigator.cc |
| +++ b/chrome/browser/ui/browser_navigator.cc |
| @@ -37,6 +37,9 @@ |
| #include "content/public/browser/browser_url_handler.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/browser/render_view_host.h" |
| +#include "content/public/browser/session_storage_namespace.h" |
| +#include "content/public/browser/site_instance.h" |
| +#include "content/public/browser/storage_partition.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/browser/web_contents_view.h" |
| @@ -329,7 +332,37 @@ content::WebContents* CreateTargetContents(const chrome::NavigateParams& params, |
| } |
| #endif |
| - content::WebContents* target_contents = WebContents::Create(create_params); |
| + content::SessionStorageNamespaceMap namespace_map; |
| + if (params.source_contents && params.should_copy_session_storage_namespace) { |
| + Profile* source_profile = Profile::FromBrowserContext( |
| + params.source_contents->GetBrowserContext()); |
| + // TODO(jochen): once we use more than two storage partitions in chrome, we |
| + // will need to revise this logic to clone the session storage namespace in |
| + // the correct partition. For now, using the opener site instance to |
| + // determine the storage partition is always ok. |
|
awong
2013/07/31 18:58:59
This can never happen now. Each RenderViewHost sho
|
| + content::SiteInstance* site_instance = |
| + params.source_contents->GetSiteInstance(); |
| + |
| + // Compare to RenderMessageFilter::OnCreateWindow() and |
| + // WebContentsImpl::CreateNewWindow(). |
| + std::string partition_id = source_profile->GetStoragePartitionIdForSite( |
| + site_instance->GetSiteURL()); |
| + content::StoragePartition* partition = |
| + content::BrowserContext::GetStoragePartition(source_profile, |
| + site_instance); |
| + content::SessionStorageNamespaceMap::const_iterator old_namespace = |
| + params.source_contents->GetController().GetSessionStorageNamespaceMap() |
| + .find(partition_id); |
| + scoped_refptr<content::SessionStorageNamespace> cloned_namespace = |
| + content::SessionStorageNamespace::Clone( |
| + partition->GetDOMStorageContext(), old_namespace->second.get()); |
| + namespace_map.insert(make_pair(partition_id, cloned_namespace)); |
|
awong
2013/07/31 18:58:59
We should remove the SessionStorageNamespaceMap, w
|
| + } |
| + WebContents* target_contents = WebContents::CreateWithSessionStorage( |
| + create_params, |
| + namespace_map, |
| + params.should_set_opener ? params.source_contents : NULL); |
| + |
| // New tabs can have WebUI URLs that will make calls back to arbitrary |
| // tab helpers, so the entire set of tab helpers needs to be set up |
| // immediately. |
| @@ -393,7 +426,9 @@ NavigateParams::NavigateParams(Browser* a_browser, |
| browser(a_browser), |
| initiating_profile(NULL), |
| host_desktop_type(GetHostDesktop(a_browser)), |
| - should_replace_current_entry(false) { |
| + should_replace_current_entry(false), |
| + should_copy_session_storage_namespace(false), |
| + should_set_opener(false) { |
| } |
| NavigateParams::NavigateParams(Browser* a_browser, |
| @@ -412,7 +447,9 @@ NavigateParams::NavigateParams(Browser* a_browser, |
| browser(a_browser), |
| initiating_profile(NULL), |
| host_desktop_type(GetHostDesktop(a_browser)), |
| - should_replace_current_entry(false) { |
| + should_replace_current_entry(false), |
| + should_copy_session_storage_namespace(false), |
| + should_set_opener(false) { |
| } |
| NavigateParams::NavigateParams(Profile* a_profile, |
| @@ -433,7 +470,9 @@ NavigateParams::NavigateParams(Profile* a_profile, |
| browser(NULL), |
| initiating_profile(a_profile), |
| host_desktop_type(chrome::GetActiveDesktop()), |
| - should_replace_current_entry(false) { |
| + should_replace_current_entry(false), |
| + should_copy_session_storage_namespace(false), |
| + should_set_opener(false) { |
| } |
| NavigateParams::~NavigateParams() {} |