Chromium Code Reviews| 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 d40ee0f3c8f059c4ea39e73f49d8150c1b3f566a..31c176737b024af59ae2af7db256ad0cdf317db7 100644 |
| --- a/chrome/browser/browsing_data/browsing_data_counter_utils.cc |
| +++ b/chrome/browser/browsing_data/browsing_data_counter_utils.cc |
| @@ -5,9 +5,13 @@ |
| #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
| #include "base/command_line.h" |
| +#include "base/numerics/safe_conversions.h" |
| +#include "base/strings/string_util.h" |
| +#include "base/strings/utf_string_conversions.h" |
| #include "chrome/browser/browsing_data/autofill_counter.h" |
| #include "chrome/browser/browsing_data/cache_counter.h" |
| #include "chrome/browser/browsing_data/history_counter.h" |
| +#include "chrome/browser/browsing_data/hosted_apps_counter.h" |
| #include "chrome/browser/browsing_data/passwords_counter.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/pref_names.h" |
| @@ -158,6 +162,40 @@ base::string16 GetCounterTextFromResult( |
| default: |
| NOTREACHED(); |
| } |
| + |
| + } else if (pref_name == prefs::kDeleteHostedAppsData) { |
| + // Hosted apps counter. |
| + const HostedAppsCounter::HostedAppsResult* hosted_apps_result = |
| + static_cast<const HostedAppsCounter::HostedAppsResult*>(result); |
| + int hosted_apps_count = hosted_apps_result->Value(); |
| + |
| + DCHECK_GE(hosted_apps_result->Value(), |
| + base::checked_cast<HostedAppsCounter::ResultInt>( |
|
vabr (Chromium)
2016/06/20 14:16:50
BrowsingDataCounter::ResultInt
msramek
2016/06/20 14:41:02
Done.
|
| + hosted_apps_result->examples().size())); |
| + |
| + std::vector<base::string16> replacements; |
| + if (hosted_apps_count > 0) { |
| + replacements.push_back( // App1, |
| + base::UTF8ToUTF16(hosted_apps_result->examples()[0])); |
| + } |
| + if (hosted_apps_count > 1) { |
| + replacements.push_back( |
| + base::UTF8ToUTF16(hosted_apps_result->examples()[1])); // App2, |
| + } |
| + if (hosted_apps_count > 2) { |
| + replacements.push_back(l10n_util::GetPluralStringFUTF16( // and X-2 more. |
| + IDS_DEL_HOSTED_APPS_COUNTER_AND_X_MORE, |
| + hosted_apps_count - 2)); |
| + } |
| + |
| + // 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( |
| + l10n_util::GetPluralStringFUTF16( |
| + IDS_DEL_HOSTED_APPS_COUNTER, hosted_apps_count), |
| + replacements, |
| + nullptr); |
| } |
| return text; |