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

Side by Side Diff: components/flags_ui/feature_entry.cc

Issue 2774203002: Migrate about:flags messages to const char* (Closed)
Patch Set: fix iOS compilation Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « components/flags_ui/feature_entry.h ('k') | components/flags_ui/flags_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/flags_ui/feature_entry.h" 5 #include "components/flags_ui/feature_entry.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/strings/grit/components_strings.h"
11 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
12 11
13 namespace flags_ui { 12 namespace flags_ui {
14 13
14 const char kGenericExperimentChoiceDefault[] = "Default";
15 const char kGenericExperimentChoiceEnabled[] = "Enabled";
16 const char kGenericExperimentChoiceDisabled[] = "Disabled";
17 const char kGenericExperimentChoiceAutomatic[] = "Automatic";
18
15 std::string FeatureEntry::NameForOption(int index) const { 19 std::string FeatureEntry::NameForOption(int index) const {
16 DCHECK(type == FeatureEntry::MULTI_VALUE || 20 DCHECK(type == FeatureEntry::MULTI_VALUE ||
17 type == FeatureEntry::ENABLE_DISABLE_VALUE || 21 type == FeatureEntry::ENABLE_DISABLE_VALUE ||
18 type == FeatureEntry::FEATURE_VALUE || 22 type == FeatureEntry::FEATURE_VALUE ||
19 type == FeatureEntry::FEATURE_WITH_PARAMS_VALUE); 23 type == FeatureEntry::FEATURE_WITH_PARAMS_VALUE);
20 DCHECK_LT(index, num_options); 24 DCHECK_LT(index, num_options);
21 return std::string(internal_name) + testing::kMultiSeparator + 25 return std::string(internal_name) + testing::kMultiSeparator +
22 base::IntToString(index); 26 base::IntToString(index);
23 } 27 }
24 28
25 base::string16 FeatureEntry::DescriptionForOption(int index) const { 29 base::string16 FeatureEntry::DescriptionForOption(int index) const {
26 DCHECK(type == FeatureEntry::MULTI_VALUE || 30 DCHECK(type == FeatureEntry::MULTI_VALUE ||
27 type == FeatureEntry::ENABLE_DISABLE_VALUE || 31 type == FeatureEntry::ENABLE_DISABLE_VALUE ||
28 type == FeatureEntry::FEATURE_VALUE || 32 type == FeatureEntry::FEATURE_VALUE ||
29 type == FeatureEntry::FEATURE_WITH_PARAMS_VALUE); 33 type == FeatureEntry::FEATURE_WITH_PARAMS_VALUE);
30 DCHECK_LT(index, num_options); 34 DCHECK_LT(index, num_options);
31 int description_id; 35 const char* description = nullptr;
32 if (type == FeatureEntry::ENABLE_DISABLE_VALUE || 36 if (type == FeatureEntry::ENABLE_DISABLE_VALUE ||
33 type == FeatureEntry::FEATURE_VALUE) { 37 type == FeatureEntry::FEATURE_VALUE) {
34 const int kEnableDisableDescriptionIds[] = { 38 const char* kEnableDisableDescriptions[] = {
35 IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, 39 kGenericExperimentChoiceDefault, kGenericExperimentChoiceEnabled,
36 IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED, 40 kGenericExperimentChoiceDisabled,
37 IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED,
38 }; 41 };
39 description_id = kEnableDisableDescriptionIds[index]; 42 description = kEnableDisableDescriptions[index];
40 } else if (type == FeatureEntry::FEATURE_WITH_PARAMS_VALUE) { 43 } else if (type == FeatureEntry::FEATURE_WITH_PARAMS_VALUE) {
41 if (index == 0) { 44 if (index == 0) {
42 description_id = IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT; 45 description = kGenericExperimentChoiceDefault;
43 } else if (index == 1) { 46 } else if (index == 1) {
44 description_id = IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED; 47 description = kGenericExperimentChoiceEnabled;
45 } else if (index < num_options - 1) { 48 } else if (index < num_options - 1) {
46 // First two options do not have variations params. 49 // First two options do not have variations params.
47 int variation_index = index - 2; 50 int variation_index = index - 2;
48 return l10n_util::GetStringUTF16(IDS_GENERIC_EXPERIMENT_CHOICE_ENABLED) + 51 return base::ASCIIToUTF16(
52 base::StringPiece(kGenericExperimentChoiceEnabled)) +
49 base::ASCIIToUTF16(" ") + 53 base::ASCIIToUTF16(" ") +
50 base::ASCIIToUTF16( 54 base::ASCIIToUTF16(
51 feature_variations[variation_index].description_text); 55 feature_variations[variation_index].description_text);
52 } else { 56 } else {
53 DCHECK_EQ(num_options - 1, index); 57 DCHECK_EQ(num_options - 1, index);
54 description_id = IDS_GENERIC_EXPERIMENT_CHOICE_DISABLED; 58 description = kGenericExperimentChoiceDisabled;
55 } 59 }
56 } else { 60 } else {
57 description_id = choices[index].description_id; 61 description = choices[index].description;
58 } 62 }
59 return l10n_util::GetStringUTF16(description_id); 63 return base::ASCIIToUTF16(base::StringPiece(description));
60 } 64 }
61 65
62 const FeatureEntry::Choice& FeatureEntry::ChoiceForOption(int index) const { 66 const FeatureEntry::Choice& FeatureEntry::ChoiceForOption(int index) const {
63 DCHECK_EQ(FeatureEntry::MULTI_VALUE, type); 67 DCHECK_EQ(FeatureEntry::MULTI_VALUE, type);
64 DCHECK_LT(index, num_options); 68 DCHECK_LT(index, num_options);
65 69
66 return choices[index]; 70 return choices[index];
67 } 71 }
68 72
69 FeatureEntry::FeatureState FeatureEntry::StateForOption(int index) const { 73 FeatureEntry::FeatureState FeatureEntry::StateForOption(int index) const {
(...skipping 27 matching lines...) Expand all
97 101
98 namespace testing { 102 namespace testing {
99 103
100 // WARNING: '@' is also used in the html file. If you update this constant you 104 // WARNING: '@' is also used in the html file. If you update this constant you
101 // also need to update the html file. 105 // also need to update the html file.
102 const char kMultiSeparator[] = "@"; 106 const char kMultiSeparator[] = "@";
103 107
104 } // namespace testing 108 } // namespace testing
105 109
106 } // namespace flags_ui 110 } // namespace flags_ui
OLDNEW
« no previous file with comments | « components/flags_ui/feature_entry.h ('k') | components/flags_ui/flags_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698