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

Side by Side Diff: chrome/browser/extensions/data_deleter.cc

Issue 11419307: Garbage Collect the Storage directory on next profile start after an extension uninstall. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged Created 8 years 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 | Annotate | Revision Log
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/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/settings/settings_frontend.h" 8 #include "chrome/browser/extensions/settings/settings_frontend.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
11 #include "content/public/browser/browser_context.h" 11 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/storage_partition.h" 13 #include "content/public/browser/storage_partition.h"
14 #include "extensions/common/constants.h" 14 #include "extensions/common/constants.h"
15 #include "net/url_request/url_request_context_getter.h" 15 #include "net/url_request/url_request_context_getter.h"
16 16
17 using content::BrowserContext; 17 using content::BrowserContext;
18 using content::BrowserThread; 18 using content::BrowserThread;
19 19
20 namespace extensions { 20 namespace extensions {
21 21
22 // static 22 // static
23 void DataDeleter::StartDeleting(Profile* profile, 23 void DataDeleter::StartDeleting(Profile* profile,
24 const std::string& extension_id, 24 const std::string& extension_id,
25 const GURL& storage_origin, 25 const GURL& storage_origin) {
26 bool is_storage_isolated) {
27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
28 DCHECK(profile); 27 DCHECK(profile);
29 28
30 const GURL& site = Extension::GetBaseURLFromExtensionId(extension_id); 29 const GURL& site = Extension::GetBaseURLFromExtensionId(extension_id);
31 30
32 if (is_storage_isolated) {
33 BrowserContext::AsyncObliterateStoragePartition(profile, site);
34 return;
35 }
36
37 content::StoragePartition* partition = 31 content::StoragePartition* partition =
38 BrowserContext::GetStoragePartitionForSite(profile, site); 32 BrowserContext::GetStoragePartitionForSite(profile, site);
39 33
40 if (storage_origin.SchemeIs(extensions::kExtensionScheme)) { 34 if (storage_origin.SchemeIs(extensions::kExtensionScheme)) {
41 // TODO(ajwong): Cookies are not properly isolated for 35 // TODO(ajwong): Cookies are not properly isolated for
42 // chrome-extension:// scheme. (http://crbug.com/158386). 36 // chrome-extension:// scheme. (http://crbug.com/158386).
43 // 37 //
44 // However, no isolated apps actually can write to kExtensionScheme 38 // However, no isolated apps actually can write to kExtensionScheme
45 // origins. Thus, it is benign to delete from the 39 // origins. Thus, it is benign to delete from the
46 // RequestContextForExtensions because there's nothing stored there. We 40 // RequestContextForExtensions because there's nothing stored there. We
47 // preserve this code path without checking for isolation because it's 41 // preserve this code path without checking for isolation because it's
48 // simpler than special casing. This code should go away once we merge 42 // simpler than special casing. This code should go away once we merge
49 // the various URLRequestContexts (http://crbug.com/159193). 43 // the various URLRequestContexts (http://crbug.com/159193).
50 partition->AsyncClearDataForOrigin( 44 partition->AsyncClearDataForOrigin(
51 storage_origin, 45 storage_origin,
52 profile->GetRequestContextForExtensions()); 46 profile->GetRequestContextForExtensions());
53 } else { 47 } else {
54 // We don't need to worry about the media request context because that 48 // We don't need to worry about the media request context because that
55 // shares the same cookie store as the main request context. 49 // shares the same cookie store as the main request context.
56 partition->AsyncClearDataForOrigin(storage_origin, 50 partition->AsyncClearDataForOrigin(storage_origin,
57 partition->GetURLRequestContext()); 51 partition->GetURLRequestContext());
58 } 52 }
59 53
60 // Begin removal of the settings for the current extension. 54 // Begin removal of the settings for the current extension.
61 profile->GetExtensionService()->settings_frontend()-> 55 profile->GetExtensionService()->settings_frontend()->
62 DeleteStorageSoon(extension_id); 56 DeleteStorageSoon(extension_id);
63 } 57 }
64 58
65 } // namespace extensions 59 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698