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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover.cc

Issue 1651913003: Handle origin-specific password deletion in BrowsingDataRemover (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments; switch to checking GURL emptiness for origin-based deletion. Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/browsing_data/browsing_data_remover.h" 5 #include "chrome/browser/browsing_data/browsing_data_remover.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 336
337 // crbug.com/140910: Many places were calling this with base::Time() as 337 // crbug.com/140910: Many places were calling this with base::Time() as
338 // delete_end, even though they should've used base::Time::Max(). 338 // delete_end, even though they should've used base::Time::Max().
339 DCHECK_NE(base::Time(), time_range.end); 339 DCHECK_NE(base::Time(), time_range.end);
340 340
341 SetRemoving(true); 341 SetRemoving(true);
342 delete_begin_ = time_range.begin; 342 delete_begin_ = time_range.begin;
343 delete_end_ = time_range.end; 343 delete_end_ = time_range.end;
344 remove_mask_ = remove_mask; 344 remove_mask_ = remove_mask;
345 origin_type_mask_ = origin_type_mask; 345 origin_type_mask_ = origin_type_mask;
346 url::Origin remove_origin(remove_url); 346 const url::Origin remove_origin(remove_url);
347 347
348 PrefService* prefs = profile_->GetPrefs(); 348 PrefService* prefs = profile_->GetPrefs();
349 bool may_delete_history = prefs->GetBoolean( 349 bool may_delete_history = prefs->GetBoolean(
350 prefs::kAllowDeletingBrowserHistory); 350 prefs::kAllowDeletingBrowserHistory);
351 351
352 // All the UI entry points into the BrowsingDataRemover should be disabled, 352 // All the UI entry points into the BrowsingDataRemover should be disabled,
353 // but this will fire if something was missed or added. 353 // but this will fire if something was missed or added.
354 DCHECK(may_delete_history || (remove_mask & REMOVE_NOCHECKS) || 354 DCHECK(may_delete_history || (remove_mask & REMOVE_NOCHECKS) ||
355 (!(remove_mask & REMOVE_HISTORY) && !(remove_mask & REMOVE_DOWNLOADS))); 355 (!(remove_mask & REMOVE_HISTORY) && !(remove_mask & REMOVE_DOWNLOADS)));
356 356
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 data_reduction_proxy_service->compression_stats() 552 data_reduction_proxy_service->compression_stats()
553 ->DeleteBrowsingHistory(delete_begin_, delete_end_); 553 ->DeleteBrowsingHistory(delete_begin_, delete_end_);
554 } 554 }
555 } 555 }
556 } 556 }
557 557
558 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) { 558 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) {
559 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads")); 559 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads"));
560 content::DownloadManager* download_manager = 560 content::DownloadManager* download_manager =
561 BrowserContext::GetDownloadManager(profile_); 561 BrowserContext::GetDownloadManager(profile_);
562 if (remove_origin.unique()) 562 if (remove_url.is_empty()) {
563 download_manager->RemoveDownloadsBetween(delete_begin_, delete_end_); 563 download_manager->RemoveDownloadsBetween(delete_begin_, delete_end_);
564 else 564 } else {
565 download_manager->RemoveDownloadsByOriginAndTime( 565 download_manager->RemoveDownloadsByOriginAndTime(
566 remove_origin, delete_begin_, delete_end_); 566 remove_origin, delete_begin_, delete_end_);
567 }
567 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager( 568 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager(
568 download_manager); 569 download_manager);
569 download_prefs->SetSaveFilePath(download_prefs->DownloadPath()); 570 download_prefs->SetSaveFilePath(download_prefs->DownloadPath());
570 } 571 }
571 572
572 uint32_t storage_partition_remove_mask = 0; 573 uint32_t storage_partition_remove_mask = 0;
573 574
574 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, 575 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set,
575 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB 576 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB
576 // don't accidentally remove the cookies that are associated with the 577 // don't accidentally remove the cookies that are associated with the
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 } 692 }
692 693
693 if (remove_mask & REMOVE_PASSWORDS) { 694 if (remove_mask & REMOVE_PASSWORDS) {
694 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); 695 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords"));
695 password_manager::PasswordStore* password_store = 696 password_manager::PasswordStore* password_store =
696 PasswordStoreFactory::GetForProfile( 697 PasswordStoreFactory::GetForProfile(
697 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); 698 profile_, ServiceAccessType::EXPLICIT_ACCESS).get();
698 699
699 if (password_store) { 700 if (password_store) {
700 waiting_for_clear_passwords_ = true; 701 waiting_for_clear_passwords_ = true;
701 password_store->RemoveLoginsCreatedBetween( 702 auto on_cleared_passwords =
702 delete_begin_, delete_end_,
703 base::Bind(&BrowsingDataRemover::OnClearedPasswords, 703 base::Bind(&BrowsingDataRemover::OnClearedPasswords,
704 weak_ptr_factory_.GetWeakPtr())); 704 weak_ptr_factory_.GetWeakPtr());
705 if (remove_url.is_empty()) {
706 password_store->RemoveLoginsCreatedBetween(delete_begin_, delete_end_,
707 on_cleared_passwords);
708 } else {
709 password_store->RemoveLoginsByOriginAndTime(
710 remove_origin, delete_begin_, delete_end_, on_cleared_passwords);
711 }
705 } 712 }
706 } 713 }
707 714
708 if (remove_mask & REMOVE_HISTORY) { 715 if (remove_mask & REMOVE_HISTORY) {
709 password_manager::PasswordStore* password_store = 716 password_manager::PasswordStore* password_store =
710 PasswordStoreFactory::GetForProfile( 717 PasswordStoreFactory::GetForProfile(
711 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); 718 profile_, ServiceAccessType::EXPLICIT_ACCESS).get();
712 719
713 if (password_store) { 720 if (password_store) {
714 waiting_for_clear_passwords_stats_ = true; 721 waiting_for_clear_passwords_stats_ = true;
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 waiting_for_clear_domain_reliability_monitor_ = false; 1195 waiting_for_clear_domain_reliability_monitor_ = false;
1189 NotifyIfDone(); 1196 NotifyIfDone();
1190 } 1197 }
1191 1198
1192 // static 1199 // static
1193 BrowsingDataRemover::CallbackSubscription 1200 BrowsingDataRemover::CallbackSubscription
1194 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( 1201 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback(
1195 const BrowsingDataRemover::Callback& callback) { 1202 const BrowsingDataRemover::Callback& callback) {
1196 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); 1203 return GetOnBrowsingDataRemovedCallbacks()->Add(callback);
1197 } 1204 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover.h ('k') | chrome/browser/browsing_data/browsing_data_remover_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698