| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 base::Time removal_begin, | 283 base::Time removal_begin, |
| 284 int removal_mask, | 284 int removal_mask, |
| 285 int origin_type_mask) | 285 int origin_type_mask) |
| 286 : removal_begin(removal_begin), | 286 : removal_begin(removal_begin), |
| 287 removal_mask(removal_mask), | 287 removal_mask(removal_mask), |
| 288 origin_type_mask(origin_type_mask) { | 288 origin_type_mask(origin_type_mask) { |
| 289 } | 289 } |
| 290 | 290 |
| 291 BrowsingDataRemover::NotificationDetails::~NotificationDetails() {} | 291 BrowsingDataRemover::NotificationDetails::~NotificationDetails() {} |
| 292 | 292 |
| 293 // static | |
| 294 BrowsingDataRemover::TimeRange BrowsingDataRemover::Unbounded() { | |
| 295 return TimeRange(base::Time(), base::Time::Max()); | |
| 296 } | |
| 297 | |
| 298 // static | |
| 299 BrowsingDataRemover::TimeRange BrowsingDataRemover::Period(TimePeriod period) { | |
| 300 switch (period) { | |
| 301 case LAST_HOUR: | |
| 302 content::RecordAction( | |
| 303 UserMetricsAction("ClearBrowsingData_LastHour")); | |
| 304 break; | |
| 305 case LAST_DAY: | |
| 306 content::RecordAction( | |
| 307 UserMetricsAction("ClearBrowsingData_LastDay")); | |
| 308 break; | |
| 309 case LAST_WEEK: | |
| 310 content::RecordAction( | |
| 311 UserMetricsAction("ClearBrowsingData_LastWeek")); | |
| 312 break; | |
| 313 case FOUR_WEEKS: | |
| 314 content::RecordAction( | |
| 315 UserMetricsAction("ClearBrowsingData_LastMonth")); | |
| 316 break; | |
| 317 case EVERYTHING: | |
| 318 content::RecordAction( | |
| 319 UserMetricsAction("ClearBrowsingData_Everything")); | |
| 320 break; | |
| 321 } | |
| 322 return TimeRange(CalculateBeginDeleteTime(period), base::Time::Max()); | |
| 323 } | |
| 324 | 293 |
| 325 BrowsingDataRemover::BrowsingDataRemover( | 294 BrowsingDataRemover::BrowsingDataRemover( |
| 326 content::BrowserContext* browser_context) | 295 content::BrowserContext* browser_context) |
| 327 : profile_(Profile::FromBrowserContext(browser_context)), | 296 : profile_(Profile::FromBrowserContext(browser_context)), |
| 328 is_removing_(false), | 297 is_removing_(false), |
| 329 #if BUILDFLAG(ANDROID_JAVA_UI) | 298 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 330 webapp_registry_(new WebappRegistry()), | 299 webapp_registry_(new WebappRegistry()), |
| 331 #endif | 300 #endif |
| 332 weak_ptr_factory_(this) { | 301 weak_ptr_factory_(this) { |
| 333 DCHECK(browser_context); | 302 DCHECK(browser_context); |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 &settings); | 1039 &settings); |
| 1071 for (const ContentSettingPatternSource& setting : settings) { | 1040 for (const ContentSettingPatternSource& setting : settings) { |
| 1072 if (predicate.Run(setting.primary_pattern, setting.secondary_pattern)) { | 1041 if (predicate.Run(setting.primary_pattern, setting.secondary_pattern)) { |
| 1073 content_settings_map->SetWebsiteSettingCustomScope( | 1042 content_settings_map->SetWebsiteSettingCustomScope( |
| 1074 setting.primary_pattern, setting.secondary_pattern, content_type, | 1043 setting.primary_pattern, setting.secondary_pattern, content_type, |
| 1075 std::string(), nullptr); | 1044 std::string(), nullptr); |
| 1076 } | 1045 } |
| 1077 } | 1046 } |
| 1078 } | 1047 } |
| 1079 | 1048 |
| 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() { | 1049 bool BrowsingDataRemover::AllDone() { |
| 1105 return !waiting_for_clear_autofill_origin_urls_ && | 1050 return !waiting_for_clear_autofill_origin_urls_ && |
| 1106 !waiting_for_clear_cache_ && !waiting_for_clear_content_licenses_ && | 1051 !waiting_for_clear_cache_ && !waiting_for_clear_content_licenses_ && |
| 1107 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && | 1052 !waiting_for_clear_channel_ids_ && !waiting_for_clear_cookies_count_ && |
| 1108 !waiting_for_clear_domain_reliability_monitor_ && | 1053 !waiting_for_clear_domain_reliability_monitor_ && |
| 1109 !waiting_for_clear_form_ && !waiting_for_clear_history_ && | 1054 !waiting_for_clear_form_ && !waiting_for_clear_history_ && |
| 1110 !waiting_for_clear_hostname_resolution_cache_ && | 1055 !waiting_for_clear_hostname_resolution_cache_ && |
| 1111 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && | 1056 !waiting_for_clear_keyword_data_ && !waiting_for_clear_nacl_cache_ && |
| 1112 !waiting_for_clear_network_predictor_ && | 1057 !waiting_for_clear_network_predictor_ && |
| 1113 !waiting_for_clear_networking_history_ && | 1058 !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; | 1281 waiting_for_clear_domain_reliability_monitor_ = false; |
| 1337 NotifyIfDone(); | 1282 NotifyIfDone(); |
| 1338 } | 1283 } |
| 1339 | 1284 |
| 1340 // static | 1285 // static |
| 1341 BrowsingDataRemover::CallbackSubscription | 1286 BrowsingDataRemover::CallbackSubscription |
| 1342 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( | 1287 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( |
| 1343 const BrowsingDataRemover::Callback& callback) { | 1288 const BrowsingDataRemover::Callback& callback) { |
| 1344 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); | 1289 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); |
| 1345 } | 1290 } |
| OLD | NEW |