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

Unified Diff: components/flags_ui/feature_entry.cc

Issue 1415953005: Componentize about_flags::FeatureEntry in flags_ui component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 1 month 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
« no previous file with comments | « components/flags_ui/feature_entry.h ('k') | components/flags_ui/feature_entry_macros.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/flags_ui/feature_entry.cc
diff --git a/components/flags_ui/feature_entry.cc b/components/flags_ui/feature_entry.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b7556970cad778a9cef605e67d8c6bd5dcfa802e
--- /dev/null
+++ b/components/flags_ui/feature_entry.cc
@@ -0,0 +1,51 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/flags_ui/feature_entry.h"
+
+#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+#include "grit/components_strings.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace flags_ui {
+
+std::string FeatureEntry::NameForChoice(int index) const {
+ DCHECK(type == FeatureEntry::MULTI_VALUE ||
+ type == FeatureEntry::ENABLE_DISABLE_VALUE ||
+ type == FeatureEntry::FEATURE_VALUE);
+ DCHECK_LT(index, num_choices);
+ return std::string(internal_name) + testing::kMultiSeparator +
+ base::IntToString(index);
+}
+
+base::string16 FeatureEntry::DescriptionForChoice(int index) const {
+ DCHECK(type == FeatureEntry::MULTI_VALUE ||
+ type == FeatureEntry::ENABLE_DISABLE_VALUE ||
+ type == FeatureEntry::FEATURE_VALUE);
+ DCHECK_LT(index, num_choices);
+ int description_id;
+ if (type == FeatureEntry::ENABLE_DISABLE_VALUE ||
+ type == FeatureEntry::FEATURE_VALUE) {
+ const int kEnableDisableDescriptionIds[] = {
+ IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT,
+ IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
+ IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
+ };
+ description_id = kEnableDisableDescriptionIds[index];
+ } else {
+ description_id = choices[index].description_id;
+ }
+ return l10n_util::GetStringUTF16(description_id);
+}
+
+namespace testing {
+
+// WARNING: '@' is also used in the html file. If you update this constant you
+// also need to update the html file.
+const char kMultiSeparator[] = "@";
+
+} // namespace testing
+
+} // namespace flags_ui
« no previous file with comments | « components/flags_ui/feature_entry.h ('k') | components/flags_ui/feature_entry_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698