| 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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 base::Bind( | 626 base::Bind( |
| 627 &WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles, | 627 &WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles, |
| 628 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()), | 628 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()), |
| 629 delete_begin_), | 629 delete_begin_), |
| 630 base::Bind(&BrowsingDataRemover::OnClearedWebRtcLogs, | 630 base::Bind(&BrowsingDataRemover::OnClearedWebRtcLogs, |
| 631 weak_ptr_factory_.GetWeakPtr())); | 631 weak_ptr_factory_.GetWeakPtr())); |
| 632 #endif | 632 #endif |
| 633 | 633 |
| 634 // The SSL Host State that tracks SSL interstitial "proceed" decisions may | 634 // The SSL Host State that tracks SSL interstitial "proceed" decisions may |
| 635 // include origins that the user has visited, so it must be cleared. | 635 // include origins that the user has visited, so it must be cleared. |
| 636 if (profile_->GetSSLHostStateDelegate()) | 636 // TODO(msramek): We can reuse the plugin filter here, since both plugins |
| 637 profile_->GetSSLHostStateDelegate()->Clear(); | 637 // and SSL host state are scoped to hosts and represent them as std::string. |
| 638 // Rename the method to indicate its more general usage. |
| 639 if (profile_->GetSSLHostStateDelegate()) { |
| 640 profile_->GetSSLHostStateDelegate()->Clear( |
| 641 filter_builder.IsEmptyBlacklist() |
| 642 ? base::Callback<bool(const std::string&)>() |
| 643 : filter_builder.BuildPluginFilter()); |
| 644 } |
| 638 | 645 |
| 639 #if BUILDFLAG(ANDROID_JAVA_UI) | 646 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 640 precache::PrecacheManager* precache_manager = | 647 precache::PrecacheManager* precache_manager = |
| 641 precache::PrecacheManagerFactory::GetForBrowserContext(profile_); | 648 precache::PrecacheManagerFactory::GetForBrowserContext(profile_); |
| 642 // |precache_manager| could be nullptr if the profile is off the record. | 649 // |precache_manager| could be nullptr if the profile is off the record. |
| 643 if (!precache_manager) { | 650 if (!precache_manager) { |
| 644 waiting_for_clear_precache_history_ = true; | 651 waiting_for_clear_precache_history_ = true; |
| 645 precache_manager->ClearHistory(); | 652 precache_manager->ClearHistory(); |
| 646 // The above calls are done on the UI thread but do their work on the DB | 653 // The above calls are done on the UI thread but do their work on the DB |
| 647 // thread. So wait for it. | 654 // thread. So wait for it. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 // object to avoid having to copy them to callback methods. | 816 // object to avoid having to copy them to callback methods. |
| 810 flash_lso_helper_->StartFetching(base::Bind( | 817 flash_lso_helper_->StartFetching(base::Bind( |
| 811 &BrowsingDataRemover::OnSitesWithFlashDataFetched, | 818 &BrowsingDataRemover::OnSitesWithFlashDataFetched, |
| 812 weak_ptr_factory_.GetWeakPtr(), | 819 weak_ptr_factory_.GetWeakPtr(), |
| 813 filter_builder.BuildPluginFilter())); | 820 filter_builder.BuildPluginFilter())); |
| 814 } | 821 } |
| 815 } | 822 } |
| 816 #endif | 823 #endif |
| 817 | 824 |
| 818 if (remove_mask & REMOVE_SITE_USAGE_DATA) { | 825 if (remove_mask & REMOVE_SITE_USAGE_DATA) { |
| 819 ClearSettingsForOneTypeWithPredicate( | 826 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 820 HostContentSettingsMapFactory::GetForProfile(profile_), | 827 ->ClearSettingsForOneTypeWithPredicate( |
| 821 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, | 828 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 822 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); | 829 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); |
| 823 } | 830 } |
| 824 | 831 |
| 825 if (remove_mask & REMOVE_SITE_USAGE_DATA || remove_mask & REMOVE_HISTORY) { | 832 if (remove_mask & REMOVE_SITE_USAGE_DATA || remove_mask & REMOVE_HISTORY) { |
| 826 ClearSettingsForOneTypeWithPredicate( | 833 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 827 HostContentSettingsMapFactory::GetForProfile(profile_), | 834 ->ClearSettingsForOneTypeWithPredicate( |
| 828 CONTENT_SETTINGS_TYPE_APP_BANNER, | 835 CONTENT_SETTINGS_TYPE_APP_BANNER, |
| 829 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); | 836 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); |
| 830 | 837 |
| 831 PermissionDecisionAutoBlocker::RemoveCountsByUrl(profile_, filter); | 838 PermissionDecisionAutoBlocker::RemoveCountsByUrl(profile_, filter); |
| 832 } | 839 } |
| 833 | 840 |
| 834 if (remove_mask & REMOVE_PASSWORDS) { | 841 if (remove_mask & REMOVE_PASSWORDS) { |
| 835 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); | 842 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); |
| 836 password_manager::PasswordStore* password_store = | 843 password_manager::PasswordStore* password_store = |
| 837 PasswordStoreFactory::GetForProfile( | 844 PasswordStoreFactory::GetForProfile( |
| 838 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); | 845 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
| 839 | 846 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder, | 1175 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder, |
| 1169 Observer* observer) | 1176 Observer* observer) |
| 1170 : time_range(time_range), | 1177 : time_range(time_range), |
| 1171 remove_mask(remove_mask), | 1178 remove_mask(remove_mask), |
| 1172 origin_type_mask(origin_type_mask), | 1179 origin_type_mask(origin_type_mask), |
| 1173 filter_builder(std::move(filter_builder)), | 1180 filter_builder(std::move(filter_builder)), |
| 1174 observer(observer) {} | 1181 observer(observer) {} |
| 1175 | 1182 |
| 1176 BrowsingDataRemover::RemovalTask::~RemovalTask() {} | 1183 BrowsingDataRemover::RemovalTask::~RemovalTask() {} |
| 1177 | 1184 |
| 1178 void BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( | |
| 1179 HostContentSettingsMap* content_settings_map, | |
| 1180 ContentSettingsType content_type, | |
| 1181 const base::Callback<bool(const ContentSettingsPattern& primary_pattern, | |
| 1182 const ContentSettingsPattern& secondary_pattern)>& | |
| 1183 predicate) { | |
| 1184 ContentSettingsForOneType settings; | |
| 1185 content_settings_map->GetSettingsForOneType(content_type, std::string(), | |
| 1186 &settings); | |
| 1187 for (const ContentSettingPatternSource& setting : settings) { | |
| 1188 if (predicate.Run(setting.primary_pattern, setting.secondary_pattern)) { | |
| 1189 content_settings_map->SetWebsiteSettingCustomScope( | |
| 1190 setting.primary_pattern, setting.secondary_pattern, content_type, | |
| 1191 std::string(), nullptr); | |
| 1192 } | |
| 1193 } | |
| 1194 } | |
| 1195 | |
| 1196 bool BrowsingDataRemover::AllDone() { | 1185 bool BrowsingDataRemover::AllDone() { |
| 1197 return !waiting_for_synchronous_clear_operations_ && | 1186 return !waiting_for_synchronous_clear_operations_ && |
| 1198 !waiting_for_clear_autofill_origin_urls_ && | 1187 !waiting_for_clear_autofill_origin_urls_ && |
| 1199 !waiting_for_clear_cache_ && | 1188 !waiting_for_clear_cache_ && |
| 1200 !waiting_for_clear_flash_content_licenses_ && | 1189 !waiting_for_clear_flash_content_licenses_ && |
| 1201 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && | 1190 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && |
| 1202 !waiting_for_clear_domain_reliability_monitor_ && | 1191 !waiting_for_clear_domain_reliability_monitor_ && |
| 1203 !waiting_for_clear_form_ && !waiting_for_clear_history_ && | 1192 !waiting_for_clear_form_ && !waiting_for_clear_history_ && |
| 1204 !waiting_for_clear_hostname_resolution_cache_ && | 1193 !waiting_for_clear_hostname_resolution_cache_ && |
| 1205 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && | 1194 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 waiting_for_clear_offline_page_data_ = false; | 1470 waiting_for_clear_offline_page_data_ = false; |
| 1482 NotifyIfDone(); | 1471 NotifyIfDone(); |
| 1483 } | 1472 } |
| 1484 #endif | 1473 #endif |
| 1485 | 1474 |
| 1486 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { | 1475 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { |
| 1487 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1476 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1488 waiting_for_clear_domain_reliability_monitor_ = false; | 1477 waiting_for_clear_domain_reliability_monitor_ = false; |
| 1489 NotifyIfDone(); | 1478 NotifyIfDone(); |
| 1490 } | 1479 } |
| OLD | NEW |