summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chrome_content_browser_client.cc
diff options
context:
space:
mode:
authorcreis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-17 12:20:10 +0000
committercreis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-17 12:20:10 +0000
commit14acc6453fa956c279b2b788e00f937e23d951b3 (patch)
tree04df34881382e794d7218af42a62aa43df57e5e2 /chrome/browser/chrome_content_browser_client.cc
parent3df6cdbbdec79e947aeadfbb360c755b7790a637 (diff)
downloadchromium_src-14acc6453fa956c279b2b788e00f937e23d951b3.zip
chromium_src-14acc6453fa956c279b2b788e00f937e23d951b3.tar.gz
chromium_src-14acc6453fa956c279b2b788e00f937e23d951b3.tar.bz2
Implement the ability to obliterate a storage partition from disk.
On the uninstall of an extension with isolated storage, we want to delete all the data for the extension from disk as soon as possible. Because we cannot know when various objects with state on disk (eg., FileSystemContext) have all been deleted, we do a best-effort delete for any directory that we know isn't being used. The way this gets projected into the content modulue is that each extension defines one partition_domain. If an extension has a <webview> tag, it will also have multiple StoragePartitions, each with a different partition_name. If it doesn't have a <webview> tag, the partition_name is considered empty which yields the default partition. The default partition, and all webview partitions are peers inside the partition_domain's root directory. This CL introduces a function that allows us to delete partiton domain. Special care is taken to not accidentally instantiate a StoragePartition for the domain if none current exists. This is necessary to allow us to actually delete the whole partition domain directory. (Patch by ajwong@chromium.org) BUG=85127 Review URL: https://chromiumcodereview.appspot.com/11280030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chrome_content_browser_client.cc')
-rw-r--r--chrome/browser/chrome_content_browser_client.cc59
1 files changed, 40 insertions, 19 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 450a7ab..cd5048a 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -501,9 +501,16 @@ bool ChromeContentBrowserClient::IsValidStoragePartitionId(
void ChromeContentBrowserClient::GetStoragePartitionConfigForSite(
content::BrowserContext* browser_context,
const GURL& site,
+ bool can_be_default,
std::string* partition_domain,
std::string* partition_name,
bool* in_memory) {
+ // Default to the browser-wide storage partition and override based on |site|
+ // below.
+ partition_domain->clear();
+ partition_name->clear();
+ *in_memory = false;
+
// 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 +530,44 @@ void ChromeContentBrowserClient::GetStoragePartitionConfigForSite(
// URL was created, so it needs to be decoded.
*partition_name = net::UnescapeURLComponent(site.query(),
net::UnescapeRule::NORMAL);
- return;
- }
+ } else if (site.SchemeIs(extensions::kExtensionScheme)) {
+ // If |can_be_default| is false, the caller is stating that the |site|
+ // should be parsed as if it had isolated storage. In particular it is
+ // important to NOT check ExtensionService for the is_storage_isolated()
+ // attribute because this code path is run during Extension uninstall
+ // to do cleanup after the Extension has already been unloaded from the
+ // ExtensionService.
+ bool is_isolated = !can_be_default;
+ if (can_be_default) {
+ 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()) {
+ is_isolated = true;
+ }
+ }
+ }
- 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();
+ if (is_isolated) {
+ CHECK(site.has_host());
+ // For extensions with isolated storage, the 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;
- return;
+ partition_name->clear();
}
}
- // All other cases use the default, browser-wide, storage partition.
- partition_domain->clear();
- partition_name->clear();
- *in_memory = false;
+ // Assert that if |can_be_default| is false, the code above must have found a
+ // non-default partition. If this fails, the caller has a serious logic
+ // error about which StoragePartition they expect to be in and it is not
+ // safe to continue.
+ CHECK(can_be_default || !partition_domain->empty());
}
content::WebContentsViewDelegate*