| 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 #include <utility> | 10 #include <utility> |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 #include "extensions/features/features.h" | 82 #include "extensions/features/features.h" |
| 83 #include "net/base/net_errors.h" | 83 #include "net/base/net_errors.h" |
| 84 #include "net/cookies/cookie_store.h" | 84 #include "net/cookies/cookie_store.h" |
| 85 #include "net/http/http_network_session.h" | 85 #include "net/http/http_network_session.h" |
| 86 #include "net/http/http_transaction_factory.h" | 86 #include "net/http/http_transaction_factory.h" |
| 87 #include "net/http/transport_security_state.h" | 87 #include "net/http/transport_security_state.h" |
| 88 #include "net/ssl/channel_id_service.h" | 88 #include "net/ssl/channel_id_service.h" |
| 89 #include "net/ssl/channel_id_store.h" | 89 #include "net/ssl/channel_id_store.h" |
| 90 #include "net/url_request/url_request_context.h" | 90 #include "net/url_request/url_request_context.h" |
| 91 #include "net/url_request/url_request_context_getter.h" | 91 #include "net/url_request/url_request_context_getter.h" |
| 92 #include "ppapi/features/features.h" |
| 92 #include "storage/browser/quota/special_storage_policy.h" | 93 #include "storage/browser/quota/special_storage_policy.h" |
| 93 #include "url/origin.h" | 94 #include "url/origin.h" |
| 94 | 95 |
| 95 #if BUILDFLAG(ANDROID_JAVA_UI) | 96 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 96 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 97 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| 97 #include "chrome/browser/android/webapps/webapp_registry.h" | 98 #include "chrome/browser/android/webapps/webapp_registry.h" |
| 98 #include "chrome/browser/precache/precache_manager_factory.h" | 99 #include "chrome/browser/precache/precache_manager_factory.h" |
| 99 #include "components/offline_pages/offline_page_feature.h" | 100 #include "components/offline_pages/offline_page_feature.h" |
| 100 #include "components/offline_pages/offline_page_model.h" | 101 #include "components/offline_pages/offline_page_model.h" |
| 101 #include "components/precache/content/precache_manager.h" | 102 #include "components/precache/content/precache_manager.h" |
| 102 #endif | 103 #endif |
| 103 | 104 |
| 104 #if BUILDFLAG(ENABLE_EXTENSIONS) | 105 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 105 #include "chrome/browser/extensions/activity_log/activity_log.h" | 106 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 106 #include "extensions/browser/extension_prefs.h" | 107 #include "extensions/browser/extension_prefs.h" |
| 107 #endif | 108 #endif |
| 108 | 109 |
| 109 #if defined(ENABLE_PLUGINS) | 110 #if BUILDFLAG(ENABLE_PLUGINS) |
| 110 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" | 111 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" |
| 111 #endif | 112 #endif |
| 112 | 113 |
| 113 #if BUILDFLAG(ENABLE_SESSION_SERVICE) | 114 #if BUILDFLAG(ENABLE_SESSION_SERVICE) |
| 114 #include "chrome/browser/sessions/session_service.h" | 115 #include "chrome/browser/sessions/session_service.h" |
| 115 #include "chrome/browser/sessions/session_service_factory.h" | 116 #include "chrome/browser/sessions/session_service_factory.h" |
| 116 #endif | 117 #endif |
| 117 | 118 |
| 118 #if defined(OS_CHROMEOS) | 119 #if defined(OS_CHROMEOS) |
| 119 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 120 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 317 } |
| 317 return TimeRange(CalculateBeginDeleteTime(period), base::Time::Max()); | 318 return TimeRange(CalculateBeginDeleteTime(period), base::Time::Max()); |
| 318 } | 319 } |
| 319 | 320 |
| 320 BrowsingDataRemover::BrowsingDataRemover( | 321 BrowsingDataRemover::BrowsingDataRemover( |
| 321 content::BrowserContext* browser_context) | 322 content::BrowserContext* browser_context) |
| 322 : profile_(Profile::FromBrowserContext(browser_context)), | 323 : profile_(Profile::FromBrowserContext(browser_context)), |
| 323 remove_mask_(-1), | 324 remove_mask_(-1), |
| 324 origin_type_mask_(-1), | 325 origin_type_mask_(-1), |
| 325 is_removing_(false), | 326 is_removing_(false), |
| 326 #if defined(ENABLE_PLUGINS) | 327 #if BUILDFLAG(ENABLE_PLUGINS) |
| 327 flash_lso_helper_(BrowsingDataFlashLSOHelper::Create(profile_)), | 328 flash_lso_helper_(BrowsingDataFlashLSOHelper::Create(profile_)), |
| 328 #endif | 329 #endif |
| 329 #if BUILDFLAG(ANDROID_JAVA_UI) | 330 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 330 webapp_registry_(new WebappRegistry()), | 331 webapp_registry_(new WebappRegistry()), |
| 331 #endif | 332 #endif |
| 332 weak_ptr_factory_(this) { | 333 weak_ptr_factory_(this) { |
| 333 DCHECK(browser_context); | 334 DCHECK(browser_context); |
| 334 } | 335 } |
| 335 | 336 |
| 336 BrowsingDataRemover::~BrowsingDataRemover() { | 337 BrowsingDataRemover::~BrowsingDataRemover() { |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 } | 844 } |
| 844 if (remove_mask & REMOVE_CACHE_STORAGE) { | 845 if (remove_mask & REMOVE_CACHE_STORAGE) { |
| 845 storage_partition_remove_mask |= | 846 storage_partition_remove_mask |= |
| 846 content::StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE; | 847 content::StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE; |
| 847 } | 848 } |
| 848 if (remove_mask & REMOVE_FILE_SYSTEMS) { | 849 if (remove_mask & REMOVE_FILE_SYSTEMS) { |
| 849 storage_partition_remove_mask |= | 850 storage_partition_remove_mask |= |
| 850 content::StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS; | 851 content::StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS; |
| 851 } | 852 } |
| 852 | 853 |
| 853 #if defined(ENABLE_PLUGINS) | 854 #if BUILDFLAG(ENABLE_PLUGINS) |
| 854 // Plugin is data not separated for protected and unprotected web origins. We | 855 // Plugin is data not separated for protected and unprotected web origins. We |
| 855 // check the origin_type_mask_ to prevent unintended deletion. | 856 // check the origin_type_mask_ to prevent unintended deletion. |
| 856 if (remove_mask & REMOVE_PLUGIN_DATA && | 857 if (remove_mask & REMOVE_PLUGIN_DATA && |
| 857 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | 858 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { |
| 858 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); | 859 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); |
| 859 waiting_for_clear_plugin_data_count_ = 1; | 860 waiting_for_clear_plugin_data_count_ = 1; |
| 860 | 861 |
| 861 if (filter_builder.IsEmptyBlacklist()) { | 862 if (filter_builder.IsEmptyBlacklist()) { |
| 862 DCHECK(!plugin_data_remover_); | 863 DCHECK(!plugin_data_remover_); |
| 863 plugin_data_remover_.reset(content::PluginDataRemover::Create(profile_)); | 864 plugin_data_remover_.reset(content::PluginDataRemover::Create(profile_)); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 base::Bind(&BrowsingDataRemover::OnClearedStoragePartitionData, | 1110 base::Bind(&BrowsingDataRemover::OnClearedStoragePartitionData, |
| 1110 weak_ptr_factory_.GetWeakPtr())); | 1111 weak_ptr_factory_.GetWeakPtr())); |
| 1111 } | 1112 } |
| 1112 | 1113 |
| 1113 if (remove_mask & REMOVE_MEDIA_LICENSES) { | 1114 if (remove_mask & REMOVE_MEDIA_LICENSES) { |
| 1114 // TODO(jrummell): This UMA should be renamed to indicate it is for Media | 1115 // TODO(jrummell): This UMA should be renamed to indicate it is for Media |
| 1115 // Licenses. | 1116 // Licenses. |
| 1116 content::RecordAction( | 1117 content::RecordAction( |
| 1117 UserMetricsAction("ClearBrowsingData_ContentLicenses")); | 1118 UserMetricsAction("ClearBrowsingData_ContentLicenses")); |
| 1118 | 1119 |
| 1119 #if defined(ENABLE_PLUGINS) | 1120 #if BUILDFLAG(ENABLE_PLUGINS) |
| 1120 waiting_for_clear_flash_content_licenses_ = true; | 1121 waiting_for_clear_flash_content_licenses_ = true; |
| 1121 if (!pepper_flash_settings_manager_.get()) { | 1122 if (!pepper_flash_settings_manager_.get()) { |
| 1122 pepper_flash_settings_manager_.reset( | 1123 pepper_flash_settings_manager_.reset( |
| 1123 new PepperFlashSettingsManager(this, profile_)); | 1124 new PepperFlashSettingsManager(this, profile_)); |
| 1124 } | 1125 } |
| 1125 deauthorize_flash_content_licenses_request_id_ = | 1126 deauthorize_flash_content_licenses_request_id_ = |
| 1126 pepper_flash_settings_manager_->DeauthorizeContentLicenses(prefs); | 1127 pepper_flash_settings_manager_->DeauthorizeContentLicenses(prefs); |
| 1127 #if defined(OS_CHROMEOS) | 1128 #if defined(OS_CHROMEOS) |
| 1128 // On Chrome OS, also delete any content protection platform keys. | 1129 // On Chrome OS, also delete any content protection platform keys. |
| 1129 const user_manager::User* user = | 1130 const user_manager::User* user = |
| 1130 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_); | 1131 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_); |
| 1131 if (!user) { | 1132 if (!user) { |
| 1132 LOG(WARNING) << "Failed to find user for current profile."; | 1133 LOG(WARNING) << "Failed to find user for current profile."; |
| 1133 } else { | 1134 } else { |
| 1134 chromeos::DBusThreadManager::Get() | 1135 chromeos::DBusThreadManager::Get() |
| 1135 ->GetCryptohomeClient() | 1136 ->GetCryptohomeClient() |
| 1136 ->TpmAttestationDeleteKeys( | 1137 ->TpmAttestationDeleteKeys( |
| 1137 chromeos::attestation::KEY_USER, | 1138 chromeos::attestation::KEY_USER, |
| 1138 cryptohome::Identification(user->GetAccountId()), | 1139 cryptohome::Identification(user->GetAccountId()), |
| 1139 chromeos::attestation::kContentProtectionKeyPrefix, | 1140 chromeos::attestation::kContentProtectionKeyPrefix, |
| 1140 base::Bind(&BrowsingDataRemover::OnClearPlatformKeys, | 1141 base::Bind(&BrowsingDataRemover::OnClearPlatformKeys, |
| 1141 weak_ptr_factory_.GetWeakPtr())); | 1142 weak_ptr_factory_.GetWeakPtr())); |
| 1142 waiting_for_clear_platform_keys_ = true; | 1143 waiting_for_clear_platform_keys_ = true; |
| 1143 } | 1144 } |
| 1144 #endif // defined(OS_CHROMEOS) | 1145 #endif // defined(OS_CHROMEOS) |
| 1145 #endif // defined(ENABLE_PLUGINS) | 1146 #endif // BUILDFLAG(ENABLE_PLUGINS) |
| 1146 } | 1147 } |
| 1147 | 1148 |
| 1148 // Remove omnibox zero-suggest cache results. Filtering is not supported. | 1149 // Remove omnibox zero-suggest cache results. Filtering is not supported. |
| 1149 // This is not a problem, as deleting more data than necessary will just cause | 1150 // This is not a problem, as deleting more data than necessary will just cause |
| 1150 // another server round-trip; no data is actually lost. | 1151 // another server round-trip; no data is actually lost. |
| 1151 if ((remove_mask & (REMOVE_CACHE | REMOVE_COOKIES))) | 1152 if ((remove_mask & (REMOVE_CACHE | REMOVE_COOKIES))) |
| 1152 prefs->SetString(omnibox::kZeroSuggestCachedResults, std::string()); | 1153 prefs->SetString(omnibox::kZeroSuggestCachedResults, std::string()); |
| 1153 | 1154 |
| 1154 if (remove_mask & (REMOVE_COOKIES | REMOVE_HISTORY)) { | 1155 if (remove_mask & (REMOVE_COOKIES | REMOVE_HISTORY)) { |
| 1155 domain_reliability::DomainReliabilityService* service = | 1156 domain_reliability::DomainReliabilityService* service = |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 storage_partition_for_testing_ = storage_partition; | 1220 storage_partition_for_testing_ = storage_partition; |
| 1220 } | 1221 } |
| 1221 | 1222 |
| 1222 #if BUILDFLAG(ANDROID_JAVA_UI) | 1223 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 1223 void BrowsingDataRemover::OverrideWebappRegistryForTesting( | 1224 void BrowsingDataRemover::OverrideWebappRegistryForTesting( |
| 1224 std::unique_ptr<WebappRegistry> webapp_registry) { | 1225 std::unique_ptr<WebappRegistry> webapp_registry) { |
| 1225 webapp_registry_ = std::move(webapp_registry); | 1226 webapp_registry_ = std::move(webapp_registry); |
| 1226 } | 1227 } |
| 1227 #endif | 1228 #endif |
| 1228 | 1229 |
| 1229 #if defined(ENABLE_PLUGINS) | 1230 #if BUILDFLAG(ENABLE_PLUGINS) |
| 1230 void BrowsingDataRemover::OverrideFlashLSOHelperForTesting( | 1231 void BrowsingDataRemover::OverrideFlashLSOHelperForTesting( |
| 1231 scoped_refptr<BrowsingDataFlashLSOHelper> flash_lso_helper) { | 1232 scoped_refptr<BrowsingDataFlashLSOHelper> flash_lso_helper) { |
| 1232 flash_lso_helper_ = flash_lso_helper; | 1233 flash_lso_helper_ = flash_lso_helper; |
| 1233 } | 1234 } |
| 1234 #endif | 1235 #endif |
| 1235 | 1236 |
| 1236 const base::Time& BrowsingDataRemover::GetLastUsedBeginTime() { | 1237 const base::Time& BrowsingDataRemover::GetLastUsedBeginTime() { |
| 1237 return delete_begin_; | 1238 return delete_begin_; |
| 1238 } | 1239 } |
| 1239 | 1240 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1402 NotifyIfDone(); | 1403 NotifyIfDone(); |
| 1403 } | 1404 } |
| 1404 | 1405 |
| 1405 void BrowsingDataRemover::ClearedPnaclCache() { | 1406 void BrowsingDataRemover::ClearedPnaclCache() { |
| 1406 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1407 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1407 waiting_for_clear_pnacl_cache_ = false; | 1408 waiting_for_clear_pnacl_cache_ = false; |
| 1408 NotifyIfDone(); | 1409 NotifyIfDone(); |
| 1409 } | 1410 } |
| 1410 #endif | 1411 #endif |
| 1411 | 1412 |
| 1412 #if defined(ENABLE_PLUGINS) | 1413 #if BUILDFLAG(ENABLE_PLUGINS) |
| 1413 void BrowsingDataRemover::OnWaitableEventSignaled( | 1414 void BrowsingDataRemover::OnWaitableEventSignaled( |
| 1414 base::WaitableEvent* waitable_event) { | 1415 base::WaitableEvent* waitable_event) { |
| 1415 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1416 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1416 | 1417 |
| 1417 DCHECK_EQ(1, waiting_for_clear_plugin_data_count_); | 1418 DCHECK_EQ(1, waiting_for_clear_plugin_data_count_); |
| 1418 waiting_for_clear_plugin_data_count_ = 0; | 1419 waiting_for_clear_plugin_data_count_ = 0; |
| 1419 | 1420 |
| 1420 plugin_data_remover_.reset(); | 1421 plugin_data_remover_.reset(); |
| 1421 watcher_.StopWatching(); | 1422 watcher_.StopWatching(); |
| 1422 NotifyIfDone(); | 1423 NotifyIfDone(); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 waiting_for_clear_offline_page_data_ = false; | 1547 waiting_for_clear_offline_page_data_ = false; |
| 1547 NotifyIfDone(); | 1548 NotifyIfDone(); |
| 1548 } | 1549 } |
| 1549 #endif | 1550 #endif |
| 1550 | 1551 |
| 1551 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { | 1552 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { |
| 1552 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1553 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1553 waiting_for_clear_domain_reliability_monitor_ = false; | 1554 waiting_for_clear_domain_reliability_monitor_ = false; |
| 1554 NotifyIfDone(); | 1555 NotifyIfDone(); |
| 1555 } | 1556 } |
| OLD | NEW |