Index: chrome/browser/browsing_data_remover.cc |
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc |
index ea084bbb4b282671c3b35063b0cbe3669841013b..c8a8576f989db1439f0b562f11f66c1183ceccf9 100644 |
--- a/chrome/browser/browsing_data_remover.cc |
+++ b/chrome/browser/browsing_data_remover.cc |
@@ -103,7 +103,9 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
waiting_for_clear_origin_bound_certs_(false), |
waiting_for_clear_plugin_data_(false), |
waiting_for_clear_quota_managed_data_(false), |
- remove_mask_(0) { |
+ remove_mask_(0), |
+ remove_origin_(GURL()), |
+ remove_protected_(false) { |
DCHECK(profile); |
} |
@@ -126,7 +128,9 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
waiting_for_clear_origin_bound_certs_(false), |
waiting_for_clear_plugin_data_(false), |
waiting_for_clear_quota_managed_data_(false), |
- remove_mask_(0) { |
+ remove_mask_(0), |
+ remove_origin_(GURL()), |
+ remove_protected_(false) { |
DCHECK(profile); |
} |
@@ -156,15 +160,25 @@ int BrowsingDataRemover::GenerateQuotaClientMask(int remove_mask) { |
} |
void BrowsingDataRemover::Remove(int remove_mask) { |
+ RemoveImpl(remove_mask, GURL(), false); |
+} |
+ |
+void BrowsingDataRemover::RemoveImpl(int remove_mask, |
+ const GURL& origin, |
+ bool remove_protected_origins) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
set_removing(true); |
remove_mask_ = remove_mask; |
+ remove_origin_ = origin; |
+ remove_protected_ = remove_protected_origins; |
if (remove_mask & REMOVE_HISTORY) { |
HistoryService* history_service = |
profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
if (history_service) { |
std::set<GURL> restrict_urls; |
+ if (!remove_origin_.is_empty()) |
+ restrict_urls.insert(remove_origin_); |
content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); |
waiting_for_clear_history_ = true; |
history_service->ExpireHistoryBetween(restrict_urls, |
@@ -175,7 +189,8 @@ void BrowsingDataRemover::Remove(int remove_mask) { |
} |
// Need to clear the host cache and accumulated speculative data, as it also |
- // reveals some history. |
+ // reveals some history: we have no mechanism to track when these items were |
+ // created, so we'll clear them all. Better safe than sorry. |
if (g_browser_process->io_thread()) { |
waiting_for_clear_networking_history_ = true; |
BrowserThread::PostTask( |
@@ -192,27 +207,14 @@ void BrowsingDataRemover::Remove(int remove_mask) { |
content::Source<TemplateURLService>(keywords_model)); |
keywords_model->Load(); |
} else if (keywords_model) { |
- keywords_model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_); |
- } |
- |
- // We also delete the list of recently closed tabs. Since these expire, |
- // they can't be more than a day old, so we can simply clear them all. |
- TabRestoreService* tab_service = |
- TabRestoreServiceFactory::GetForProfile(profile_); |
- if (tab_service) { |
- tab_service->ClearEntries(); |
- tab_service->DeleteLastSession(); |
+ keywords_model->RemoveAutoGeneratedForOriginBetween(remove_origin_, |
+ delete_begin_, delete_end_); |
} |
- // We also delete the last session when we delete the history. |
- SessionService* session_service = |
- SessionServiceFactory::GetForProfile(profile_); |
- if (session_service) |
- session_service->DeleteLastSession(); |
- |
// The PrerenderManager keeps history of prerendered pages, so clear that. |
- // It also may have a prerendered page. If so, the page could be considered |
- // to have a small amount of historical information, so delete it, too. |
+ // It also may have a prerendered page. If so, the page could be |
+ // considered to have a small amount of historical information, so delete |
+ // it, too. |
prerender::PrerenderManager* prerender_manager = |
prerender::PrerenderManagerFactory::GetForProfile(profile_); |
if (prerender_manager) { |
@@ -220,6 +222,25 @@ void BrowsingDataRemover::Remove(int remove_mask) { |
prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS | |
prerender::PrerenderManager::CLEAR_PRERENDER_HISTORY); |
} |
+ |
+ // If the caller is removing history for all hosts, then clear ancillary |
+ // historical information. |
+ if (remove_origin_.is_empty()) { |
+ // We also delete the list of recently closed tabs. Since these expire, |
+ // they can't be more than a day old, so we can simply clear them all. |
+ TabRestoreService* tab_service = |
+ TabRestoreServiceFactory::GetForProfile(profile_); |
+ if (tab_service) { |
+ tab_service->ClearEntries(); |
+ tab_service->DeleteLastSession(); |
+ } |
+ |
+ // We also delete the last session when we delete the history. |
+ SessionService* session_service = |
+ SessionServiceFactory::GetForProfile(profile_); |
+ if (session_service) |
+ session_service->DeleteLastSession(); |
+ } |
} |
if (remove_mask & REMOVE_DOWNLOADS) { |