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

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

Issue 11362268: Implement the ability to obliterate a storage partition from disk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Correctly delete all data. Created 8 years, 1 month 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) { 26 bool is_storage_isolated) {
27 // TODO(ajwong): If |is_storage_isolated|, we should just blowaway the 27 // TODO(ajwong): If |is_storage_isolated|, we should just blowaway the
Charlie Reis 2012/11/15 18:28:21 Does this CL resolve this TODO?
awong 2012/11/16 00:36:04 Done.
28 // whole directory that the associated StoragePartition is located at. To do 28 // whole directory that the associated StoragePartition is located at. To do
29 // this, we need to ensure that all contexts referencing that directory have 29 // this, we need to ensure that all contexts referencing that directory have
30 // closed their file handles, otherwise Windows will complain. 30 // closed their file handles, otherwise Windows will complain.
31 // 31 //
32 // http://www.crbug.com/85127 32 // http://www.crbug.com/85127
33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
34 DCHECK(profile); 34 DCHECK(profile);
35 35
36 const GURL& site = Extension::GetBaseURLFromExtensionId(extension_id); 36 const GURL& site = Extension::GetBaseURLFromExtensionId(extension_id);
37
38 if (is_storage_isolated) {
39 BrowserContext::AsyncObliterateStoragePartition(profile, site);
40 return;
41 }
42
37 content::StoragePartition* partition = 43 content::StoragePartition* partition =
38 BrowserContext::GetStoragePartitionForSite(profile, site); 44 BrowserContext::GetStoragePartitionForSite(profile, site);
39 45
40 if (storage_origin.SchemeIs(extensions::kExtensionScheme)) { 46 if (storage_origin.SchemeIs(extensions::kExtensionScheme)) {
41 // TODO(ajwong): Cookies are not properly isolated for 47 // TODO(ajwong): Cookies are not properly isolated for
42 // chrome-extension:// scheme. (http://crbug.com/158386). 48 // chrome-extension:// scheme. (http://crbug.com/158386).
43 // 49 //
44 // However, no isolated apps actually can write to kExtensionScheme 50 // However, no isolated apps actually can write to kExtensionScheme
45 // origins. Thus, it is benign to delete from the 51 // origins. Thus, it is benign to delete from the
46 // RequestContextForExtensions because there's nothing stored there. We 52 // RequestContextForExtensions because there's nothing stored there. We
47 // preserve this code path without checking for isolation because it's 53 // preserve this code path without checking for isolation because it's
48 // simpler than special casing. This code should go away once we merge 54 // simpler than special casing. This code should go away once we merge
49 // the various URLRequestContexts (http://crbug.com/159193). 55 // the various URLRequestContexts (http://crbug.com/159193).
50 partition->AsyncClearDataForOrigin( 56 partition->AsyncClearDataForOrigin(
51 storage_origin, 57 storage_origin,
52 profile->GetRequestContextForExtensions()); 58 profile->GetRequestContextForExtensions());
53 } else { 59 } else {
54 // We don't need to worry about the media request context because that 60 // We don't need to worry about the media request context because that
55 // shares the same cookie store as the main request context. 61 // shares the same cookie store as the main request context.
56 partition->AsyncClearDataForOrigin(storage_origin, 62 partition->AsyncClearDataForOrigin(storage_origin,
57 partition->GetURLRequestContext()); 63 partition->GetURLRequestContext());
58 } 64 }
59 65
60 // Begin removal of the settings for the current extension. 66 // Begin removal of the settings for the current extension.
61 profile->GetExtensionService()->settings_frontend()-> 67 profile->GetExtensionService()->settings_frontend()->
62 DeleteStorageSoon(extension_id); 68 DeleteStorageSoon(extension_id);
63 } 69 }
64 70
65 } // namespace extensions 71 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_context.cc » ('j') | content/browser/storage_partition_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698