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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/data_deleter.h" 5 #include "chrome/browser/extensions/data_deleter.h"
6 6
7 #include "chrome/browser/extensions/api/storage/settings_frontend.h" 7 #include "chrome/browser/extensions/api/storage/settings_frontend.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_special_storage_policy.h"
9 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
12 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
10 #include "content/public/browser/browser_context.h" 13 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/site_instance.h"
12 #include "content/public/browser/storage_partition.h" 16 #include "content/public/browser/storage_partition.h"
13 #include "extensions/common/constants.h" 17 #include "extensions/common/constants.h"
14 #include "extensions/common/extension.h" 18 #include "extensions/common/extension.h"
15 #include "net/url_request/url_request_context_getter.h" 19 #include "net/url_request/url_request_context_getter.h"
16 20
17 using content::BrowserContext; 21 using content::BrowserContext;
18 using content::BrowserThread; 22 using content::BrowserThread;
19 using content::StoragePartition; 23 using content::StoragePartition;
20 24
21 namespace extensions { 25 namespace extensions {
22 26
23 // static 27 // static
24 void DataDeleter::StartDeleting(Profile* profile, 28 void DataDeleter::StartDeleting(Profile* profile, const Extension* extension) {
25 const std::string& extension_id, 29 DCHECK(profile);
26 const GURL& storage_origin) { 30 DCHECK(extension);
31
32 std::string extension_id = extension->id();
33
34 if (extensions::AppIsolationInfo::HasIsolatedStorage(extension)) {
35 BrowserContext::AsyncObliterateStoragePartition(
36 profile,
37 profile->GetExtensionService()->GetSiteForExtensionId(extension_id),
38 base::Bind(&ExtensionService::OnNeedsToGarbageCollectIsolatedStorage,
39 profile->GetExtensionService()->AsWeakPtr()));
40 } else {
41 GURL launch_web_url_origin(
42 extensions::AppLaunchInfo::GetLaunchWebURL(extension).GetOrigin());
43
44 if (extension->is_hosted_app() &&
45 !profile->GetExtensionSpecialStoragePolicy()->
46 IsStorageProtected(launch_web_url_origin)) {
47 DeleteNonIsolatedStorage(profile, extension_id, launch_web_url_origin);
not at google - send to devlin 2014/01/08 02:49:17 interesting that we do this
48 }
49 DeleteNonIsolatedStorage(profile, extension_id, extension->url());
50 }
51
52 // Begin removal of the settings for the current extension.
53 profile->GetExtensionService()->settings_frontend()->
54 DeleteStorageSoon(extension_id);
55 }
56
57 // static
58 void DataDeleter::DeleteNonIsolatedStorage(Profile* profile,
not at google - send to devlin 2014/01/08 02:49:17 nit: name is a bit misleading. this deletes the st
mlamouri (slow - plz ping) 2014/01/08 17:42:31 Done.
59 const std::string& extension_id,
60 const GURL& storage_origin) {
27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
28 DCHECK(profile); 62 DCHECK(profile);
29 63
30 const GURL& site = Extension::GetBaseURLFromExtensionId(extension_id); 64 const GURL& site = Extension::GetBaseURLFromExtensionId(extension_id);
31 65
32 StoragePartition* partition = 66 StoragePartition* partition =
33 BrowserContext::GetStoragePartitionForSite(profile, site); 67 BrowserContext::GetStoragePartitionForSite(profile, site);
34 68
35 if (storage_origin.SchemeIs(extensions::kExtensionScheme)) { 69 if (storage_origin.SchemeIs(extensions::kExtensionScheme)) {
36 // TODO(ajwong): Cookies are not properly isolated for 70 // TODO(ajwong): Cookies are not properly isolated for
(...skipping 14 matching lines...) Expand all
51 } else { 85 } else {
52 // We don't need to worry about the media request context because that 86 // We don't need to worry about the media request context because that
53 // shares the same cookie store as the main request context. 87 // shares the same cookie store as the main request context.
54 partition->ClearDataForOrigin( 88 partition->ClearDataForOrigin(
55 StoragePartition::REMOVE_DATA_MASK_ALL & 89 StoragePartition::REMOVE_DATA_MASK_ALL &
56 (~StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE), 90 (~StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE),
57 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, 91 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
58 storage_origin, 92 storage_origin,
59 partition->GetURLRequestContext()); 93 partition->GetURLRequestContext());
60 } 94 }
61
62 // Begin removal of the settings for the current extension.
63 profile->GetExtensionService()->settings_frontend()->
64 DeleteStorageSoon(extension_id);
65 } 95 }
66 96
67 } // namespace extensions 97 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698