OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_counter_utils.h" | 5 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browsing_data/autofill_counter.h" | |
10 #include "chrome/browser/browsing_data/cache_counter.h" | 9 #include "chrome/browser/browsing_data/cache_counter.h" |
11 #include "chrome/browser/browsing_data/history_counter.h" | |
12 #include "chrome/browser/browsing_data/media_licenses_counter.h" | 10 #include "chrome/browser/browsing_data/media_licenses_counter.h" |
13 #include "chrome/browser/browsing_data/passwords_counter.h" | |
14 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
17 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 15 #include "components/browsing_data/core/counters/autofill_counter.h" |
| 16 #include "components/browsing_data/core/counters/history_counter.h" |
| 17 #include "components/browsing_data/core/counters/passwords_counter.h" |
18 #include "components/browsing_data/core/pref_names.h" | 18 #include "components/browsing_data/core/pref_names.h" |
19 #include "components/prefs/pref_service.h" | 19 #include "components/prefs/pref_service.h" |
20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/base/text/bytes_formatting.h" | 21 #include "ui/base/text/bytes_formatting.h" |
22 | 22 |
23 #if defined(ENABLE_EXTENSIONS) | 23 #if defined(ENABLE_EXTENSIONS) |
24 #include "base/numerics/safe_conversions.h" | 24 #include "base/numerics/safe_conversions.h" |
25 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
27 #include "chrome/browser/browsing_data/hosted_apps_counter.h" | 27 #include "chrome/browser/browsing_data/hosted_apps_counter.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 text = time_period == browsing_data::EVERYTHING | 96 text = time_period == browsing_data::EVERYTHING |
97 ? formatted_size | 97 ? formatted_size |
98 : l10n_util::GetStringFUTF16( | 98 : l10n_util::GetStringFUTF16( |
99 IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE, formatted_size); | 99 IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE, formatted_size); |
100 } else { | 100 } else { |
101 text = l10n_util::GetStringUTF16(IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY); | 101 text = l10n_util::GetStringUTF16(IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY); |
102 } | 102 } |
103 | 103 |
104 } else if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) { | 104 } else if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) { |
105 // History counter. | 105 // History counter. |
106 const HistoryCounter::HistoryResult* history_result = | 106 const browsing_data::HistoryCounter::HistoryResult* history_result = |
107 static_cast<const HistoryCounter::HistoryResult*>(result); | 107 static_cast<const browsing_data::HistoryCounter::HistoryResult*>( |
| 108 result); |
108 browsing_data::BrowsingDataCounter::ResultInt local_item_count = | 109 browsing_data::BrowsingDataCounter::ResultInt local_item_count = |
109 history_result->Value(); | 110 history_result->Value(); |
110 bool has_synced_visits = history_result->has_synced_visits(); | 111 bool has_synced_visits = history_result->has_synced_visits(); |
111 | 112 |
112 text = has_synced_visits | 113 text = has_synced_visits |
113 ? l10n_util::GetPluralStringFUTF16( | 114 ? l10n_util::GetPluralStringFUTF16( |
114 IDS_DEL_BROWSING_HISTORY_COUNTER_SYNCED, local_item_count) | 115 IDS_DEL_BROWSING_HISTORY_COUNTER_SYNCED, local_item_count) |
115 : l10n_util::GetPluralStringFUTF16( | 116 : l10n_util::GetPluralStringFUTF16( |
116 IDS_DEL_BROWSING_HISTORY_COUNTER, local_item_count); | 117 IDS_DEL_BROWSING_HISTORY_COUNTER, local_item_count); |
117 | 118 |
118 } else if (pref_name == browsing_data::prefs::kDeleteFormData) { | 119 } else if (pref_name == browsing_data::prefs::kDeleteFormData) { |
119 // Autofill counter. | 120 // Autofill counter. |
120 const AutofillCounter::AutofillResult* autofill_result = | 121 const browsing_data::AutofillCounter::AutofillResult* autofill_result = |
121 static_cast<const AutofillCounter::AutofillResult*>(result); | 122 static_cast<const browsing_data::AutofillCounter::AutofillResult*>( |
122 AutofillCounter::ResultInt num_suggestions = autofill_result->Value(); | 123 result); |
123 AutofillCounter::ResultInt num_credit_cards = | 124 browsing_data::AutofillCounter::ResultInt num_suggestions = |
| 125 autofill_result->Value(); |
| 126 browsing_data::AutofillCounter::ResultInt num_credit_cards = |
124 autofill_result->num_credit_cards(); | 127 autofill_result->num_credit_cards(); |
125 AutofillCounter::ResultInt num_addresses = autofill_result->num_addresses(); | 128 browsing_data::AutofillCounter::ResultInt num_addresses = |
| 129 autofill_result->num_addresses(); |
126 | 130 |
127 std::vector<base::string16> displayed_strings; | 131 std::vector<base::string16> displayed_strings; |
128 | 132 |
129 if (num_credit_cards) { | 133 if (num_credit_cards) { |
130 displayed_strings.push_back(l10n_util::GetPluralStringFUTF16( | 134 displayed_strings.push_back(l10n_util::GetPluralStringFUTF16( |
131 IDS_DEL_AUTOFILL_COUNTER_CREDIT_CARDS, num_credit_cards)); | 135 IDS_DEL_AUTOFILL_COUNTER_CREDIT_CARDS, num_credit_cards)); |
132 } | 136 } |
133 if (num_addresses) { | 137 if (num_addresses) { |
134 displayed_strings.push_back(l10n_util::GetPluralStringFUTF16( | 138 displayed_strings.push_back(l10n_util::GetPluralStringFUTF16( |
135 IDS_DEL_AUTOFILL_COUNTER_ADDRESSES, num_addresses)); | 139 IDS_DEL_AUTOFILL_COUNTER_ADDRESSES, num_addresses)); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // preference. | 258 // preference. |
255 return false; | 259 return false; |
256 case browsing_data::NUM_TYPES: | 260 case browsing_data::NUM_TYPES: |
257 // This is not an actual type. | 261 // This is not an actual type. |
258 NOTREACHED(); | 262 NOTREACHED(); |
259 return false; | 263 return false; |
260 } | 264 } |
261 NOTREACHED(); | 265 NOTREACHED(); |
262 return false; | 266 return false; |
263 } | 267 } |
OLD | NEW |