Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: components/browsing_data/core/browsing_data_utils.cc

Issue 2798243004: Show password sync status in CBD (Closed)
Patch Set: add sync test Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 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 == browsing_data::prefs::kDeletePasswords || 77 } else if (pref_name == prefs::kDeletePasswords) {
78 pref_name == browsing_data::prefs::kDeleteDownloadHistory) { 78 const PasswordsCounter::PasswordResult* password_result =
79 // Counters with trivially formatted result: passwords and downloads. 79 static_cast<const PasswordsCounter::PasswordResult*>(result);
80 browsing_data::BrowsingDataCounter::ResultInt count = 80
81 static_cast<const browsing_data::BrowsingDataCounter::FinishedResult*>( 81 BrowsingDataCounter::ResultInt count = password_result->Value();
82 result) 82
83 text = l10n_util::GetPluralStringFUTF16(
84 password_result->password_sync_enabled()
85 ? IDS_DEL_PASSWORDS_COUNTER_SYNCED
86 : IDS_DEL_PASSWORDS_COUNTER,
87 count);
88 } else if (pref_name == prefs::kDeleteDownloadHistory) {
89 BrowsingDataCounter::ResultInt count =
90 static_cast<const BrowsingDataCounter::FinishedResult*>(result)
83 ->Value(); 91 ->Value();
84 text = l10n_util::GetPluralStringFUTF16( 92 text = l10n_util::GetPluralStringFUTF16(IDS_DEL_DOWNLOADS_COUNTER, count);
85 pref_name == browsing_data::prefs::kDeletePasswords 93 } else if (pref_name == prefs::kDeleteBrowsingHistoryBasic) {
86 ? IDS_DEL_PASSWORDS_COUNTER
87 : IDS_DEL_DOWNLOADS_COUNTER,
88 count);
89 } else if (pref_name == browsing_data::prefs::kDeleteBrowsingHistoryBasic) {
90 // The basic tab doesn't show history counter results. 94 // The basic tab doesn't show history counter results.
91 NOTREACHED(); 95 NOTREACHED();
92 } else if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) { 96 } else if (pref_name == prefs::kDeleteBrowsingHistory) {
93 // History counter. 97 // History counter.
94 const browsing_data::HistoryCounter::HistoryResult* history_result = 98 const HistoryCounter::HistoryResult* history_result =
95 static_cast<const browsing_data::HistoryCounter::HistoryResult*>( 99 static_cast<const HistoryCounter::HistoryResult*>(result);
96 result); 100 BrowsingDataCounter::ResultInt local_item_count = history_result->Value();
97 browsing_data::BrowsingDataCounter::ResultInt local_item_count =
98 history_result->Value();
99 bool has_synced_visits = history_result->has_synced_visits(); 101 bool has_synced_visits = history_result->has_synced_visits();
100 text = has_synced_visits 102 text = has_synced_visits
101 ? l10n_util::GetPluralStringFUTF16( 103 ? l10n_util::GetPluralStringFUTF16(
102 IDS_DEL_BROWSING_HISTORY_COUNTER_SYNCED, local_item_count) 104 IDS_DEL_BROWSING_HISTORY_COUNTER_SYNCED, local_item_count)
103 : l10n_util::GetPluralStringFUTF16( 105 : l10n_util::GetPluralStringFUTF16(
104 IDS_DEL_BROWSING_HISTORY_COUNTER, local_item_count); 106 IDS_DEL_BROWSING_HISTORY_COUNTER, local_item_count);
105 107
106 } else if (pref_name == browsing_data::prefs::kDeleteFormData) { 108 } else if (pref_name == prefs::kDeleteFormData) {
107 // Autofill counter. 109 // Autofill counter.
108 const browsing_data::AutofillCounter::AutofillResult* autofill_result = 110 const AutofillCounter::AutofillResult* autofill_result =
109 static_cast<const browsing_data::AutofillCounter::AutofillResult*>( 111 static_cast<const AutofillCounter::AutofillResult*>(result);
110 result); 112 AutofillCounter::ResultInt num_suggestions = autofill_result->Value();
111 browsing_data::AutofillCounter::ResultInt num_suggestions = 113 AutofillCounter::ResultInt num_credit_cards =
112 autofill_result->Value();
113 browsing_data::AutofillCounter::ResultInt num_credit_cards =
114 autofill_result->num_credit_cards(); 114 autofill_result->num_credit_cards();
115 browsing_data::AutofillCounter::ResultInt num_addresses = 115 AutofillCounter::ResultInt num_addresses = autofill_result->num_addresses();
116 autofill_result->num_addresses();
117 116
118 std::vector<base::string16> displayed_strings; 117 std::vector<base::string16> displayed_strings;
119 118
120 if (num_credit_cards) { 119 if (num_credit_cards) {
121 displayed_strings.push_back(l10n_util::GetPluralStringFUTF16( 120 displayed_strings.push_back(l10n_util::GetPluralStringFUTF16(
122 IDS_DEL_AUTOFILL_COUNTER_CREDIT_CARDS, num_credit_cards)); 121 IDS_DEL_AUTOFILL_COUNTER_CREDIT_CARDS, num_credit_cards));
123 } 122 }
124 if (num_addresses) { 123 if (num_addresses) {
125 displayed_strings.push_back(l10n_util::GetPluralStringFUTF16( 124 displayed_strings.push_back(l10n_util::GetPluralStringFUTF16(
126 IDS_DEL_AUTOFILL_COUNTER_ADDRESSES, num_addresses)); 125 IDS_DEL_AUTOFILL_COUNTER_ADDRESSES, num_addresses));
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 prefs->GetBoolean(prefs::kDeleteCache)); 236 prefs->GetBoolean(prefs::kDeleteCache));
238 prefs->SetBoolean(prefs::kDeleteCookiesBasic, 237 prefs->SetBoolean(prefs::kDeleteCookiesBasic,
239 prefs->GetBoolean(prefs::kDeleteCookies)); 238 prefs->GetBoolean(prefs::kDeleteCookies));
240 prefs->SetInteger(prefs::kDeleteTimePeriodBasic, 239 prefs->SetInteger(prefs::kDeleteTimePeriodBasic,
241 prefs->GetInteger(prefs::kDeleteTimePeriod)); 240 prefs->GetInteger(prefs::kDeleteTimePeriod));
242 prefs->SetBoolean(prefs::kPreferencesMigratedToBasic, true); 241 prefs->SetBoolean(prefs::kPreferencesMigratedToBasic, true);
243 } 242 }
244 } 243 }
245 244
246 } // namespace browsing_data 245 } // namespace browsing_data
OLDNEW
« no previous file with comments | « components/browsing_data/core/BUILD.gn ('k') | components/browsing_data/core/browsing_data_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698