| 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
|
|
|