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

Unified Diff: chrome/browser/browsing_data_remover.cc

Issue 10413072: Teaching BrowsingDataRemover how to delete application data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh. Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browsing_data_remover.cc
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index 0772e9ff1c8b62616a2db5cd9b053b66ce9c1603..0ae6694c67fe2146f37add64e71d4de805836862 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -61,6 +61,7 @@
#include "net/url_request/url_request_context_getter.h"
#include "webkit/quota/quota_manager.h"
#include "webkit/quota/quota_types.h"
+#include "webkit/quota/special_storage_policy.h"
using content::BrowserContext;
using content::BrowserThread;
@@ -68,6 +69,23 @@ using content::DOMStorageContext;
using content::DownloadManager;
using content::UserMetricsAction;
+namespace {
+
+// Converts BrowsingDataRemover::OriginSetMask data to
+// quota::SpecialStoragePolicy::OriginType data.
+int GetDomStorageContextMask(int origin_set_mask) {
+ int result = 0;
+ if (origin_set_mask & BrowsingDataRemover::PROTECTED_WEB)
+ result |= quota::SpecialStoragePolicy::PROTECTED_WEB;
+ if (origin_set_mask & BrowsingDataRemover::UNPROTECTED_WEB)
+ result |= quota::SpecialStoragePolicy::UNPROTECTED_WEB;
+ if (origin_set_mask & BrowsingDataRemover::EXTENSION)
+ result |= quota::SpecialStoragePolicy::EXTENSION;
+ return result;
+}
+
+} // namespace
+
bool BrowsingDataRemover::removing_ = false;
BrowsingDataRemover::NotificationDetails::NotificationDetails()
@@ -111,7 +129,7 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
waiting_for_clear_quota_managed_data_(false),
remove_mask_(0),
remove_origin_(GURL()),
- remove_protected_(false) {
+ origin_set_mask_(0) {
DCHECK(profile);
}
@@ -136,7 +154,7 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
waiting_for_clear_quota_managed_data_(false),
remove_mask_(0),
remove_origin_(GURL()),
- remove_protected_(false) {
+ origin_set_mask_(0) {
DCHECK(profile);
}
@@ -165,18 +183,18 @@ int BrowsingDataRemover::GenerateQuotaClientMask(int remove_mask) {
return quota_client_mask;
}
-void BrowsingDataRemover::Remove(int remove_mask) {
- RemoveImpl(remove_mask, GURL(), false);
+void BrowsingDataRemover::Remove(int remove_mask, int origin_set_mask) {
+ RemoveImpl(remove_mask, GURL(), origin_set_mask);
}
void BrowsingDataRemover::RemoveImpl(int remove_mask,
const GURL& origin,
- bool remove_protected_origins) {
+ int origin_set_mask) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
set_removing(true);
remove_mask_ = remove_mask;
remove_origin_ = origin;
- remove_protected_ = remove_protected_origins;
+ origin_set_mask_ = origin_set_mask;
if (remove_mask & REMOVE_HISTORY) {
HistoryService* history_service =
@@ -308,7 +326,7 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
if (remove_mask & REMOVE_LOCAL_STORAGE) {
BrowserContext::GetDOMStorageContext(profile_)->DeleteDataModifiedSince(
- delete_begin_);
+ delete_begin_, GetDomStorageContextMask(origin_set_mask_));
}
if (remove_mask & REMOVE_INDEXEDDB || remove_mask & REMOVE_WEBSQL ||
@@ -588,11 +606,12 @@ void BrowsingDataRemover::ClearQuotaManagedDataOnIOThread() {
quota_managed_origins_to_delete_count_ = 0;
quota_managed_storage_types_to_delete_count_ = 2;
- if (delete_begin_ == base::Time()) {
- // If we're deleting since the beginning of time, ask the QuotaManager for
- // all origins with persistent quota modified within the user-specified
- // timeframe, and deal with the resulting set in
- // OnGotPersistentQuotaManagedOrigins.
+ if (delete_begin_ == base::Time() ||
+ origin_set_mask_ & (PROTECTED_WEB | EXTENSION) ) {
+ // If we're deleting since the beginning of time, or we're removing
+ // protected origins, then ask the QuotaManager for all origins with
+ // persistent quota modified within the user-specified timeframe, and deal
+ // with the resulting set in OnGotPersistentQuotaManagedOrigins.
quota_manager_->GetOriginsModifiedSince(
quota::kStorageTypePersistent, delete_begin_,
base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins,
@@ -602,27 +621,45 @@ void BrowsingDataRemover::ClearQuotaManagedDataOnIOThread() {
--quota_managed_storage_types_to_delete_count_;
}
- // Do the same for temporary quota, regardless, passing the resulting set into
- // OnGotTemporaryQuotaManagedOrigins.
- quota_manager_->GetOriginsModifiedSince(
- quota::kStorageTypeTemporary, delete_begin_,
- base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins,
- base::Unretained(this)));
+ if (origin_set_mask_ & UNPROTECTED_WEB) {
+ // Do the same for temporary quota, if we're removing unprotected origins,
+ // by passing the resulting set into OnGotTemporaryQuotaManagedOrigins.
+ quota_manager_->GetOriginsModifiedSince(
+ quota::kStorageTypeTemporary, delete_begin_,
+ base::Bind(&BrowsingDataRemover::OnGotQuotaManagedOrigins,
+ base::Unretained(this)));
+ }
}
void BrowsingDataRemover::OnGotQuotaManagedOrigins(
const std::set<GURL>& origins, quota::StorageType type) {
DCHECK_GT(quota_managed_storage_types_to_delete_count_, 0);
// Walk through the origins passed in, delete quota of |type| from each that
- // isn't protected.
+ // matches the |origin_set_mask_|.
std::set<GURL>::const_iterator origin;
for (origin = origins.begin(); origin != origins.end(); ++origin) {
- if (!BrowsingDataHelper::IsValidScheme(origin->scheme()))
+ if (!remove_origin_.is_empty() && remove_origin_ != origin->GetOrigin())
continue;
- if (special_storage_policy_->IsStorageProtected(origin->GetOrigin()))
+
+ // Skip packaged apps and extensions (non-websafe origin) unless
+ // EXTENSION is set.
+ if (!(origin_set_mask_ & EXTENSION) &&
+ !BrowsingDataHelper::IsValidScheme(origin->scheme()))
continue;
- if (!remove_origin_.is_empty() && remove_origin_ != origin->GetOrigin())
+
+ // Skip the open web (unprotected and websafe origins) unless
+ // UNPROTECTED_WEB is set.
+ if (!(origin_set_mask_ & UNPROTECTED_WEB) &&
+ special_storage_policy_->IsStorageProtected(origin->GetOrigin()))
+ continue;
+
+ // Skip hosted applications (protected and websafe origins) unless
+ // PROTECTED_WEB is set.
+ if (!(origin_set_mask_ & PROTECTED_WEB) &&
+ BrowsingDataHelper::IsValidScheme(origin->scheme()) &&
+ special_storage_policy_->IsStorageProtected(origin->GetOrigin()))
continue;
+
++quota_managed_origins_to_delete_count_;
quota_manager_->DeleteOriginData(
origin->GetOrigin(), type,

Powered by Google App Engine
This is Rietveld 408576698