Chromium Code Reviews| Index: chrome/browser/chrome_content_browser_client.cc |
| diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc |
| index 677ab1f5bd7e5e336678ff0f004c181ea28d2404..6af8e23d6d3a617bd21c83e2d47b363b00e121e4 100644 |
| --- a/chrome/browser/chrome_content_browser_client.cc |
| +++ b/chrome/browser/chrome_content_browser_client.cc |
| @@ -504,6 +504,38 @@ void ChromeContentBrowserClient::GetStoragePartitionConfigForSite( |
| std::string* partition_domain, |
| std::string* partition_name, |
| bool* in_memory) { |
| + // Handle sites that may not use the default storage partition. |
| + if (site.SchemeIs(chrome::kGuestScheme)) { |
| + ParseNonDefaultStoragePartitionConfig(site, partition_domain, |
| + partition_name, in_memory); |
|
Charlie Reis
2012/11/16 01:45:10
nit: Wrong indent.
|
| + return; |
| + } |
| + |
| + const Extension* extension = NULL; |
| + Profile* profile = Profile::FromBrowserContext(browser_context); |
| + ExtensionService* extension_service = |
| + extensions::ExtensionSystem::Get(profile)->extension_service(); |
| + if (extension_service) { |
| + extension = extension_service->extensions()-> |
| + GetExtensionOrAppByURL(ExtensionURLInfo(site)); |
| + if (extension && extension->is_storage_isolated()) { |
| + ParseNonDefaultStoragePartitionConfig(site, partition_domain, |
| + partition_name, in_memory); |
| + return; |
| + } |
| + } |
| + |
| + // All other cases use the default, browser-wide, storage partition. |
| + partition_domain->clear(); |
| + partition_name->clear(); |
| + *in_memory = false; |
| +} |
| + |
| +void ChromeContentBrowserClient::ParseNonDefaultStoragePartitionConfig( |
| + const GURL& site, |
| + std::string* partition_domain, |
| + std::string* partition_name, |
| + bool* in_memory) { |
| // For the webview tag, we create special guest processes, which host the |
| // tag content separately from the main application that embeds the tag. |
| // A webview tag can specify both the partition name and whether the storage |
| @@ -523,30 +555,21 @@ void ChromeContentBrowserClient::GetStoragePartitionConfigForSite( |
| // URL was created, so it needs to be decoded. |
| *partition_name = net::UnescapeURLComponent(site.query(), |
| net::UnescapeRule::NORMAL); |
| + } else if (site.SchemeIs(extensions::kExtensionScheme)) { |
| + CHECK(site.has_host()); |
| + // This function assumes the extension has isolated storage. For such sites, |
| + // the host of the |site| is the |partition_domain|. The |in_memory| and |
| + // |partition_name| are only used in guest schemes so they are cleared |
| + // here. |
| + *partition_domain = site.host(); |
| + *in_memory = false; |
| + partition_name->clear(); |
| + } else { |
| + // Serious logic error if this is being called on a |site| with an |
| + // unexpected format. |
| + LOG(FATAL) << "site has unexpected format: " << site; |
| return; |
| } |
| - |
| - const Extension* extension = NULL; |
| - Profile* profile = Profile::FromBrowserContext(browser_context); |
| - ExtensionService* extension_service = |
| - extensions::ExtensionSystem::Get(profile)->extension_service(); |
| - if (extension_service) { |
| - extension = extension_service->extensions()-> |
| - GetExtensionOrAppByURL(ExtensionURLInfo(site)); |
| - if (extension && extension->is_storage_isolated()) { |
| - // Extensions which have storage isolation enabled (e.g., apps), use |
| - // the extension id as the |partition_domain|. |
| - *partition_domain = extension->id(); |
| - partition_name->clear(); |
| - *in_memory = false; |
| - return; |
| - } |
| - } |
| - |
| - // All other cases use the default, browser-wide, storage partition. |
| - partition_domain->clear(); |
| - partition_name->clear(); |
| - *in_memory = false; |
| } |
| content::WebContentsViewDelegate* |