| Index: chrome/browser/browsing_data/browsing_data_counter_utils.cc
|
| diff --git a/chrome/browser/browsing_data/browsing_data_counter_utils.cc b/chrome/browser/browsing_data/browsing_data_counter_utils.cc
|
| index 4b7087f29544fbfd17766c2d633f845bc09281b2..02de813c03a7146d49da25f02e60fad95c70dfb3 100644
|
| --- a/chrome/browser/browsing_data/browsing_data_counter_utils.cc
|
| +++ b/chrome/browser/browsing_data/browsing_data_counter_utils.cc
|
| @@ -12,11 +12,9 @@
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/grit/generated_resources.h"
|
| -#include "components/browsing_data/core/counters/autofill_counter.h"
|
| -#include "components/browsing_data/core/counters/history_counter.h"
|
| -#include "components/browsing_data/core/counters/passwords_counter.h"
|
| #include "components/browsing_data/core/pref_names.h"
|
| #include "components/prefs/pref_service.h"
|
| +#include "grit/components_strings.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/base/text/bytes_formatting.h"
|
|
|
| @@ -54,29 +52,16 @@ base::string16 FormatBytesMBOrHigher(
|
| bytes, ui::DataUnits::DATA_UNITS_MEBIBYTE, true);
|
| }
|
|
|
| -base::string16 GetCounterTextFromResult(
|
| +base::string16 GetChromeCounterTextFromResult(
|
| const browsing_data::BrowsingDataCounter::Result* result) {
|
| - base::string16 text;
|
| std::string pref_name = result->source()->GetPrefName();
|
|
|
| if (!result->Finished()) {
|
| // The counter is still counting.
|
| - text = l10n_util::GetStringUTF16(IDS_CLEAR_BROWSING_DATA_CALCULATING);
|
| -
|
| - } else if (pref_name == browsing_data::prefs::kDeletePasswords ||
|
| - pref_name == browsing_data::prefs::kDeleteDownloadHistory) {
|
| - // Counters with trivially formatted result: passwords and downloads.
|
| - browsing_data::BrowsingDataCounter::ResultInt count =
|
| - static_cast<const browsing_data::BrowsingDataCounter::FinishedResult*>(
|
| - result)
|
| - ->Value();
|
| - text = l10n_util::GetPluralStringFUTF16(
|
| - pref_name == browsing_data::prefs::kDeletePasswords
|
| - ? IDS_DEL_PASSWORDS_COUNTER
|
| - : IDS_DEL_DOWNLOADS_COUNTER,
|
| - count);
|
| + return l10n_util::GetStringUTF16(IDS_CLEAR_BROWSING_DATA_CALCULATING);
|
| + }
|
|
|
| - } else if (pref_name == browsing_data::prefs::kDeleteCache) {
|
| + if (pref_name == browsing_data::prefs::kDeleteCache) {
|
| // Cache counter.
|
| browsing_data::BrowsingDataCounter::ResultInt cache_size_bytes =
|
| static_cast<const browsing_data::BrowsingDataCounter::FinishedResult*>(
|
| @@ -93,109 +78,28 @@ base::string16 GetCounterTextFromResult(
|
| static const int kBytesInAMegabyte = 1024 * 1024;
|
| if (cache_size_bytes >= kBytesInAMegabyte) {
|
| base::string16 formatted_size = FormatBytesMBOrHigher(cache_size_bytes);
|
| - text = time_period == browsing_data::ALL_TIME
|
| + return time_period == browsing_data::ALL_TIME
|
| ? formatted_size
|
| : l10n_util::GetStringFUTF16(
|
| IDS_DEL_CACHE_COUNTER_UPPER_ESTIMATE, formatted_size);
|
| - } else {
|
| - text = l10n_util::GetStringUTF16(IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY);
|
| - }
|
| -
|
| - } else if (pref_name == browsing_data::prefs::kDeleteBrowsingHistory) {
|
| - // History counter.
|
| - const browsing_data::HistoryCounter::HistoryResult* history_result =
|
| - static_cast<const browsing_data::HistoryCounter::HistoryResult*>(
|
| - result);
|
| - browsing_data::BrowsingDataCounter::ResultInt local_item_count =
|
| - history_result->Value();
|
| - bool has_synced_visits = history_result->has_synced_visits();
|
| -
|
| - text = has_synced_visits
|
| - ? l10n_util::GetPluralStringFUTF16(
|
| - IDS_DEL_BROWSING_HISTORY_COUNTER_SYNCED, local_item_count)
|
| - : l10n_util::GetPluralStringFUTF16(
|
| - IDS_DEL_BROWSING_HISTORY_COUNTER, local_item_count);
|
| -
|
| - } else if (pref_name == browsing_data::prefs::kDeleteFormData) {
|
| - // Autofill counter.
|
| - const browsing_data::AutofillCounter::AutofillResult* autofill_result =
|
| - static_cast<const browsing_data::AutofillCounter::AutofillResult*>(
|
| - result);
|
| - browsing_data::AutofillCounter::ResultInt num_suggestions =
|
| - autofill_result->Value();
|
| - browsing_data::AutofillCounter::ResultInt num_credit_cards =
|
| - autofill_result->num_credit_cards();
|
| - browsing_data::AutofillCounter::ResultInt num_addresses =
|
| - autofill_result->num_addresses();
|
| -
|
| - std::vector<base::string16> displayed_strings;
|
| -
|
| - if (num_credit_cards) {
|
| - displayed_strings.push_back(l10n_util::GetPluralStringFUTF16(
|
| - IDS_DEL_AUTOFILL_COUNTER_CREDIT_CARDS, num_credit_cards));
|
| - }
|
| - if (num_addresses) {
|
| - displayed_strings.push_back(l10n_util::GetPluralStringFUTF16(
|
| - IDS_DEL_AUTOFILL_COUNTER_ADDRESSES, num_addresses));
|
| - }
|
| - if (num_suggestions) {
|
| - // We use a different wording for autocomplete suggestions based on the
|
| - // length of the entire string.
|
| - switch (displayed_strings.size()) {
|
| - case 0:
|
| - displayed_strings.push_back(l10n_util::GetPluralStringFUTF16(
|
| - IDS_DEL_AUTOFILL_COUNTER_SUGGESTIONS, num_suggestions));
|
| - break;
|
| - case 1:
|
| - displayed_strings.push_back(l10n_util::GetPluralStringFUTF16(
|
| - IDS_DEL_AUTOFILL_COUNTER_SUGGESTIONS_LONG, num_suggestions));
|
| - break;
|
| - case 2:
|
| - displayed_strings.push_back(l10n_util::GetPluralStringFUTF16(
|
| - IDS_DEL_AUTOFILL_COUNTER_SUGGESTIONS_SHORT, num_suggestions));
|
| - break;
|
| - default:
|
| - NOTREACHED();
|
| - }
|
| - }
|
| -
|
| - // Construct the resulting string from the sections in |displayed_strings|.
|
| - switch (displayed_strings.size()) {
|
| - case 0:
|
| - text = l10n_util::GetStringUTF16(IDS_DEL_AUTOFILL_COUNTER_EMPTY);
|
| - break;
|
| - case 1:
|
| - text = displayed_strings[0];
|
| - break;
|
| - case 2:
|
| - text = l10n_util::GetStringFUTF16(IDS_DEL_AUTOFILL_COUNTER_TWO_TYPES,
|
| - displayed_strings[0],
|
| - displayed_strings[1]);
|
| - break;
|
| - case 3:
|
| - text = l10n_util::GetStringFUTF16(IDS_DEL_AUTOFILL_COUNTER_THREE_TYPES,
|
| - displayed_strings[0],
|
| - displayed_strings[1],
|
| - displayed_strings[2]);
|
| - break;
|
| - default:
|
| - NOTREACHED();
|
| }
|
| + return l10n_util::GetStringUTF16(IDS_DEL_CACHE_COUNTER_ALMOST_EMPTY);
|
| + }
|
|
|
| - } else if (pref_name == browsing_data::prefs::kDeleteMediaLicenses) {
|
| + if (pref_name == browsing_data::prefs::kDeleteMediaLicenses) {
|
| const MediaLicensesCounter::MediaLicenseResult* media_license_result =
|
| static_cast<const MediaLicensesCounter::MediaLicenseResult*>(result);
|
| if (media_license_result->Value() > 0) {
|
| - text = l10n_util::GetStringFUTF16(
|
| + return l10n_util::GetStringFUTF16(
|
| IDS_DEL_MEDIA_LICENSES_COUNTER_SITE_COMMENT,
|
| base::UTF8ToUTF16(media_license_result->GetOneOrigin()));
|
| - } else {
|
| - text = l10n_util::GetStringUTF16(
|
| - IDS_DEL_MEDIA_LICENSES_COUNTER_GENERAL_COMMENT);
|
| }
|
| + return l10n_util::GetStringUTF16(
|
| + IDS_DEL_MEDIA_LICENSES_COUNTER_GENERAL_COMMENT);
|
| + }
|
|
|
| #if defined(ENABLE_EXTENSIONS)
|
| - } else if (pref_name == browsing_data::prefs::kDeleteHostedAppsData) {
|
| + if (pref_name == browsing_data::prefs::kDeleteHostedAppsData) {
|
| // Hosted apps counter.
|
| const HostedAppsCounter::HostedAppsResult* hosted_apps_result =
|
| static_cast<const HostedAppsCounter::HostedAppsResult*>(result);
|
| @@ -223,15 +127,15 @@ base::string16 GetCounterTextFromResult(
|
| // The output string has both the number placeholder (#) and substitution
|
| // placeholders ($1, $2, $3). First fetch the correct plural string first,
|
| // then substitute the $ placeholders.
|
| - text = base::ReplaceStringPlaceholders(
|
| + return base::ReplaceStringPlaceholders(
|
| l10n_util::GetPluralStringFUTF16(
|
| IDS_DEL_HOSTED_APPS_COUNTER, hosted_apps_count),
|
| replacements,
|
| nullptr);
|
| -#endif
|
| }
|
| +#endif
|
|
|
| - return text;
|
| + return browsing_data::GetCounterTextFromResult(result);
|
| }
|
|
|
| bool GetDeletionPreferenceFromDataType(
|
|
|