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

Unified Diff: chrome/browser/browsing_data/browsing_data_counter_utils.cc

Issue 2080283002: Implement GetCounterTextFromResult() for the hosted apps counter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
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..0c92d534d9282b0670e9465cc762d7c639bf6839 100644
--- a/chrome/browser/browsing_data/browsing_data_counter_utils.cc
+++ b/chrome/browser/browsing_data/browsing_data_counter_utils.cc
@@ -5,9 +5,12 @@
#include "chrome/browser/browsing_data/browsing_data_counter_utils.h"
#include "base/command_line.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 +161,39 @@ 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((unsigned int)hosted_apps_result->Value(),
vabr (Chromium) 2016/06/20 13:51:43 Please do not use C-style casting. Consider using
msramek 2016/06/20 14:06:18 Done. Yeah, I just quickly added this to compile a
+ 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;

Powered by Google App Engine
This is Rietveld 408576698