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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 #if defined(ENABLE_SESSION_SERVICE) | 107 #if defined(ENABLE_SESSION_SERVICE) |
| 108 #include "chrome/browser/sessions/session_service.h" | 108 #include "chrome/browser/sessions/session_service.h" |
| 109 #include "chrome/browser/sessions/session_service_factory.h" | 109 #include "chrome/browser/sessions/session_service_factory.h" |
| 110 #endif | 110 #endif |
| 111 | 111 |
| 112 #if defined(ENABLE_WEBRTC) | 112 #if defined(ENABLE_WEBRTC) |
| 113 #include "chrome/browser/media/webrtc_log_list.h" | 113 #include "chrome/browser/media/webrtc_log_list.h" |
| 114 #include "chrome/browser/media/webrtc_log_util.h" | 114 #include "chrome/browser/media/webrtc_log_util.h" |
| 115 #endif | 115 #endif |
| 116 | 116 |
| 117 #if defined(ENABLE_PLUGINS) | |
|
Bernhard Bauer
2016/08/18 18:35:59
Move this between ENABLE_EXTENSIONS and ENABLE_SES
msramek
2016/08/19 11:16:46
Done. Also moved the "OS_CHROMEOS" section down. I
| |
| 118 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" | |
| 119 #endif | |
| 120 | |
| 117 using base::UserMetricsAction; | 121 using base::UserMetricsAction; |
| 118 using content::BrowserContext; | 122 using content::BrowserContext; |
| 119 using content::BrowserThread; | 123 using content::BrowserThread; |
| 120 using content::DOMStorageContext; | 124 using content::DOMStorageContext; |
| 121 | 125 |
| 122 namespace { | 126 namespace { |
| 123 | 127 |
| 124 void UIThreadTrampolineHelper(const base::Closure& callback) { | 128 void UIThreadTrampolineHelper(const base::Closure& callback) { |
| 125 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 129 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); |
| 126 } | 130 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 case browsing_data::ALL_TIME: | 286 case browsing_data::ALL_TIME: |
| 283 content::RecordAction(UserMetricsAction("ClearBrowsingData_Everything")); | 287 content::RecordAction(UserMetricsAction("ClearBrowsingData_Everything")); |
| 284 break; | 288 break; |
| 285 } | 289 } |
| 286 return TimeRange(CalculateBeginDeleteTime(period), base::Time::Max()); | 290 return TimeRange(CalculateBeginDeleteTime(period), base::Time::Max()); |
| 287 } | 291 } |
| 288 | 292 |
| 289 BrowsingDataRemover::BrowsingDataRemover( | 293 BrowsingDataRemover::BrowsingDataRemover( |
| 290 content::BrowserContext* browser_context) | 294 content::BrowserContext* browser_context) |
| 291 : profile_(Profile::FromBrowserContext(browser_context)), | 295 : profile_(Profile::FromBrowserContext(browser_context)), |
| 292 is_removing_(false), | |
| 293 remove_mask_(-1), | 296 remove_mask_(-1), |
| 294 origin_type_mask_(-1), | 297 origin_type_mask_(-1), |
| 298 is_removing_(false), | |
| 299 #if defined(ENABLE_PLUGINS) | |
| 300 flash_lso_helper_(BrowsingDataFlashLSOHelper::Create(profile_)), | |
| 301 #endif | |
| 295 #if BUILDFLAG(ANDROID_JAVA_UI) | 302 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 296 webapp_registry_(new WebappRegistry()), | 303 webapp_registry_(new WebappRegistry()), |
| 297 #endif | 304 #endif |
| 298 weak_ptr_factory_(this) { | 305 weak_ptr_factory_(this) { |
| 299 DCHECK(browser_context); | 306 DCHECK(browser_context); |
| 300 } | 307 } |
| 301 | 308 |
| 302 BrowsingDataRemover::~BrowsingDataRemover() { | 309 BrowsingDataRemover::~BrowsingDataRemover() { |
| 303 if (!task_queue_.empty()) { | 310 if (!task_queue_.empty()) { |
| 304 VLOG(1) << "BrowsingDataRemover shuts down with " << task_queue_.size() | 311 VLOG(1) << "BrowsingDataRemover shuts down with " << task_queue_.size() |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 storage_partition_remove_mask |= | 773 storage_partition_remove_mask |= |
| 767 content::StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS; | 774 content::StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS; |
| 768 } | 775 } |
| 769 | 776 |
| 770 #if defined(ENABLE_PLUGINS) | 777 #if defined(ENABLE_PLUGINS) |
| 771 // Plugin is data not separated for protected and unprotected web origins. We | 778 // Plugin is data not separated for protected and unprotected web origins. We |
| 772 // check the origin_type_mask_ to prevent unintended deletion. | 779 // check the origin_type_mask_ to prevent unintended deletion. |
| 773 if (remove_mask & REMOVE_PLUGIN_DATA && | 780 if (remove_mask & REMOVE_PLUGIN_DATA && |
| 774 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | 781 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { |
| 775 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); | 782 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); |
| 783 waiting_for_clear_plugin_data_count_ = 1; | |
| 776 | 784 |
| 777 waiting_for_clear_plugin_data_ = true; | 785 if (filter_builder.IsEmptyBlacklist()) { |
| 778 DCHECK(!plugin_data_remover_); | 786 DCHECK(!plugin_data_remover_); |
| 779 plugin_data_remover_.reset(content::PluginDataRemover::Create(profile_)); | 787 plugin_data_remover_.reset(content::PluginDataRemover::Create(profile_)); |
| 780 base::WaitableEvent* event = | 788 base::WaitableEvent* event = |
| 781 plugin_data_remover_->StartRemoving(delete_begin_); | 789 plugin_data_remover_->StartRemoving(delete_begin_); |
| 782 | 790 |
| 783 base::WaitableEventWatcher::EventCallback watcher_callback = | 791 base::WaitableEventWatcher::EventCallback watcher_callback = |
| 784 base::Bind(&BrowsingDataRemover::OnWaitableEventSignaled, | 792 base::Bind(&BrowsingDataRemover::OnWaitableEventSignaled, |
| 785 weak_ptr_factory_.GetWeakPtr()); | 793 weak_ptr_factory_.GetWeakPtr()); |
| 786 watcher_.StartWatching(event, watcher_callback); | 794 watcher_.StartWatching(event, watcher_callback); |
| 795 } else { | |
| 796 // TODO(msramek): Store filters from the currently executed task on the | |
| 797 // object to avoid having to copy them to callback methods. | |
| 798 flash_lso_helper_->StartFetching(base::Bind( | |
| 799 &BrowsingDataRemover::OnSitesWithFlashDataFetched, | |
| 800 weak_ptr_factory_.GetWeakPtr(), | |
| 801 filter_builder.BuildPluginFilter())); | |
| 802 } | |
| 787 } | 803 } |
| 788 #endif | 804 #endif |
| 789 | 805 |
| 790 if (remove_mask & REMOVE_SITE_USAGE_DATA) { | 806 if (remove_mask & REMOVE_SITE_USAGE_DATA) { |
| 791 ClearSettingsForOneTypeWithPredicate( | 807 ClearSettingsForOneTypeWithPredicate( |
| 792 HostContentSettingsMapFactory::GetForProfile(profile_), | 808 HostContentSettingsMapFactory::GetForProfile(profile_), |
| 793 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, | 809 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 794 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); | 810 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); |
| 795 } | 811 } |
| 796 | 812 |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1101 storage_partition_for_testing_ = storage_partition; | 1117 storage_partition_for_testing_ = storage_partition; |
| 1102 } | 1118 } |
| 1103 | 1119 |
| 1104 #if BUILDFLAG(ANDROID_JAVA_UI) | 1120 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 1105 void BrowsingDataRemover::OverrideWebappRegistryForTesting( | 1121 void BrowsingDataRemover::OverrideWebappRegistryForTesting( |
| 1106 std::unique_ptr<WebappRegistry> webapp_registry) { | 1122 std::unique_ptr<WebappRegistry> webapp_registry) { |
| 1107 webapp_registry_.reset(webapp_registry.release()); | 1123 webapp_registry_.reset(webapp_registry.release()); |
| 1108 } | 1124 } |
| 1109 #endif | 1125 #endif |
| 1110 | 1126 |
| 1127 #if defined(ENABLE_PLUGINS) | |
| 1128 void BrowsingDataRemover::OverrideFlashLSOHelperForTesting( | |
| 1129 scoped_refptr<BrowsingDataFlashLSOHelper> flash_lso_helper) { | |
| 1130 flash_lso_helper_ = flash_lso_helper; | |
| 1131 } | |
| 1132 #endif | |
| 1133 | |
| 1111 const base::Time& BrowsingDataRemover::GetLastUsedBeginTime() { | 1134 const base::Time& BrowsingDataRemover::GetLastUsedBeginTime() { |
| 1112 return delete_begin_; | 1135 return delete_begin_; |
| 1113 } | 1136 } |
| 1114 | 1137 |
| 1115 const base::Time& BrowsingDataRemover::GetLastUsedEndTime() { | 1138 const base::Time& BrowsingDataRemover::GetLastUsedEndTime() { |
| 1116 return delete_end_; | 1139 return delete_end_; |
| 1117 } | 1140 } |
| 1118 | 1141 |
| 1119 int BrowsingDataRemover::GetLastUsedRemovalMask() { | 1142 int BrowsingDataRemover::GetLastUsedRemovalMask() { |
| 1120 return remove_mask_; | 1143 return remove_mask_; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1162 !waiting_for_clear_cache_ && | 1185 !waiting_for_clear_cache_ && |
| 1163 !waiting_for_clear_flash_content_licenses_ && | 1186 !waiting_for_clear_flash_content_licenses_ && |
| 1164 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && | 1187 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && |
| 1165 !waiting_for_clear_domain_reliability_monitor_ && | 1188 !waiting_for_clear_domain_reliability_monitor_ && |
| 1166 !waiting_for_clear_form_ && !waiting_for_clear_history_ && | 1189 !waiting_for_clear_form_ && !waiting_for_clear_history_ && |
| 1167 !waiting_for_clear_hostname_resolution_cache_ && | 1190 !waiting_for_clear_hostname_resolution_cache_ && |
| 1168 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && | 1191 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && |
| 1169 !waiting_for_clear_network_predictor_ && | 1192 !waiting_for_clear_network_predictor_ && |
| 1170 !waiting_for_clear_networking_history_ && | 1193 !waiting_for_clear_networking_history_ && |
| 1171 !waiting_for_clear_passwords_ && !waiting_for_clear_passwords_stats_ && | 1194 !waiting_for_clear_passwords_ && !waiting_for_clear_passwords_stats_ && |
| 1172 !waiting_for_clear_platform_keys_ && !waiting_for_clear_plugin_data_ && | 1195 !waiting_for_clear_platform_keys_ && |
| 1196 !waiting_for_clear_plugin_data_count_ && | |
| 1173 !waiting_for_clear_pnacl_cache_ && | 1197 !waiting_for_clear_pnacl_cache_ && |
| 1174 #if BUILDFLAG(ANDROID_JAVA_UI) | 1198 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 1175 !waiting_for_clear_precache_history_ && | 1199 !waiting_for_clear_precache_history_ && |
| 1176 !waiting_for_clear_webapp_data_ && | 1200 !waiting_for_clear_webapp_data_ && |
| 1177 !waiting_for_clear_webapp_history_ && | 1201 !waiting_for_clear_webapp_history_ && |
| 1178 !waiting_for_clear_offline_page_data_ && | 1202 !waiting_for_clear_offline_page_data_ && |
| 1179 #endif | 1203 #endif |
| 1180 #if defined(ENABLE_WEBRTC) | 1204 #if defined(ENABLE_WEBRTC) |
| 1181 !waiting_for_clear_webrtc_logs_ && | 1205 !waiting_for_clear_webrtc_logs_ && |
| 1182 #endif | 1206 #endif |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1291 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1315 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1292 waiting_for_clear_pnacl_cache_ = false; | 1316 waiting_for_clear_pnacl_cache_ = false; |
| 1293 NotifyIfDone(); | 1317 NotifyIfDone(); |
| 1294 } | 1318 } |
| 1295 #endif | 1319 #endif |
| 1296 | 1320 |
| 1297 #if defined(ENABLE_PLUGINS) | 1321 #if defined(ENABLE_PLUGINS) |
| 1298 void BrowsingDataRemover::OnWaitableEventSignaled( | 1322 void BrowsingDataRemover::OnWaitableEventSignaled( |
| 1299 base::WaitableEvent* waitable_event) { | 1323 base::WaitableEvent* waitable_event) { |
| 1300 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1324 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1301 waiting_for_clear_plugin_data_ = false; | 1325 |
| 1326 --waiting_for_clear_plugin_data_count_; | |
|
Bernhard Bauer
2016/08/18 18:35:59
I would use post-increment – the compiler should b
msramek
2016/08/19 11:16:46
I replaced this part, but changed it in OnFlashDat
Bernhard Bauer
2016/08/19 16:29:39
Yeah, if you think about it, C++ means incremental
| |
| 1327 DCHECK(!waiting_for_clear_plugin_data_count_); | |
|
Bernhard Bauer
2016/08/18 18:35:59
So really, you are transitioning from 1 to 0? Why
msramek
2016/08/19 11:16:46
Changed to DCHECK that it's 1, then set it to 0.
| |
| 1328 | |
| 1302 plugin_data_remover_.reset(); | 1329 plugin_data_remover_.reset(); |
| 1303 watcher_.StopWatching(); | 1330 watcher_.StopWatching(); |
| 1304 NotifyIfDone(); | 1331 NotifyIfDone(); |
| 1305 } | 1332 } |
| 1306 | 1333 |
| 1334 void BrowsingDataRemover::OnSitesWithFlashDataFetched( | |
| 1335 base::Callback<bool(const std::string&)> plugin_filter, | |
| 1336 const std::vector<std::string>& sites) { | |
| 1337 --waiting_for_clear_plugin_data_count_; | |
| 1338 DCHECK(!waiting_for_clear_plugin_data_count_); | |
| 1339 | |
| 1340 std::vector<std::string> sites_to_delete; | |
| 1341 for (const std::string& site : sites) { | |
| 1342 if (plugin_filter.Run(site)) | |
| 1343 sites_to_delete.push_back(site); | |
| 1344 } | |
| 1345 | |
| 1346 waiting_for_clear_plugin_data_count_ = sites_to_delete.size(); | |
| 1347 | |
| 1348 for (const std::string& site : sites_to_delete) { | |
| 1349 flash_lso_helper_->DeleteFlashLSOsForSite( | |
| 1350 site, | |
| 1351 base::Bind(&BrowsingDataRemover::OnFlashDataDeleted, | |
| 1352 weak_ptr_factory_.GetWeakPtr())); | |
| 1353 } | |
| 1354 | |
| 1355 NotifyIfDone(); | |
| 1356 } | |
| 1357 | |
| 1358 void BrowsingDataRemover::OnFlashDataDeleted() { | |
| 1359 --waiting_for_clear_plugin_data_count_; | |
| 1360 NotifyIfDone(); | |
| 1361 } | |
| 1362 | |
| 1307 void BrowsingDataRemover::OnDeauthorizeFlashContentLicensesCompleted( | 1363 void BrowsingDataRemover::OnDeauthorizeFlashContentLicensesCompleted( |
| 1308 uint32_t request_id, | 1364 uint32_t request_id, |
| 1309 bool /* success */) { | 1365 bool /* success */) { |
| 1310 DCHECK(waiting_for_clear_flash_content_licenses_); | 1366 DCHECK(waiting_for_clear_flash_content_licenses_); |
| 1311 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); | 1367 DCHECK_EQ(request_id, deauthorize_flash_content_licenses_request_id_); |
| 1312 | 1368 |
| 1313 waiting_for_clear_flash_content_licenses_ = false; | 1369 waiting_for_clear_flash_content_licenses_ = false; |
| 1314 NotifyIfDone(); | 1370 NotifyIfDone(); |
| 1315 } | 1371 } |
| 1316 #endif | 1372 #endif |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1411 waiting_for_clear_offline_page_data_ = false; | 1467 waiting_for_clear_offline_page_data_ = false; |
| 1412 NotifyIfDone(); | 1468 NotifyIfDone(); |
| 1413 } | 1469 } |
| 1414 #endif | 1470 #endif |
| 1415 | 1471 |
| 1416 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { | 1472 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { |
| 1417 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1473 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1418 waiting_for_clear_domain_reliability_monitor_ = false; | 1474 waiting_for_clear_domain_reliability_monitor_ = false; |
| 1419 NotifyIfDone(); | 1475 NotifyIfDone(); |
| 1420 } | 1476 } |
| OLD | NEW |