| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 } | 289 } |
| 290 | 290 |
| 291 BrowsingDataRemover::NotificationDetails::~NotificationDetails() {} | 291 BrowsingDataRemover::NotificationDetails::~NotificationDetails() {} |
| 292 | 292 |
| 293 // static | 293 // static |
| 294 BrowsingDataRemover::TimeRange BrowsingDataRemover::Unbounded() { | 294 BrowsingDataRemover::TimeRange BrowsingDataRemover::Unbounded() { |
| 295 return TimeRange(base::Time(), base::Time::Max()); | 295 return TimeRange(base::Time(), base::Time::Max()); |
| 296 } | 296 } |
| 297 | 297 |
| 298 // static | 298 // static |
| 299 BrowsingDataRemover::TimeRange BrowsingDataRemover::Period(TimePeriod period) { | 299 BrowsingDataRemover::TimeRange BrowsingDataRemover::Period( |
| 300 browsing_data::TimePeriod period) { |
| 300 switch (period) { | 301 switch (period) { |
| 301 case LAST_HOUR: | 302 case browsing_data::LAST_HOUR: |
| 302 content::RecordAction( | 303 content::RecordAction(UserMetricsAction("ClearBrowsingData_LastHour")); |
| 303 UserMetricsAction("ClearBrowsingData_LastHour")); | |
| 304 break; | 304 break; |
| 305 case LAST_DAY: | 305 case browsing_data::LAST_DAY: |
| 306 content::RecordAction( | 306 content::RecordAction(UserMetricsAction("ClearBrowsingData_LastDay")); |
| 307 UserMetricsAction("ClearBrowsingData_LastDay")); | |
| 308 break; | 307 break; |
| 309 case LAST_WEEK: | 308 case browsing_data::LAST_WEEK: |
| 310 content::RecordAction( | 309 content::RecordAction(UserMetricsAction("ClearBrowsingData_LastWeek")); |
| 311 UserMetricsAction("ClearBrowsingData_LastWeek")); | |
| 312 break; | 310 break; |
| 313 case FOUR_WEEKS: | 311 case browsing_data::FOUR_WEEKS: |
| 314 content::RecordAction( | 312 content::RecordAction(UserMetricsAction("ClearBrowsingData_LastMonth")); |
| 315 UserMetricsAction("ClearBrowsingData_LastMonth")); | |
| 316 break; | 313 break; |
| 317 case EVERYTHING: | 314 case browsing_data::EVERYTHING: |
| 318 content::RecordAction( | 315 content::RecordAction(UserMetricsAction("ClearBrowsingData_Everything")); |
| 319 UserMetricsAction("ClearBrowsingData_Everything")); | |
| 320 break; | 316 break; |
| 321 } | 317 } |
| 322 return TimeRange(CalculateBeginDeleteTime(period), base::Time::Max()); | 318 return TimeRange(CalculateBeginDeleteTime(period), base::Time::Max()); |
| 323 } | 319 } |
| 324 | 320 |
| 325 BrowsingDataRemover::BrowsingDataRemover( | 321 BrowsingDataRemover::BrowsingDataRemover( |
| 326 content::BrowserContext* browser_context) | 322 content::BrowserContext* browser_context) |
| 327 : profile_(Profile::FromBrowserContext(browser_context)), | 323 : profile_(Profile::FromBrowserContext(browser_context)), |
| 328 is_removing_(false), | 324 is_removing_(false), |
| 329 #if BUILDFLAG(ANDROID_JAVA_UI) | 325 #if BUILDFLAG(ANDROID_JAVA_UI) |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 &settings); | 1066 &settings); |
| 1071 for (const ContentSettingPatternSource& setting : settings) { | 1067 for (const ContentSettingPatternSource& setting : settings) { |
| 1072 if (predicate.Run(setting.primary_pattern, setting.secondary_pattern)) { | 1068 if (predicate.Run(setting.primary_pattern, setting.secondary_pattern)) { |
| 1073 content_settings_map->SetWebsiteSettingCustomScope( | 1069 content_settings_map->SetWebsiteSettingCustomScope( |
| 1074 setting.primary_pattern, setting.secondary_pattern, content_type, | 1070 setting.primary_pattern, setting.secondary_pattern, content_type, |
| 1075 std::string(), nullptr); | 1071 std::string(), nullptr); |
| 1076 } | 1072 } |
| 1077 } | 1073 } |
| 1078 } | 1074 } |
| 1079 | 1075 |
| 1080 base::Time BrowsingDataRemover::CalculateBeginDeleteTime( | |
| 1081 TimePeriod time_period) { | |
| 1082 base::TimeDelta diff; | |
| 1083 base::Time delete_begin_time = base::Time::Now(); | |
| 1084 switch (time_period) { | |
| 1085 case LAST_HOUR: | |
| 1086 diff = base::TimeDelta::FromHours(1); | |
| 1087 break; | |
| 1088 case LAST_DAY: | |
| 1089 diff = base::TimeDelta::FromHours(24); | |
| 1090 break; | |
| 1091 case LAST_WEEK: | |
| 1092 diff = base::TimeDelta::FromHours(7*24); | |
| 1093 break; | |
| 1094 case FOUR_WEEKS: | |
| 1095 diff = base::TimeDelta::FromHours(4*7*24); | |
| 1096 break; | |
| 1097 case EVERYTHING: | |
| 1098 delete_begin_time = base::Time(); | |
| 1099 break; | |
| 1100 } | |
| 1101 return delete_begin_time - diff; | |
| 1102 } | |
| 1103 | |
| 1104 bool BrowsingDataRemover::AllDone() { | 1076 bool BrowsingDataRemover::AllDone() { |
| 1105 return !waiting_for_clear_autofill_origin_urls_ && | 1077 return !waiting_for_clear_autofill_origin_urls_ && |
| 1106 !waiting_for_clear_cache_ && !waiting_for_clear_content_licenses_ && | 1078 !waiting_for_clear_cache_ && !waiting_for_clear_content_licenses_ && |
| 1107 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && | 1079 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && |
| 1108 !waiting_for_clear_domain_reliability_monitor_ && | 1080 !waiting_for_clear_domain_reliability_monitor_ && |
| 1109 !waiting_for_clear_form_ && !waiting_for_clear_history_ && | 1081 !waiting_for_clear_form_ && !waiting_for_clear_history_ && |
| 1110 !waiting_for_clear_hostname_resolution_cache_ && | 1082 !waiting_for_clear_hostname_resolution_cache_ && |
| 1111 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && | 1083 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && |
| 1112 !waiting_for_clear_network_predictor_ && | 1084 !waiting_for_clear_network_predictor_ && |
| 1113 !waiting_for_clear_networking_history_ && | 1085 !waiting_for_clear_networking_history_ && |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 waiting_for_clear_domain_reliability_monitor_ = false; | 1308 waiting_for_clear_domain_reliability_monitor_ = false; |
| 1337 NotifyIfDone(); | 1309 NotifyIfDone(); |
| 1338 } | 1310 } |
| 1339 | 1311 |
| 1340 // static | 1312 // static |
| 1341 BrowsingDataRemover::CallbackSubscription | 1313 BrowsingDataRemover::CallbackSubscription |
| 1342 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( | 1314 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( |
| 1343 const BrowsingDataRemover::Callback& callback) { | 1315 const BrowsingDataRemover::Callback& callback) { |
| 1344 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); | 1316 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); |
| 1345 } | 1317 } |
| OLD | NEW |