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

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();
not at google - send to devlin 2014/01/08 18:01:36 should be a const std::string&, however, IMO this
mlamouri (slow - plz ping) 2014/01/08 23:44:08 Agreed. It's not that needed. That code changed a
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 StoragePartition* partition = BrowserContext::GetStoragePartitionForSite(
45 profile,
46 Extension::GetBaseURLFromExtensionId(extension_id));
47
48 if (extension->is_hosted_app() &&
49 !profile->GetExtensionSpecialStoragePolicy()->
50 IsStorageProtected(launch_web_url_origin)) {
51 DeleteOrigin(profile, partition, launch_web_url_origin);
52 }
53 DeleteOrigin(profile, partition, extension->url());
54 }
55
56 // Begin removal of the settings for the current extension.
57 profile->GetExtensionService()->settings_frontend()->
58 DeleteStorageSoon(extension_id);
59 }
60
61 // static
62 void DataDeleter::DeleteOrigin(Profile* profile,
63 StoragePartition* partition,
64 const GURL& origin) {
27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
28 DCHECK(profile); 66 DCHECK(profile);
67 DCHECK(partition);
29 68
30 const GURL& site = Extension::GetBaseURLFromExtensionId(extension_id); 69 if (origin.SchemeIs(extensions::kExtensionScheme)) {
31
32 StoragePartition* partition =
33 BrowserContext::GetStoragePartitionForSite(profile, site);
34
35 if (storage_origin.SchemeIs(extensions::kExtensionScheme)) {
36 // TODO(ajwong): Cookies are not properly isolated for 70 // TODO(ajwong): Cookies are not properly isolated for
37 // chrome-extension:// scheme. (http://crbug.com/158386). 71 // chrome-extension:// scheme. (http://crbug.com/158386).
38 // 72 //
39 // However, no isolated apps actually can write to kExtensionScheme 73 // However, no isolated apps actually can write to kExtensionScheme
40 // origins. Thus, it is benign to delete from the 74 // origins. Thus, it is benign to delete from the
41 // RequestContextForExtensions because there's nothing stored there. We 75 // RequestContextForExtensions because there's nothing stored there. We
42 // preserve this code path without checking for isolation because it's 76 // preserve this code path without checking for isolation because it's
43 // simpler than special casing. This code should go away once we merge 77 // simpler than special casing. This code should go away once we merge
44 // the various URLRequestContexts (http://crbug.com/159193). 78 // the various URLRequestContexts (http://crbug.com/159193).
45 partition->ClearDataForOrigin( 79 partition->ClearDataForOrigin(
46 StoragePartition::REMOVE_DATA_MASK_ALL & 80 StoragePartition::REMOVE_DATA_MASK_ALL &
47 (~StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE), 81 (~StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE),
48 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, 82 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
49 storage_origin, 83 origin,
50 profile->GetRequestContextForExtensions()); 84 profile->GetRequestContextForExtensions());
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 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