| OLD | NEW |
| 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 | |
| 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 | |
| 30 // closed their file handles, otherwise Windows will complain. | |
| 31 // | |
| 32 // http://www.crbug.com/85127 | |
| 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 34 DCHECK(profile); | 28 DCHECK(profile); |
| 35 | 29 |
| 36 const GURL& site = Extension::GetBaseURLFromExtensionId(extension_id); | 30 const GURL& site = Extension::GetBaseURLFromExtensionId(extension_id); |
| 31 |
| 32 if (is_storage_isolated) { |
| 33 BrowserContext::AsyncObliterateStoragePartition(profile, site); |
| 34 return; |
| 35 } |
| 36 |
| 37 content::StoragePartition* partition = | 37 content::StoragePartition* partition = |
| 38 BrowserContext::GetStoragePartitionForSite(profile, site); | 38 BrowserContext::GetStoragePartitionForSite(profile, site); |
| 39 | 39 |
| 40 if (storage_origin.SchemeIs(extensions::kExtensionScheme)) { | 40 if (storage_origin.SchemeIs(extensions::kExtensionScheme)) { |
| 41 // TODO(ajwong): Cookies are not properly isolated for | 41 // TODO(ajwong): Cookies are not properly isolated for |
| 42 // chrome-extension:// scheme. (http://crbug.com/158386). | 42 // chrome-extension:// scheme. (http://crbug.com/158386). |
| 43 // | 43 // |
| 44 // However, no isolated apps actually can write to kExtensionScheme | 44 // However, no isolated apps actually can write to kExtensionScheme |
| 45 // origins. Thus, it is benign to delete from the | 45 // origins. Thus, it is benign to delete from the |
| 46 // RequestContextForExtensions because there's nothing stored there. We | 46 // RequestContextForExtensions because there's nothing stored there. We |
| 47 // preserve this code path without checking for isolation because it's | 47 // preserve this code path without checking for isolation because it's |
| 48 // simpler than special casing. This code should go away once we merge | 48 // simpler than special casing. This code should go away once we merge |
| 49 // the various URLRequestContexts (http://crbug.com/159193). | 49 // the various URLRequestContexts (http://crbug.com/159193). |
| 50 partition->AsyncClearDataForOrigin( | 50 partition->AsyncClearDataForOrigin( |
| 51 storage_origin, | 51 storage_origin, |
| 52 profile->GetRequestContextForExtensions()); | 52 profile->GetRequestContextForExtensions()); |
| 53 } else { | 53 } else { |
| 54 // We don't need to worry about the media request context because that | 54 // We don't need to worry about the media request context because that |
| 55 // shares the same cookie store as the main request context. | 55 // shares the same cookie store as the main request context. |
| 56 partition->AsyncClearDataForOrigin(storage_origin, | 56 partition->AsyncClearDataForOrigin(storage_origin, |
| 57 partition->GetURLRequestContext()); | 57 partition->GetURLRequestContext()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Begin removal of the settings for the current extension. | 60 // Begin removal of the settings for the current extension. |
| 61 profile->GetExtensionService()->settings_frontend()-> | 61 profile->GetExtensionService()->settings_frontend()-> |
| 62 DeleteStorageSoon(extension_id); | 62 DeleteStorageSoon(extension_id); |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace extensions | 65 } // namespace extensions |
| OLD | NEW |