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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 &settings); | 1069 &settings); |
1074 for (const ContentSettingPatternSource& setting : settings) { | 1070 for (const ContentSettingPatternSource& setting : settings) { |
1075 if (predicate.Run(setting.primary_pattern, setting.secondary_pattern)) { | 1071 if (predicate.Run(setting.primary_pattern, setting.secondary_pattern)) { |
1076 content_settings_map->SetWebsiteSettingCustomScope( | 1072 content_settings_map->SetWebsiteSettingCustomScope( |
1077 setting.primary_pattern, setting.secondary_pattern, content_type, | 1073 setting.primary_pattern, setting.secondary_pattern, content_type, |
1078 std::string(), nullptr); | 1074 std::string(), nullptr); |
1079 } | 1075 } |
1080 } | 1076 } |
1081 } | 1077 } |
1082 | 1078 |
1083 base::Time BrowsingDataRemover::CalculateBeginDeleteTime( | |
1084 TimePeriod time_period) { | |
1085 base::TimeDelta diff; | |
1086 base::Time delete_begin_time = base::Time::Now(); | |
1087 switch (time_period) { | |
1088 case LAST_HOUR: | |
1089 diff = base::TimeDelta::FromHours(1); | |
1090 break; | |
1091 case LAST_DAY: | |
1092 diff = base::TimeDelta::FromHours(24); | |
1093 break; | |
1094 case LAST_WEEK: | |
1095 diff = base::TimeDelta::FromHours(7*24); | |
1096 break; | |
1097 case FOUR_WEEKS: | |
1098 diff = base::TimeDelta::FromHours(4*7*24); | |
1099 break; | |
1100 case EVERYTHING: | |
1101 delete_begin_time = base::Time(); | |
1102 break; | |
1103 } | |
1104 return delete_begin_time - diff; | |
1105 } | |
1106 | |
1107 bool BrowsingDataRemover::AllDone() { | 1079 bool BrowsingDataRemover::AllDone() { |
1108 return !waiting_for_clear_autofill_origin_urls_ && | 1080 return !waiting_for_clear_autofill_origin_urls_ && |
1109 !waiting_for_clear_cache_ && | 1081 !waiting_for_clear_cache_ && |
1110 !waiting_for_clear_flash_content_licenses_ && | 1082 !waiting_for_clear_flash_content_licenses_ && |
1111 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && | 1083 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && |
1112 !waiting_for_clear_domain_reliability_monitor_ && | 1084 !waiting_for_clear_domain_reliability_monitor_ && |
1113 !waiting_for_clear_form_ && !waiting_for_clear_history_ && | 1085 !waiting_for_clear_form_ && !waiting_for_clear_history_ && |
1114 !waiting_for_clear_hostname_resolution_cache_ && | 1086 !waiting_for_clear_hostname_resolution_cache_ && |
1115 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && | 1087 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && |
1116 !waiting_for_clear_network_predictor_ && | 1088 !waiting_for_clear_network_predictor_ && |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 waiting_for_clear_domain_reliability_monitor_ = false; | 1312 waiting_for_clear_domain_reliability_monitor_ = false; |
1341 NotifyIfDone(); | 1313 NotifyIfDone(); |
1342 } | 1314 } |
1343 | 1315 |
1344 // static | 1316 // static |
1345 BrowsingDataRemover::CallbackSubscription | 1317 BrowsingDataRemover::CallbackSubscription |
1346 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( | 1318 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( |
1347 const BrowsingDataRemover::Callback& callback) { | 1319 const BrowsingDataRemover::Callback& callback) { |
1348 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); | 1320 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); |
1349 } | 1321 } |
OLD | NEW |