| 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 9f4c3a30440df5669cb6ef8f9bdf64ca8057ce3b..985bda4de4319cadd4cdfdc764e34e1d1c1ca369 100644
|
| --- a/chrome/browser/chrome_content_browser_client.cc
|
| +++ b/chrome/browser/chrome_content_browser_client.cc
|
| @@ -413,14 +413,63 @@ std::string ChromeContentBrowserClient::GetStoragePartitionIdForChildProcess(
|
| Profile* profile = Profile::FromBrowserContext(browser_context);
|
| ExtensionService* extension_service =
|
| extensions::ExtensionSystem::Get(profile)->extension_service();
|
| + std::string partition_id;
|
| if (extension_service) {
|
| - const extensions::Extension* installed_app = extension_service->
|
| + const extensions::Extension* extension = extension_service->
|
| GetInstalledAppForRenderer(child_process_id);
|
| - if (installed_app && installed_app->is_storage_isolated()) {
|
| - return installed_app->id();
|
| + if (extension && extension->is_storage_isolated()) {
|
| + partition_id = extension->id();
|
| }
|
| }
|
| - return std::string();
|
| +
|
| + // Enforce that IsValidStoragePartitionId() implementation stays in sync.
|
| + DCHECK(IsValidStoragePartitionId(browser_context, partition_id));
|
| + return partition_id;
|
| +}
|
| +
|
| +std::string ChromeContentBrowserClient::GetStoragePartitionIdForSiteInstance(
|
| + content::BrowserContext* browser_context,
|
| + SiteInstance* instance) {
|
| + // In chrome, we use the extension ID as the partition ID. This works well
|
| + // because the extension ID fits the partition ID pattern and currently only
|
| + // apps can designate that storage should be isolated.
|
| + Profile* profile = Profile::FromBrowserContext(browser_context);
|
| + ExtensionService* extension_service =
|
| + extensions::ExtensionSystem::Get(profile)->extension_service();
|
| + std::string partition_id;
|
| + if (extension_service) {
|
| + const Extension* extension = extension_service->extensions()->
|
| + GetExtensionOrAppByURL(ExtensionURLInfo(instance->GetSite()));
|
| + if (extension && extension->is_storage_isolated()) {
|
| + partition_id = extension->id();
|
| + }
|
| + }
|
| +
|
| + // Enforce that IsValidStoragePartitionId() implementation stays in sync.
|
| + DCHECK(IsValidStoragePartitionId(browser_context, partition_id));
|
| + return partition_id;
|
| +}
|
| +
|
| +bool ChromeContentBrowserClient::IsValidStoragePartitionId(
|
| + content::BrowserContext* browser_context,
|
| + const std::string& partition_id) {
|
| + // The default ID is empty which is always allowed.
|
| + if (partition_id.empty())
|
| + return true;
|
| +
|
| + // If it isn't empty, then it must belong to an extension of some sort. Parse
|
| + // out the extension ID and make sure it is still installed.
|
| + Profile* profile = Profile::FromBrowserContext(browser_context);
|
| + ExtensionService* extension_service =
|
| + extensions::ExtensionSystem::Get(profile)->extension_service();
|
| + if (!extension_service) {
|
| + // No extension service means no storage partitions in Chrome.
|
| + return false;
|
| + }
|
| +
|
| + // See if we can find an extension. The |partition_id| is the extension ID so
|
| + // no parsing needed to be done.
|
| + return extension_service->GetExtensionById(partition_id, false) != NULL;
|
| }
|
|
|
| content::WebContentsViewDelegate*
|
|
|