Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 waiting_for_clear_content_licenses_(false), | 207 waiting_for_clear_content_licenses_(false), |
| 208 waiting_for_clear_cookies_count_(0), | 208 waiting_for_clear_cookies_count_(0), |
| 209 waiting_for_clear_domain_reliability_monitor_(false), | 209 waiting_for_clear_domain_reliability_monitor_(false), |
| 210 waiting_for_clear_form_(false), | 210 waiting_for_clear_form_(false), |
| 211 waiting_for_clear_history_(false), | 211 waiting_for_clear_history_(false), |
| 212 waiting_for_clear_hostname_resolution_cache_(false), | 212 waiting_for_clear_hostname_resolution_cache_(false), |
| 213 waiting_for_clear_keyword_data_(false), | 213 waiting_for_clear_keyword_data_(false), |
| 214 waiting_for_clear_nacl_cache_(false), | 214 waiting_for_clear_nacl_cache_(false), |
| 215 waiting_for_clear_network_predictor_(false), | 215 waiting_for_clear_network_predictor_(false), |
| 216 waiting_for_clear_networking_history_(false), | 216 waiting_for_clear_networking_history_(false), |
| 217 waiting_for_clear_passwords_(false), | |
| 217 waiting_for_clear_platform_keys_(false), | 218 waiting_for_clear_platform_keys_(false), |
| 218 waiting_for_clear_plugin_data_(false), | 219 waiting_for_clear_plugin_data_(false), |
| 219 waiting_for_clear_pnacl_cache_(false), | 220 waiting_for_clear_pnacl_cache_(false), |
| 220 waiting_for_clear_storage_partition_data_(false), | 221 waiting_for_clear_storage_partition_data_(false), |
| 221 #if defined(ENABLE_WEBRTC) | 222 #if defined(ENABLE_WEBRTC) |
| 222 waiting_for_clear_webrtc_logs_(false), | 223 waiting_for_clear_webrtc_logs_(false), |
| 223 #endif | 224 #endif |
| 224 remove_mask_(0), | 225 remove_mask_(0), |
| 225 remove_origin_(GURL()), | 226 remove_origin_(GURL()), |
| 226 origin_set_mask_(0), | 227 origin_set_mask_(0), |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 CONTENT_SETTINGS_TYPE_APP_BANNER); | 556 CONTENT_SETTINGS_TYPE_APP_BANNER); |
| 556 } | 557 } |
| 557 #endif | 558 #endif |
| 558 | 559 |
| 559 if (remove_mask & REMOVE_PASSWORDS) { | 560 if (remove_mask & REMOVE_PASSWORDS) { |
| 560 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); | 561 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); |
| 561 password_manager::PasswordStore* password_store = | 562 password_manager::PasswordStore* password_store = |
| 562 PasswordStoreFactory::GetForProfile( | 563 PasswordStoreFactory::GetForProfile( |
| 563 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); | 564 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
| 564 | 565 |
| 565 if (password_store) | 566 if (password_store) { |
| 566 password_store->RemoveLoginsCreatedBetween(delete_begin_, delete_end_); | 567 // TrimAffiliationCache() will be called in OnClearedPasswords(), so that |
| 568 // affiliation data corresponding to just deleted passwords can also be | |
| 569 // removed. | |
| 570 waiting_for_clear_passwords_ = true; | |
| 571 password_store->RemoveLoginsCreatedBetween( | |
| 572 delete_begin_, delete_end_, | |
| 573 base::Bind(&BrowsingDataRemover::OnClearedPasswords, | |
| 574 base::Unretained(this))); | |
| 575 } | |
| 576 } else if (remove_mask & REMOVE_CACHE) { | |
| 577 TrimAffiliationCache(); | |
| 567 } | 578 } |
| 568 | 579 |
| 569 if (remove_mask & REMOVE_FORM_DATA) { | 580 if (remove_mask & REMOVE_FORM_DATA) { |
| 570 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); | 581 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); |
| 571 scoped_refptr<autofill::AutofillWebDataService> web_data_service = | 582 scoped_refptr<autofill::AutofillWebDataService> web_data_service = |
| 572 WebDataServiceFactory::GetAutofillWebDataForProfile( | 583 WebDataServiceFactory::GetAutofillWebDataForProfile( |
| 573 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 584 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 574 | 585 |
| 575 if (web_data_service.get()) { | 586 if (web_data_service.get()) { |
| 576 waiting_for_clear_form_ = true; | 587 waiting_for_clear_form_ = true; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 797 !waiting_for_clear_channel_ids_ && | 808 !waiting_for_clear_channel_ids_ && |
| 798 !waiting_for_clear_cookies_count_ && | 809 !waiting_for_clear_cookies_count_ && |
| 799 !waiting_for_clear_domain_reliability_monitor_ && | 810 !waiting_for_clear_domain_reliability_monitor_ && |
| 800 !waiting_for_clear_form_ && | 811 !waiting_for_clear_form_ && |
| 801 !waiting_for_clear_history_ && | 812 !waiting_for_clear_history_ && |
| 802 !waiting_for_clear_hostname_resolution_cache_ && | 813 !waiting_for_clear_hostname_resolution_cache_ && |
| 803 !waiting_for_clear_keyword_data_ && | 814 !waiting_for_clear_keyword_data_ && |
| 804 !waiting_for_clear_nacl_cache_ && | 815 !waiting_for_clear_nacl_cache_ && |
| 805 !waiting_for_clear_network_predictor_ && | 816 !waiting_for_clear_network_predictor_ && |
| 806 !waiting_for_clear_networking_history_ && | 817 !waiting_for_clear_networking_history_ && |
| 818 !waiting_for_clear_passwords_ && | |
| 807 !waiting_for_clear_platform_keys_ && | 819 !waiting_for_clear_platform_keys_ && |
| 808 !waiting_for_clear_plugin_data_ && | 820 !waiting_for_clear_plugin_data_ && |
| 809 !waiting_for_clear_pnacl_cache_ && | 821 !waiting_for_clear_pnacl_cache_ && |
| 810 #if defined(ENABLE_WEBRTC) | 822 #if defined(ENABLE_WEBRTC) |
| 811 !waiting_for_clear_webrtc_logs_ && | 823 !waiting_for_clear_webrtc_logs_ && |
| 812 #endif | 824 #endif |
| 813 !waiting_for_clear_storage_partition_data_; | 825 !waiting_for_clear_storage_partition_data_; |
| 814 } | 826 } |
| 815 | 827 |
| 816 void BrowsingDataRemover::OnKeywordsLoaded() { | 828 void BrowsingDataRemover::OnKeywordsLoaded() { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 996 bool result) { | 1008 bool result) { |
| 997 DCHECK(waiting_for_clear_platform_keys_); | 1009 DCHECK(waiting_for_clear_platform_keys_); |
| 998 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result) { | 1010 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result) { |
| 999 LOG(ERROR) << "Failed to clear platform keys."; | 1011 LOG(ERROR) << "Failed to clear platform keys."; |
| 1000 } | 1012 } |
| 1001 waiting_for_clear_platform_keys_ = false; | 1013 waiting_for_clear_platform_keys_ = false; |
| 1002 NotifyAndDeleteIfDone(); | 1014 NotifyAndDeleteIfDone(); |
| 1003 } | 1015 } |
| 1004 #endif | 1016 #endif |
| 1005 | 1017 |
| 1018 | |
| 1019 void BrowsingDataRemover::OnClearedPasswords() { | |
| 1020 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 1021 waiting_for_clear_passwords_ = false; | |
| 1022 TrimAffiliationCache(); | |
|
Mike West
2015/05/13 15:20:06
Ideally, we'd wait on this as well.
| |
| 1023 NotifyAndDeleteIfDone(); | |
| 1024 } | |
| 1025 | |
| 1026 void BrowsingDataRemover::TrimAffiliationCache() { | |
| 1027 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 1028 PasswordStoreFactory::TrimOrDeleteAffiliationCache(profile_); | |
|
Mike West
2015/05/13 15:20:06
Ideally, we'd have tests showing that this method
| |
| 1029 } | |
| 1030 | |
| 1006 void BrowsingDataRemover::OnClearedCookies(int num_deleted) { | 1031 void BrowsingDataRemover::OnClearedCookies(int num_deleted) { |
| 1007 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 1032 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 1008 BrowserThread::PostTask( | 1033 BrowserThread::PostTask( |
| 1009 BrowserThread::UI, FROM_HERE, | 1034 BrowserThread::UI, FROM_HERE, |
| 1010 base::Bind(&BrowsingDataRemover::OnClearedCookies, | 1035 base::Bind(&BrowsingDataRemover::OnClearedCookies, |
| 1011 base::Unretained(this), num_deleted)); | 1036 base::Unretained(this), num_deleted)); |
| 1012 return; | 1037 return; |
| 1013 } | 1038 } |
| 1014 | 1039 |
| 1015 DCHECK_GT(waiting_for_clear_cookies_count_, 0); | 1040 DCHECK_GT(waiting_for_clear_cookies_count_, 0); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 waiting_for_clear_domain_reliability_monitor_ = false; | 1115 waiting_for_clear_domain_reliability_monitor_ = false; |
| 1091 NotifyAndDeleteIfDone(); | 1116 NotifyAndDeleteIfDone(); |
| 1092 } | 1117 } |
| 1093 | 1118 |
| 1094 // static | 1119 // static |
| 1095 BrowsingDataRemover::CallbackSubscription | 1120 BrowsingDataRemover::CallbackSubscription |
| 1096 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( | 1121 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( |
| 1097 const BrowsingDataRemover::Callback& callback) { | 1122 const BrowsingDataRemover::Callback& callback) { |
| 1098 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); | 1123 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); |
| 1099 } | 1124 } |
| OLD | NEW |