Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 10831116: Move SessionStorageNamespace entirely into NavigationController and support StoragePartitions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac win compile fixes Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 d45f4df51a35ffe34f69b4c7e5f045158492940d..f34a66946bc3aa300ad4efe07b4496313a6246fd 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -413,14 +413,64 @@ 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->
GetInstalledAppForRenderer(child_process_id);
Charlie Reis 2012/08/06 20:38:30 Huh, this API doesn't make sense. There can be mu
if (installed_app && installed_app->is_storage_isolated()) {
- return installed_app->id();
+ partition_id = installed_app->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()));
Charlie Reis 2012/08/06 20:38:30 These two functions are identical except in how th
awong 2012/08/08 18:08:28 I'm not sure how I'd extract something that wouldn
Charlie Reis 2012/08/13 19:39:21 Even if we're just sharing the last few lines and
awong 2012/08/13 21:29:19 Done.
+ 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()) {
Charlie Reis 2012/08/06 20:38:30 nit: No braces.
awong 2012/08/08 18:08:28 Done.
+ 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*

Powered by Google App Engine
This is Rietveld 408576698