| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/browsing_data/core/browsing_data_utils.h" | 5 #include "components/browsing_data/core/browsing_data_utils.h" |
| 6 | 6 |
| 7 #include "base/metrics/user_metrics.h" |
| 7 #include "components/browsing_data/core/counters/autofill_counter.h" | 8 #include "components/browsing_data/core/counters/autofill_counter.h" |
| 8 #include "components/browsing_data/core/counters/history_counter.h" | 9 #include "components/browsing_data/core/counters/history_counter.h" |
| 9 #include "components/browsing_data/core/counters/passwords_counter.h" | 10 #include "components/browsing_data/core/counters/passwords_counter.h" |
| 10 #include "components/browsing_data/core/pref_names.h" | 11 #include "components/browsing_data/core/pref_names.h" |
| 11 #include "grit/components_strings.h" | 12 #include "grit/components_strings.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 13 | 14 |
| 14 namespace browsing_data { | 15 namespace browsing_data { |
| 15 | 16 |
| 16 base::Time CalculateBeginDeleteTime(TimePeriod time_period) { | 17 base::Time CalculateBeginDeleteTime(TimePeriod time_period) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 29 case FOUR_WEEKS: | 30 case FOUR_WEEKS: |
| 30 diff = base::TimeDelta::FromHours(4 * 7 * 24); | 31 diff = base::TimeDelta::FromHours(4 * 7 * 24); |
| 31 break; | 32 break; |
| 32 case ALL_TIME: | 33 case ALL_TIME: |
| 33 delete_begin_time = base::Time(); | 34 delete_begin_time = base::Time(); |
| 34 break; | 35 break; |
| 35 } | 36 } |
| 36 return delete_begin_time - diff; | 37 return delete_begin_time - diff; |
| 37 } | 38 } |
| 38 | 39 |
| 40 base::Time CalculateEndDeleteTime(TimePeriod time_period) { |
| 41 // No TimePeriod currently supports the second time bound. |
| 42 return base::Time::Max(); |
| 43 } |
| 44 |
| 45 void RecordDeletionForPeriod(TimePeriod period) { |
| 46 switch (period) { |
| 47 case browsing_data::LAST_HOUR: |
| 48 base::RecordAction(base::UserMetricsAction("ClearBrowsingData_LastHour")); |
| 49 break; |
| 50 case browsing_data::LAST_DAY: |
| 51 base::RecordAction(base::UserMetricsAction("ClearBrowsingData_LastDay")); |
| 52 break; |
| 53 case browsing_data::LAST_WEEK: |
| 54 base::RecordAction(base::UserMetricsAction("ClearBrowsingData_LastWeek")); |
| 55 break; |
| 56 case browsing_data::FOUR_WEEKS: |
| 57 base::RecordAction( |
| 58 base::UserMetricsAction("ClearBrowsingData_LastMonth")); |
| 59 break; |
| 60 case browsing_data::ALL_TIME: |
| 61 base::RecordAction( |
| 62 base::UserMetricsAction("ClearBrowsingData_Everything")); |
| 63 break; |
| 64 } |
| 65 } |
| 66 |
| 39 base::string16 GetCounterTextFromResult( | 67 base::string16 GetCounterTextFromResult( |
| 40 const browsing_data::BrowsingDataCounter::Result* result) { | 68 const browsing_data::BrowsingDataCounter::Result* result) { |
| 41 base::string16 text; | 69 base::string16 text; |
| 42 std::string pref_name = result->source()->GetPrefName(); | 70 std::string pref_name = result->source()->GetPrefName(); |
| 43 | 71 |
| 44 if (!result->Finished()) { | 72 if (!result->Finished()) { |
| 45 // The counter is still counting. | 73 // The counter is still counting. |
| 46 text = l10n_util::GetStringUTF16(IDS_CLEAR_BROWSING_DATA_CALCULATING); | 74 text = l10n_util::GetStringUTF16(IDS_CLEAR_BROWSING_DATA_CALCULATING); |
| 47 | 75 |
| 48 } else if (pref_name == browsing_data::prefs::kDeletePasswords || | 76 } else if (pref_name == browsing_data::prefs::kDeletePasswords || |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 case NUM_TYPES: | 195 case NUM_TYPES: |
| 168 // This is not an actual type. | 196 // This is not an actual type. |
| 169 NOTREACHED(); | 197 NOTREACHED(); |
| 170 return false; | 198 return false; |
| 171 } | 199 } |
| 172 NOTREACHED(); | 200 NOTREACHED(); |
| 173 return false; | 201 return false; |
| 174 } | 202 } |
| 175 | 203 |
| 176 } // namespace browsing_data | 204 } // namespace browsing_data |
| OLD | NEW |