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 "base/metrics/user_metrics.h" |
8 #include "components/browsing_data/core/counters/autofill_counter.h" | 8 #include "components/browsing_data/core/counters/autofill_counter.h" |
9 #include "components/browsing_data/core/counters/history_counter.h" | 9 #include "components/browsing_data/core/counters/history_counter.h" |
10 #include "components/browsing_data/core/counters/passwords_counter.h" | 10 #include "components/browsing_data/core/counters/passwords_counter.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 base::UserMetricsAction("ClearBrowsingData_LastMonth")); | 59 base::UserMetricsAction("ClearBrowsingData_LastMonth")); |
60 break; | 60 break; |
61 case TimePeriod::ALL_TIME: | 61 case TimePeriod::ALL_TIME: |
62 base::RecordAction( | 62 base::RecordAction( |
63 base::UserMetricsAction("ClearBrowsingData_Everything")); | 63 base::UserMetricsAction("ClearBrowsingData_Everything")); |
64 break; | 64 break; |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 base::string16 GetCounterTextFromResult( | 68 base::string16 GetCounterTextFromResult( |
69 const browsing_data::BrowsingDataCounter::Result* result) { | 69 const browsing_data::BrowsingDataCounter::Result* result, |
70 ClearBrowsingDataTab cbd_tab) { | |
70 base::string16 text; | 71 base::string16 text; |
71 std::string pref_name = result->source()->GetPrefName(); | 72 std::string pref_name = result->source()->GetPrefName(); |
72 | 73 |
73 if (!result->Finished()) { | 74 if (!result->Finished()) { |
74 // The counter is still counting. | 75 // The counter is still counting. |
75 text = l10n_util::GetStringUTF16(IDS_CLEAR_BROWSING_DATA_CALCULATING); | 76 text = l10n_util::GetStringUTF16(IDS_CLEAR_BROWSING_DATA_CALCULATING); |
76 | 77 |
77 } else if (pref_name == browsing_data::prefs::kDeletePasswords || | 78 } else if (pref_name == browsing_data::prefs::kDeletePasswords || |
78 pref_name == browsing_data::prefs::kDeleteDownloadHistory) { | 79 pref_name == browsing_data::prefs::kDeleteDownloadHistory) { |
79 // Counters with trivially formatted result: passwords and downloads. | 80 // Counters with trivially formatted result: passwords and downloads. |
80 browsing_data::BrowsingDataCounter::ResultInt count = | 81 browsing_data::BrowsingDataCounter::ResultInt count = |
81 static_cast<const browsing_data::BrowsingDataCounter::FinishedResult*>( | 82 static_cast<const browsing_data::BrowsingDataCounter::FinishedResult*>( |
82 result) | 83 result) |
83 ->Value(); | 84 ->Value(); |
84 text = l10n_util::GetPluralStringFUTF16( | 85 text = l10n_util::GetPluralStringFUTF16( |
85 pref_name == browsing_data::prefs::kDeletePasswords | 86 pref_name == browsing_data::prefs::kDeletePasswords |
86 ? IDS_DEL_PASSWORDS_COUNTER | 87 ? IDS_DEL_PASSWORDS_COUNTER |
87 : IDS_DEL_DOWNLOADS_COUNTER, | 88 : IDS_DEL_DOWNLOADS_COUNTER, |
88 count); | 89 count); |
89 } else if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory || | 90 } else if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory || |
90 pref_name == browsing_data::prefs::kDeleteBrowsingHistoryBasic) { | 91 pref_name == browsing_data::prefs::kDeleteBrowsingHistoryBasic) { |
msramek
2017/03/15 10:23:35
High-level question: Why do we need |cbd_tab| when
dullweber
2017/03/15 10:59:50
We actually don't need it here. Thanks!
| |
91 // History counter. | 92 // History counter. |
92 const browsing_data::HistoryCounter::HistoryResult* history_result = | 93 const browsing_data::HistoryCounter::HistoryResult* history_result = |
93 static_cast<const browsing_data::HistoryCounter::HistoryResult*>( | 94 static_cast<const browsing_data::HistoryCounter::HistoryResult*>( |
94 result); | 95 result); |
95 browsing_data::BrowsingDataCounter::ResultInt local_item_count = | 96 browsing_data::BrowsingDataCounter::ResultInt local_item_count = |
96 history_result->Value(); | 97 history_result->Value(); |
97 bool has_synced_visits = history_result->has_synced_visits(); | 98 bool has_synced_visits = history_result->has_synced_visits(); |
98 | 99 |
99 text = has_synced_visits | 100 switch (cbd_tab) { |
100 ? l10n_util::GetPluralStringFUTF16( | 101 case ClearBrowsingDataTab::ADVANCED: |
101 IDS_DEL_BROWSING_HISTORY_COUNTER_SYNCED, local_item_count) | 102 text = |
102 : l10n_util::GetPluralStringFUTF16( | 103 has_synced_visits |
103 IDS_DEL_BROWSING_HISTORY_COUNTER, local_item_count); | 104 ? l10n_util::GetPluralStringFUTF16( |
105 IDS_DEL_BROWSING_HISTORY_COUNTER_SYNCED, local_item_count) | |
106 : l10n_util::GetPluralStringFUTF16( | |
107 IDS_DEL_BROWSING_HISTORY_COUNTER, local_item_count); | |
108 break; | |
109 // The basic tab doesn't show history counter results. | |
110 case ClearBrowsingDataTab::BASIC: | |
111 case browsing_data::ClearBrowsingDataTab::NUM_TYPES: | |
msramek
2017/03/15 10:23:35
nit: No need for the namespace.
| |
112 NOTREACHED(); | |
113 } | |
104 | 114 |
105 } else if (pref_name == browsing_data::prefs::kDeleteFormData) { | 115 } else if (pref_name == browsing_data::prefs::kDeleteFormData) { |
106 // Autofill counter. | 116 // Autofill counter. |
107 const browsing_data::AutofillCounter::AutofillResult* autofill_result = | 117 const browsing_data::AutofillCounter::AutofillResult* autofill_result = |
108 static_cast<const browsing_data::AutofillCounter::AutofillResult*>( | 118 static_cast<const browsing_data::AutofillCounter::AutofillResult*>( |
109 result); | 119 result); |
110 browsing_data::AutofillCounter::ResultInt num_suggestions = | 120 browsing_data::AutofillCounter::ResultInt num_suggestions = |
111 autofill_result->Value(); | 121 autofill_result->Value(); |
112 browsing_data::AutofillCounter::ResultInt num_credit_cards = | 122 browsing_data::AutofillCounter::ResultInt num_credit_cards = |
113 autofill_result->num_credit_cards(); | 123 autofill_result->num_credit_cards(); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 prefs->GetBoolean(prefs::kDeleteCache)); | 246 prefs->GetBoolean(prefs::kDeleteCache)); |
237 prefs->SetBoolean(prefs::kDeleteCookiesBasic, | 247 prefs->SetBoolean(prefs::kDeleteCookiesBasic, |
238 prefs->GetBoolean(prefs::kDeleteCookies)); | 248 prefs->GetBoolean(prefs::kDeleteCookies)); |
239 prefs->SetInteger(prefs::kDeleteTimePeriodBasic, | 249 prefs->SetInteger(prefs::kDeleteTimePeriodBasic, |
240 prefs->GetInteger(prefs::kDeleteTimePeriod)); | 250 prefs->GetInteger(prefs::kDeleteTimePeriod)); |
241 prefs->SetBoolean(prefs::kPreferencesMigratedToBasic, true); | 251 prefs->SetBoolean(prefs::kPreferencesMigratedToBasic, true); |
242 } | 252 } |
243 } | 253 } |
244 | 254 |
245 } // namespace browsing_data | 255 } // namespace browsing_data |
OLD | NEW |