summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browsing_data_remover.cc
diff options
context:
space:
mode:
authormichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-26 00:28:43 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-26 00:28:43 +0000
commit19eb8015c483fff874bf1eddb80bd26cf4167f33 (patch)
treebe896411dde17d24eb8dbcd67e7b4c5cad2ef1b6 /chrome/browser/browsing_data_remover.cc
parentf02074331bddc7d89b20e6b3a8fb934e6891207c (diff)
downloadchromium_src-19eb8015c483fff874bf1eddb80bd26cf4167f33.zip
chromium_src-19eb8015c483fff874bf1eddb80bd26cf4167f33.tar.gz
chromium_src-19eb8015c483fff874bf1eddb80bd26cf4167f33.tar.bz2
Add an accessor for an ExtensionSpecialStoragePolicy to the Profile class
and use it in the extension service, data remover, and storage subsystems. BUG=52357 TEST=extension_service_unittest.cc Review URL: http://codereview.chromium.org/6551028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76126 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browsing_data_remover.cc')
-rw-r--r--chrome/browser/browsing_data_remover.cc67
1 files changed, 19 insertions, 48 deletions
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index 6361e30..f926126 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_special_storage_policy.h"
#include "chrome/browser/history/history.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/metrics/user_metrics.h"
@@ -49,6 +50,7 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
base::Time delete_begin,
base::Time delete_end)
: profile_(profile),
+ special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()),
delete_begin_(delete_begin),
delete_end_(delete_end),
ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_(
@@ -76,6 +78,7 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
TimePeriod time_period,
base::Time delete_end)
: profile_(profile),
+ special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()),
delete_begin_(CalculateBeginDeleteTime(time_period)),
delete_end_(delete_end),
ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_(
@@ -108,25 +111,6 @@ void BrowsingDataRemover::Remove(int remove_mask) {
DCHECK(!removing_);
removing_ = true;
- std::vector<GURL> origin_whitelist;
- ExtensionService* extensions_service = profile_->GetExtensionService();
- if (extensions_service && extensions_service->HasInstalledExtensions()) {
- std::map<GURL, int> whitelist_map =
- extensions_service->protected_storage_map();
- for (std::map<GURL, int>::const_iterator iter = whitelist_map.begin();
- iter != whitelist_map.end(); ++iter) {
- origin_whitelist.push_back(iter->first);
- }
- }
-
- std::vector<string16> webkit_db_whitelist;
- for (size_t i = 0; i < origin_whitelist.size(); ++i) {
- webkit_db_whitelist.push_back(
- webkit_database::DatabaseUtil::GetOriginIdentifier(
- origin_whitelist[i]));
- }
-
-
if (remove_mask & REMOVE_HISTORY) {
HistoryService* history_service =
profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
@@ -194,8 +178,9 @@ void BrowsingDataRemover::Remove(int remove_mask) {
// REMOVE_COOKIES is actually "cookies and other site data" so we make sure
// to remove other data such local databases, STS state, etc.
- profile_->GetWebKitContext()->DeleteDataModifiedSince(
- delete_begin_, chrome::kExtensionScheme, webkit_db_whitelist);
+ // We assume the end time is now.
+
+ profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_);
database_tracker_ = profile_->GetDatabaseTracker();
if (database_tracker_.get()) {
@@ -204,26 +189,24 @@ void BrowsingDataRemover::Remove(int remove_mask) {
BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(
this,
- &BrowsingDataRemover::ClearDatabasesOnFILEThread,
- delete_begin_,
- webkit_db_whitelist));
+ &BrowsingDataRemover::ClearDatabasesOnFILEThread));
}
+ waiting_for_clear_appcache_ = true;
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(
- profile_->GetTransportSecurityState(),
- &net::TransportSecurityState::DeleteSince,
- delete_begin_));
+ this,
+ &BrowsingDataRemover::ClearAppCacheOnIOThread));
+
+ // TODO(michaeln): delete temporary file system data too
- waiting_for_clear_appcache_ = true;
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(
- this,
- &BrowsingDataRemover::ClearAppCacheOnIOThread,
- delete_begin_, // we assume end time == now
- origin_whitelist));
+ profile_->GetTransportSecurityState(),
+ &net::TransportSecurityState::DeleteSince,
+ delete_begin_));
}
if (remove_mask & REMOVE_PASSWORDS) {
@@ -464,13 +447,11 @@ void BrowsingDataRemover::OnClearedDatabases(int rv) {
NotifyAndDeleteIfDone();
}
-void BrowsingDataRemover::ClearDatabasesOnFILEThread(base::Time delete_begin,
- const std::vector<string16>& webkit_db_whitelist) {
+void BrowsingDataRemover::ClearDatabasesOnFILEThread() {
// This function should be called on the FILE thread.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
-
int rv = database_tracker_->DeleteDataModifiedSince(
- delete_begin, webkit_db_whitelist, &database_cleared_callback_);
+ delete_begin_, &database_cleared_callback_);
if (rv != net::ERR_IO_PENDING)
OnClearedDatabases(rv);
}
@@ -483,17 +464,13 @@ void BrowsingDataRemover::OnClearedAppCache() {
DCHECK(result);
return;
}
- appcache_whitelist_.clear();
waiting_for_clear_appcache_ = false;
NotifyAndDeleteIfDone();
}
-void BrowsingDataRemover::ClearAppCacheOnIOThread(base::Time delete_begin,
- const std::vector<GURL>& origin_whitelist) {
+void BrowsingDataRemover::ClearAppCacheOnIOThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(waiting_for_clear_appcache_);
-
- appcache_whitelist_ = origin_whitelist;
appcache_info_ = new appcache::AppCacheInfoCollection;
GetAppCacheService()->GetAllAppCacheInfo(
appcache_info_, &appcache_got_info_callback_);
@@ -507,14 +484,8 @@ void BrowsingDataRemover::OnGotAppCacheInfo(int rv) {
for (InfoByOrigin::const_iterator origin =
appcache_info_->infos_by_origin.begin();
origin != appcache_info_->infos_by_origin.end(); ++origin) {
- bool found_in_whitelist = false;
- for (size_t i = 0; i < appcache_whitelist_.size(); ++i) {
- if (appcache_whitelist_[i] == origin->first)
- found_in_whitelist = true;
- }
- if (found_in_whitelist)
+ if (special_storage_policy_->IsStorageProtected(origin->first))
continue;
-
for (AppCacheInfoVector::const_iterator info = origin->second.begin();
info != origin->second.end(); ++info) {
if (info->creation_time > delete_begin_) {