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

Unified Diff: chrome/browser/extensions/data_deleter.cc

Issue 123733003: Get ride of chrome.storage.* data when removing an application. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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
« no previous file with comments | « chrome/browser/extensions/data_deleter.h ('k') | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/data_deleter.cc
diff --git a/chrome/browser/extensions/data_deleter.cc b/chrome/browser/extensions/data_deleter.cc
index c0947f8722e6083ae1aef26b3c8a9b4183072433..983182e9fa97aa0b5d433dd2cc785ca325637263 100644
--- a/chrome/browser/extensions/data_deleter.cc
+++ b/chrome/browser/extensions/data_deleter.cc
@@ -6,33 +6,35 @@
#include "chrome/browser/extensions/api/storage/settings_frontend.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_special_storage_policy.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
+#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/site_instance.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "net/url_request/url_request_context_getter.h"
+using base::WeakPtr;
using content::BrowserContext;
using content::BrowserThread;
using content::StoragePartition;
-namespace extensions {
+namespace {
-// static
-void DataDeleter::StartDeleting(Profile* profile,
- const std::string& extension_id,
- const GURL& storage_origin) {
+// Helper function that deletes data of a given |storage_origin| in a given
+// |partition|.
+void DeleteOrigin(Profile* profile,
+ StoragePartition* partition,
+ const GURL& origin) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(profile);
+ DCHECK(partition);
- const GURL& site = Extension::GetBaseURLFromExtensionId(extension_id);
-
- StoragePartition* partition =
- BrowserContext::GetStoragePartitionForSite(profile, site);
-
- if (storage_origin.SchemeIs(extensions::kExtensionScheme)) {
+ if (origin.SchemeIs(extensions::kExtensionScheme)) {
// TODO(ajwong): Cookies are not properly isolated for
// chrome-extension:// scheme. (http://crbug.com/158386).
//
@@ -46,7 +48,7 @@ void DataDeleter::StartDeleting(Profile* profile,
StoragePartition::REMOVE_DATA_MASK_ALL &
(~StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE),
StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
- storage_origin,
+ origin,
profile->GetRequestContextForExtensions());
} else {
// We don't need to worry about the media request context because that
@@ -55,13 +57,51 @@ void DataDeleter::StartDeleting(Profile* profile,
StoragePartition::REMOVE_DATA_MASK_ALL &
(~StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE),
StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
- storage_origin,
+ origin,
partition->GetURLRequestContext());
}
+}
+
+void OnNeedsToGarbageCollectIsolatedStorage(WeakPtr<ExtensionService> es) {
+ if (!es)
+ return;
+ es->extension_prefs()->SetNeedsStorageGarbageCollection(true);
+}
+
+} // namespace
+
+namespace extensions {
+
+// static
+void DataDeleter::StartDeleting(Profile* profile, const Extension* extension) {
+ DCHECK(profile);
+ DCHECK(extension);
+
+ if (extensions::AppIsolationInfo::HasIsolatedStorage(extension)) {
+ BrowserContext::AsyncObliterateStoragePartition(
+ profile,
+ profile->GetExtensionService()->GetSiteForExtensionId(extension->id()),
+ base::Bind(&OnNeedsToGarbageCollectIsolatedStorage,
+ profile->GetExtensionService()->AsWeakPtr()));
+ } else {
+ GURL launch_web_url_origin(
+ extensions::AppLaunchInfo::GetLaunchWebURL(extension).GetOrigin());
+
+ StoragePartition* partition = BrowserContext::GetStoragePartitionForSite(
+ profile,
+ Extension::GetBaseURLFromExtensionId(extension->id()));
+
+ if (extension->is_hosted_app() &&
+ !profile->GetExtensionSpecialStoragePolicy()->
+ IsStorageProtected(launch_web_url_origin)) {
+ DeleteOrigin(profile, partition, launch_web_url_origin);
+ }
+ DeleteOrigin(profile, partition, extension->url());
+ }
// Begin removal of the settings for the current extension.
profile->GetExtensionService()->settings_frontend()->
- DeleteStorageSoon(extension_id);
+ DeleteStorageSoon(extension->id());
}
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/data_deleter.h ('k') | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698