| 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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 base::Bind( | 660 base::Bind( |
| 661 &WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles, | 661 &WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles, |
| 662 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()), | 662 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()), |
| 663 delete_begin_), | 663 delete_begin_), |
| 664 base::Bind(&BrowsingDataRemover::OnClearedWebRtcLogs, | 664 base::Bind(&BrowsingDataRemover::OnClearedWebRtcLogs, |
| 665 weak_ptr_factory_.GetWeakPtr())); | 665 weak_ptr_factory_.GetWeakPtr())); |
| 666 #endif | 666 #endif |
| 667 | 667 |
| 668 // The SSL Host State that tracks SSL interstitial "proceed" decisions may | 668 // The SSL Host State that tracks SSL interstitial "proceed" decisions may |
| 669 // include origins that the user has visited, so it must be cleared. | 669 // include origins that the user has visited, so it must be cleared. |
| 670 if (profile_->GetSSLHostStateDelegate()) | 670 // TODO(msramek): We can reuse the plugin filter here, since both plugins |
| 671 profile_->GetSSLHostStateDelegate()->Clear(); | 671 // and SSL host state are scoped to hosts and represent them as std::string. |
| 672 // Rename the method to indicate its more general usage. |
| 673 if (profile_->GetSSLHostStateDelegate()) { |
| 674 profile_->GetSSLHostStateDelegate()->Clear( |
| 675 filter_builder.IsEmptyBlacklist() |
| 676 ? base::Callback<bool(const std::string&)>() |
| 677 : filter_builder.BuildPluginFilter()); |
| 678 } |
| 672 | 679 |
| 673 #if BUILDFLAG(ANDROID_JAVA_UI) | 680 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 674 precache::PrecacheManager* precache_manager = | 681 precache::PrecacheManager* precache_manager = |
| 675 precache::PrecacheManagerFactory::GetForBrowserContext(profile_); | 682 precache::PrecacheManagerFactory::GetForBrowserContext(profile_); |
| 676 // |precache_manager| could be nullptr if the profile is off the record. | 683 // |precache_manager| could be nullptr if the profile is off the record. |
| 677 if (!precache_manager) { | 684 if (!precache_manager) { |
| 678 waiting_for_clear_precache_history_ = true; | 685 waiting_for_clear_precache_history_ = true; |
| 679 precache_manager->ClearHistory(); | 686 precache_manager->ClearHistory(); |
| 680 // The above calls are done on the UI thread but do their work on the DB | 687 // The above calls are done on the UI thread but do their work on the DB |
| 681 // thread. So wait for it. | 688 // thread. So wait for it. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 // object to avoid having to copy them to callback methods. | 850 // object to avoid having to copy them to callback methods. |
| 844 flash_lso_helper_->StartFetching(base::Bind( | 851 flash_lso_helper_->StartFetching(base::Bind( |
| 845 &BrowsingDataRemover::OnSitesWithFlashDataFetched, | 852 &BrowsingDataRemover::OnSitesWithFlashDataFetched, |
| 846 weak_ptr_factory_.GetWeakPtr(), | 853 weak_ptr_factory_.GetWeakPtr(), |
| 847 filter_builder.BuildPluginFilter())); | 854 filter_builder.BuildPluginFilter())); |
| 848 } | 855 } |
| 849 } | 856 } |
| 850 #endif | 857 #endif |
| 851 | 858 |
| 852 if (remove_mask & REMOVE_SITE_USAGE_DATA) { | 859 if (remove_mask & REMOVE_SITE_USAGE_DATA) { |
| 853 ClearSettingsForOneTypeWithPredicate( | 860 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 854 HostContentSettingsMapFactory::GetForProfile(profile_), | 861 ->ClearSettingsForOneTypeWithPredicate( |
| 855 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, | 862 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 856 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); | 863 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); |
| 857 } | 864 } |
| 858 | 865 |
| 859 if (remove_mask & REMOVE_SITE_USAGE_DATA || remove_mask & REMOVE_HISTORY) { | 866 if (remove_mask & REMOVE_SITE_USAGE_DATA || remove_mask & REMOVE_HISTORY) { |
| 860 ClearSettingsForOneTypeWithPredicate( | 867 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 861 HostContentSettingsMapFactory::GetForProfile(profile_), | 868 ->ClearSettingsForOneTypeWithPredicate( |
| 862 CONTENT_SETTINGS_TYPE_APP_BANNER, | 869 CONTENT_SETTINGS_TYPE_APP_BANNER, |
| 863 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); | 870 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); |
| 864 | 871 |
| 865 PermissionDecisionAutoBlocker::RemoveCountsByUrl(profile_, filter); | 872 PermissionDecisionAutoBlocker::RemoveCountsByUrl(profile_, filter); |
| 866 } | 873 } |
| 867 | 874 |
| 868 if (remove_mask & REMOVE_PASSWORDS) { | 875 if (remove_mask & REMOVE_PASSWORDS) { |
| 869 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); | 876 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); |
| 870 password_manager::PasswordStore* password_store = | 877 password_manager::PasswordStore* password_store = |
| 871 PasswordStoreFactory::GetForProfile( | 878 PasswordStoreFactory::GetForProfile( |
| 872 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); | 879 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
| 873 | 880 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder, | 1225 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder, |
| 1219 Observer* observer) | 1226 Observer* observer) |
| 1220 : time_range(time_range), | 1227 : time_range(time_range), |
| 1221 remove_mask(remove_mask), | 1228 remove_mask(remove_mask), |
| 1222 origin_type_mask(origin_type_mask), | 1229 origin_type_mask(origin_type_mask), |
| 1223 filter_builder(std::move(filter_builder)), | 1230 filter_builder(std::move(filter_builder)), |
| 1224 observer(observer) {} | 1231 observer(observer) {} |
| 1225 | 1232 |
| 1226 BrowsingDataRemover::RemovalTask::~RemovalTask() {} | 1233 BrowsingDataRemover::RemovalTask::~RemovalTask() {} |
| 1227 | 1234 |
| 1228 void BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( | |
| 1229 HostContentSettingsMap* content_settings_map, | |
| 1230 ContentSettingsType content_type, | |
| 1231 const base::Callback<bool(const ContentSettingsPattern& primary_pattern, | |
| 1232 const ContentSettingsPattern& secondary_pattern)>& | |
| 1233 predicate) { | |
| 1234 ContentSettingsForOneType settings; | |
| 1235 content_settings_map->GetSettingsForOneType(content_type, std::string(), | |
| 1236 &settings); | |
| 1237 for (const ContentSettingPatternSource& setting : settings) { | |
| 1238 if (predicate.Run(setting.primary_pattern, setting.secondary_pattern)) { | |
| 1239 content_settings_map->SetWebsiteSettingCustomScope( | |
| 1240 setting.primary_pattern, setting.secondary_pattern, content_type, | |
| 1241 std::string(), nullptr); | |
| 1242 } | |
| 1243 } | |
| 1244 } | |
| 1245 | |
| 1246 bool BrowsingDataRemover::AllDone() { | 1235 bool BrowsingDataRemover::AllDone() { |
| 1247 return !waiting_for_synchronous_clear_operations_ && | 1236 return !waiting_for_synchronous_clear_operations_ && |
| 1248 !waiting_for_clear_autofill_origin_urls_ && | 1237 !waiting_for_clear_autofill_origin_urls_ && |
| 1249 !waiting_for_clear_cache_ && | 1238 !waiting_for_clear_cache_ && |
| 1250 !waiting_for_clear_flash_content_licenses_ && | 1239 !waiting_for_clear_flash_content_licenses_ && |
| 1251 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && | 1240 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && |
| 1252 !waiting_for_clear_domain_reliability_monitor_ && | 1241 !waiting_for_clear_domain_reliability_monitor_ && |
| 1253 !waiting_for_clear_form_ && !waiting_for_clear_history_ && | 1242 !waiting_for_clear_form_ && !waiting_for_clear_history_ && |
| 1254 !waiting_for_clear_hostname_resolution_cache_ && | 1243 !waiting_for_clear_hostname_resolution_cache_ && |
| 1255 !waiting_for_clear_http_auth_cache_ && | 1244 !waiting_for_clear_http_auth_cache_ && |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 waiting_for_clear_offline_page_data_ = false; | 1529 waiting_for_clear_offline_page_data_ = false; |
| 1541 NotifyIfDone(); | 1530 NotifyIfDone(); |
| 1542 } | 1531 } |
| 1543 #endif | 1532 #endif |
| 1544 | 1533 |
| 1545 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { | 1534 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { |
| 1546 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1535 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1547 waiting_for_clear_domain_reliability_monitor_ = false; | 1536 waiting_for_clear_domain_reliability_monitor_ = false; |
| 1548 NotifyIfDone(); | 1537 NotifyIfDone(); |
| 1549 } | 1538 } |
| OLD | NEW |