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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/flags_ui/feature_entry.h"
6
7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "grit/components_strings.h"
10 #include "ui/base/l10n/l10n_util.h"
11
12 namespace flags_ui {
13
14 std::string FeatureEntry::NameForChoice(int index) const {
15 DCHECK(type == FeatureEntry::MULTI_VALUE ||
16 type == FeatureEntry::ENABLE_DISABLE_VALUE ||
17 type == FeatureEntry::FEATURE_VALUE);
18 DCHECK_LT(index, num_choices);
19 return std::string(internal_name) + testing::kMultiSeparator +
20 base::IntToString(index);
21 }
22
23 base::string16 FeatureEntry::DescriptionForChoice(int index) const {
24 DCHECK(type == FeatureEntry::MULTI_VALUE ||
25 type == FeatureEntry::ENABLE_DISABLE_VALUE ||
26 type == FeatureEntry::FEATURE_VALUE);
27 DCHECK_LT(index, num_choices);
28 int description_id;
29 if (type == FeatureEntry::ENABLE_DISABLE_VALUE ||
30 type == FeatureEntry::FEATURE_VALUE) {
31 const int kEnableDisableDescriptionIds[] = {
32 IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT,
33 IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED,
34 IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
35 };
36 description_id = kEnableDisableDescriptionIds[index];
37 } else {
38 description_id = choices[index].description_id;
39 }
40 return l10n_util::GetStringUTF16(description_id);
41 }
42
43 namespace testing {
44
45 // WARNING: '@' is also used in the html file. If you update this constant you
46 // also need to update the html file.
47 const char kMultiSeparator[] = "@";
48
49 } // namespace testing
50
51 } // namespace flags_ui
OLDNEW
« 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