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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 base::string16 GetCounterTextFromResult( | 68 base::string16 GetCounterTextFromResult( |
69 const BrowsingDataCounter::Result* result) { | 69 const BrowsingDataCounter::Result* result) { |
70 base::string16 text; | 70 base::string16 text; |
71 std::string pref_name = result->source()->GetPrefName(); | 71 std::string pref_name = result->source()->GetPrefName(); |
72 | 72 |
73 if (!result->Finished()) { | 73 if (!result->Finished()) { |
74 // The counter is still counting. | 74 // The counter is still counting. |
75 text = l10n_util::GetStringUTF16(IDS_CLEAR_BROWSING_DATA_CALCULATING); | 75 text = l10n_util::GetStringUTF16(IDS_CLEAR_BROWSING_DATA_CALCULATING); |
76 | 76 |
77 } else if (pref_name == prefs::kDeletePasswords) { | 77 } else if (pref_name == prefs::kDeletePasswords) { |
78 const PasswordsCounter::PasswordResult* password_result = | 78 const BrowsingDataCounter::SyncResult* password_result = |
79 static_cast<const PasswordsCounter::PasswordResult*>(result); | 79 static_cast<const BrowsingDataCounter::SyncResult*>(result); |
80 | 80 |
81 BrowsingDataCounter::ResultInt count = password_result->Value(); | 81 BrowsingDataCounter::ResultInt count = password_result->Value(); |
82 | 82 |
83 text = l10n_util::GetPluralStringFUTF16( | 83 text = l10n_util::GetPluralStringFUTF16( |
84 password_result->password_sync_enabled() | 84 password_result->IsSyncEnabled() ? IDS_DEL_PASSWORDS_COUNTER_SYNCED |
85 ? IDS_DEL_PASSWORDS_COUNTER_SYNCED | 85 : IDS_DEL_PASSWORDS_COUNTER, |
86 : IDS_DEL_PASSWORDS_COUNTER, | |
87 count); | 86 count); |
88 } else if (pref_name == prefs::kDeleteDownloadHistory) { | 87 } else if (pref_name == prefs::kDeleteDownloadHistory) { |
89 BrowsingDataCounter::ResultInt count = | 88 BrowsingDataCounter::ResultInt count = |
90 static_cast<const BrowsingDataCounter::FinishedResult*>(result) | 89 static_cast<const BrowsingDataCounter::FinishedResult*>(result) |
91 ->Value(); | 90 ->Value(); |
92 text = l10n_util::GetPluralStringFUTF16(IDS_DEL_DOWNLOADS_COUNTER, count); | 91 text = l10n_util::GetPluralStringFUTF16(IDS_DEL_DOWNLOADS_COUNTER, count); |
93 } else if (pref_name == prefs::kDeleteBrowsingHistoryBasic) { | 92 } else if (pref_name == prefs::kDeleteBrowsingHistoryBasic) { |
94 // The basic tab doesn't show history counter results. | 93 // The basic tab doesn't show history counter results. |
95 NOTREACHED(); | 94 NOTREACHED(); |
96 } else if (pref_name == prefs::kDeleteBrowsingHistory) { | 95 } else if (pref_name == prefs::kDeleteBrowsingHistory) { |
97 // History counter. | 96 // History counter. |
98 const HistoryCounter::HistoryResult* history_result = | 97 const BrowsingDataCounter::SyncResult* history_result = |
99 static_cast<const HistoryCounter::HistoryResult*>(result); | 98 static_cast<const BrowsingDataCounter::SyncResult*>(result); |
100 BrowsingDataCounter::ResultInt local_item_count = history_result->Value(); | 99 BrowsingDataCounter::ResultInt local_item_count = history_result->Value(); |
101 bool has_synced_visits = history_result->has_synced_visits(); | 100 bool has_synced_visits = history_result->IsSyncEnabled(); |
102 text = has_synced_visits | 101 text = has_synced_visits |
103 ? l10n_util::GetPluralStringFUTF16( | 102 ? l10n_util::GetPluralStringFUTF16( |
104 IDS_DEL_BROWSING_HISTORY_COUNTER_SYNCED, local_item_count) | 103 IDS_DEL_BROWSING_HISTORY_COUNTER_SYNCED, local_item_count) |
105 : l10n_util::GetPluralStringFUTF16( | 104 : l10n_util::GetPluralStringFUTF16( |
106 IDS_DEL_BROWSING_HISTORY_COUNTER, local_item_count); | 105 IDS_DEL_BROWSING_HISTORY_COUNTER, local_item_count); |
107 | 106 |
108 } else if (pref_name == prefs::kDeleteFormData) { | 107 } else if (pref_name == prefs::kDeleteFormData) { |
109 // Autofill counter. | 108 // Autofill counter. |
110 const AutofillCounter::AutofillResult* autofill_result = | 109 const AutofillCounter::AutofillResult* autofill_result = |
111 static_cast<const AutofillCounter::AutofillResult*>(result); | 110 static_cast<const AutofillCounter::AutofillResult*>(result); |
(...skipping 26 matching lines...) Expand all Loading... |
138 break; | 137 break; |
139 case 2: | 138 case 2: |
140 displayed_strings.push_back(l10n_util::GetPluralStringFUTF16( | 139 displayed_strings.push_back(l10n_util::GetPluralStringFUTF16( |
141 IDS_DEL_AUTOFILL_COUNTER_SUGGESTIONS_SHORT, num_suggestions)); | 140 IDS_DEL_AUTOFILL_COUNTER_SUGGESTIONS_SHORT, num_suggestions)); |
142 break; | 141 break; |
143 default: | 142 default: |
144 NOTREACHED(); | 143 NOTREACHED(); |
145 } | 144 } |
146 } | 145 } |
147 | 146 |
148 bool synced = autofill_result->autofill_sync_enabled(); | 147 bool synced = autofill_result->IsSyncEnabled(); |
149 | 148 |
150 // Construct the resulting string from the sections in |displayed_strings|. | 149 // Construct the resulting string from the sections in |displayed_strings|. |
151 switch (displayed_strings.size()) { | 150 switch (displayed_strings.size()) { |
152 case 0: | 151 case 0: |
153 text = l10n_util::GetStringUTF16(IDS_DEL_AUTOFILL_COUNTER_EMPTY); | 152 text = l10n_util::GetStringUTF16(IDS_DEL_AUTOFILL_COUNTER_EMPTY); |
154 break; | 153 break; |
155 case 1: | 154 case 1: |
156 text = synced ? l10n_util::GetStringFUTF16( | 155 text = synced ? l10n_util::GetStringFUTF16( |
157 IDS_DEL_AUTOFILL_COUNTER_ONE_TYPE_SYNCED, | 156 IDS_DEL_AUTOFILL_COUNTER_ONE_TYPE_SYNCED, |
158 displayed_strings[0]) | 157 displayed_strings[0]) |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 prefs->GetBoolean(prefs::kDeleteCache)); | 242 prefs->GetBoolean(prefs::kDeleteCache)); |
244 prefs->SetBoolean(prefs::kDeleteCookiesBasic, | 243 prefs->SetBoolean(prefs::kDeleteCookiesBasic, |
245 prefs->GetBoolean(prefs::kDeleteCookies)); | 244 prefs->GetBoolean(prefs::kDeleteCookies)); |
246 prefs->SetInteger(prefs::kDeleteTimePeriodBasic, | 245 prefs->SetInteger(prefs::kDeleteTimePeriodBasic, |
247 prefs->GetInteger(prefs::kDeleteTimePeriod)); | 246 prefs->GetInteger(prefs::kDeleteTimePeriod)); |
248 prefs->SetBoolean(prefs::kPreferencesMigratedToBasic, true); | 247 prefs->SetBoolean(prefs::kPreferencesMigratedToBasic, true); |
249 } | 248 } |
250 } | 249 } |
251 | 250 |
252 } // namespace browsing_data | 251 } // namespace browsing_data |
OLD | NEW |