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

Unified Diff: chrome/browser/browsing_data_remover.cc

Issue 9379008: Add origin-based deletion to BrowsingDataRemover (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 c2bf21172c6e9bfd9a3452e8aa7c9095afed44c1..33fd55f50090b4a571d0fbc28de86e4746682e68 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -157,15 +157,22 @@ int BrowsingDataRemover::GenerateQuotaClientMask(int remove_mask) {
}
void BrowsingDataRemover::Remove(int remove_mask) {
+ Remove(remove_mask, GURL());
+}
+
+void BrowsingDataRemover::Remove(int remove_mask, const GURL& origin) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
set_removing(true);
remove_mask_ = remove_mask;
+ remove_origin_ = origin;
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,51 +182,56 @@ void BrowsingDataRemover::Remove(int remove_mask) {
base::Unretained(this)));
}
- // Need to clear the host cache and accumulated speculative data, as it also
- // reveals some history.
- if (g_browser_process->io_thread()) {
- waiting_for_clear_networking_history_ = true;
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- base::Bind(&BrowsingDataRemover::ClearNetworkingHistory,
- base::Unretained(this), g_browser_process->io_thread()));
- }
-
- // As part of history deletion we also delete the auto-generated keywords.
- TemplateURLService* keywords_model =
- TemplateURLServiceFactory::GetForProfile(profile_);
- if (keywords_model && !keywords_model->loaded()) {
- registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
- content::Source<TemplateURLService>(keywords_model));
- keywords_model->Load();
- } else if (keywords_model) {
- keywords_model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_);
- }
+ // If the caller is removing history for all hosts, then clear ancillary
+ // historical information.
Bernhard Bauer 2012/02/10 19:50:57 This means of course we have to be careful, as the
+ if (!remove_origin_.is_empty()) {
+ // Need to clear the host cache and accumulated speculative data, as it
+ // also reveals some history.
+ if (g_browser_process->io_thread()) {
+ waiting_for_clear_networking_history_ = true;
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&BrowsingDataRemover::ClearNetworkingHistory,
+ base::Unretained(this), g_browser_process->io_thread()));
+ }
- // 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();
- }
+ // As part of history deletion we also delete the auto-generated keywords.
+ TemplateURLService* keywords_model =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ if (keywords_model && !keywords_model->loaded()) {
+ registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
+ content::Source<TemplateURLService>(keywords_model));
+ keywords_model->Load();
+ } else if (keywords_model) {
+ keywords_model->RemoveAutoGeneratedBetween(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();
+ // 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();
+ }
- // 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.
- prerender::PrerenderManager* prerender_manager =
- prerender::PrerenderManagerFactory::GetForProfile(profile_);
- if (prerender_manager) {
- prerender_manager->ClearData(
- prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS |
- prerender::PrerenderManager::CLEAR_PRERENDER_HISTORY);
+ // 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.
+ prerender::PrerenderManager* prerender_manager =
+ prerender::PrerenderManagerFactory::GetForProfile(profile_);
+ if (prerender_manager) {
+ prerender_manager->ClearData(
+ prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS |
+ prerender::PrerenderManager::CLEAR_PRERENDER_HISTORY);
+ }
}
}
« chrome/browser/browsing_data_remover.h ('K') | « chrome/browser/browsing_data_remover.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698