summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browsing_data_remover.cc
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2011-06-09 11:47:42 +0100
committerKristian Monsen <kristianm@google.com>2011-06-29 14:33:03 +0100
commitdc0f95d653279beabeb9817299e2902918ba123e (patch)
tree32eb121cd532053a5b9cb0c390331349af8d6baa /chrome/browser/browsing_data_remover.cc
parentba160cd4054d13d0cb0b1b46e61c3bed67095811 (diff)
downloadexternal_chromium-dc0f95d653279beabeb9817299e2902918ba123e.zip
external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.gz
external_chromium-dc0f95d653279beabeb9817299e2902918ba123e.tar.bz2
Merge Chromium at r11.0.696.0: Initial merge by git
Change-Id: I273dde2843af0839dfc08b419bb443fbd449532d
Diffstat (limited to 'chrome/browser/browsing_data_remover.cc')
-rw-r--r--chrome/browser/browsing_data_remover.cc88
1 files changed, 30 insertions, 58 deletions
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index b9cae94..f926126 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -10,11 +10,10 @@
#include "base/callback.h"
#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/browser_thread.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/in_process_webkit/webkit_context.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/net/chrome_net_log.h"
@@ -30,6 +29,8 @@
#include "chrome/common/net/url_request_context_getter.h"
#include "chrome/common/notification_source.h"
#include "chrome/common/url_constants.h"
+#include "content/browser/browser_thread.h"
+#include "content/browser/in_process_webkit/webkit_context.h"
#include "net/base/cookie_monster.h"
#include "net/base/net_errors.h"
#include "net/base/transport_security_state.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_(
@@ -66,7 +68,7 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
media_context_getter_(profile->GetRequestContextForMedia()),
waiting_for_clear_databases_(false),
waiting_for_clear_history_(false),
- waiting_for_clear_host_cache_(false),
+ waiting_for_clear_networking_history_(false),
waiting_for_clear_cache_(false),
waiting_for_clear_appcache_(false) {
DCHECK(profile);
@@ -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_(
@@ -93,7 +96,7 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
media_context_getter_(profile->GetRequestContextForMedia()),
waiting_for_clear_databases_(false),
waiting_for_clear_history_(false),
- waiting_for_clear_host_cache_(false),
+ waiting_for_clear_networking_history_(false),
waiting_for_clear_cache_(false),
waiting_for_clear_appcache_(false),
waiting_for_clear_lso_data_(false) {
@@ -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);
@@ -141,13 +125,14 @@ void BrowsingDataRemover::Remove(int remove_mask) {
NewCallback(this, &BrowsingDataRemover::OnHistoryDeletionDone));
}
- // Need to clear the host cache, as it also reveals some history.
- waiting_for_clear_host_cache_ = true;
+ // Need to clear the host cache and accumulated speculative data, as it also
+ // reveals some history.
+ waiting_for_clear_networking_history_ = true;
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(
this,
- &BrowsingDataRemover::ClearHostCacheOnIOThread,
+ &BrowsingDataRemover::ClearNetworkingHistory,
g_browser_process->io_thread()));
// As part of history deletion we also delete the auto-generated keywords.
@@ -193,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()) {
@@ -203,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) {
@@ -356,16 +340,16 @@ void BrowsingDataRemover::NotifyAndDeleteIfDone() {
}
void BrowsingDataRemover::ClearedNetworkHistory() {
- waiting_for_clear_host_cache_ = false;
+ waiting_for_clear_networking_history_ = false;
NotifyAndDeleteIfDone();
}
-void BrowsingDataRemover::ClearHostCacheOnIOThread(IOThread* io_thread) {
+void BrowsingDataRemover::ClearNetworkingHistory(IOThread* io_thread) {
// This function should be called on the IO thread.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- io_thread->ClearHostCache();
+ io_thread->ClearNetworkingHistory();
// Notify the UI thread that we are done.
BrowserThread::PostTask(
@@ -463,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);
}
@@ -482,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_);
@@ -506,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_) {