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

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

Issue 2036193002: Allow overriding variation parameter via chrome://flags. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build deps #2 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 unified diff | Download patch
« no previous file with comments | « components/flags_ui/DEPS ('k') | components/flags_ui/feature_entry.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 #ifndef COMPONENTS_FLAGS_UI_FEATURE_ENTRY_H_ 5 #ifndef COMPONENTS_FLAGS_UI_FEATURE_ENTRY_H_
6 #define COMPONENTS_FLAGS_UI_FEATURE_ENTRY_H_ 6 #define COMPONENTS_FLAGS_UI_FEATURE_ENTRY_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 29 matching lines...) Expand all
40 // The feature has three possible values: Default, Enabled and Disabled. 40 // The feature has three possible values: Default, Enabled and Disabled.
41 // This should be used for features that may have their own logic to decide 41 // This should be used for features that may have their own logic to decide
42 // if the feature should be on when not explicitly specified via about 42 // if the feature should be on when not explicitly specified via about
43 // flags - for example via FieldTrials. 43 // flags - for example via FieldTrials.
44 ENABLE_DISABLE_VALUE, 44 ENABLE_DISABLE_VALUE,
45 45
46 // Corresponds to a base::Feature, per base/feature_list.h. The entry will 46 // Corresponds to a base::Feature, per base/feature_list.h. The entry will
47 // have three states: Default, Enabled, Disabled. When not specified or set 47 // have three states: Default, Enabled, Disabled. When not specified or set
48 // to Default, the normal default value of the feature is used. 48 // to Default, the normal default value of the feature is used.
49 FEATURE_VALUE, 49 FEATURE_VALUE,
50
51 // Corresponds to a base::Feature and additional options [O_1, ..., O_n]
52 // that specify variation parameters. Each of the options can specify a set
53 // of variation parameters. The entry will have n+2 states: Default,
54 // Enabled: V_1, ..., Enabled: V_n, Disabled. When not specified or set to
55 // Default, the normal default values of the feature and of the parameters
56 // are used.
57 FEATURE_WITH_VARIATIONS_VALUE,
58 };
59
60 // Describes state of a feature.
61 enum FeatureState {
62 // The state of the feature is not overridden by the user.
63 DEFAULT,
64 // The feature is enabled by the user.
65 ENABLED,
66 // The feature is disabled by the user.
67 DISABLED,
50 }; 68 };
51 69
52 // Used for MULTI_VALUE types to describe one of the possible values the user 70 // Used for MULTI_VALUE types to describe one of the possible values the user
53 // can select. 71 // can select.
54 struct Choice { 72 struct Choice {
55 // ID of the message containing the choice name. 73 // ID of the message containing the choice name.
56 int description_id; 74 int description_id;
57 75
58 // Command line switch and value to enabled for this choice. 76 // Command line switch and value to enabled for this choice.
59 const char* command_line_switch; 77 const char* command_line_switch;
60 // Simple switches that have no value should use "" for command_line_value. 78 // Simple switches that have no value should use "" for command_line_value.
61 const char* command_line_value; 79 const char* command_line_value;
62 }; 80 };
63 81
82 // Configures one parameter for FEATURE_WITH_VARIATIONS_VALUE.
83 struct FeatureParam {
84 const char* param_name;
85 const char* param_value;
86 };
87
88 // Specified one variation (list of parameter values) for
89 // FEATURE_WITH_VARIATIONS_VALUE.
90 struct FeatureVariation {
91 // Text that denotes the variation in chrome://flags. For each variation,
92 // the user is shown an option labeled "Enabled <description_text>" (with
93 // the exception of the first option labeled "Enabled" to make clear it is
94 // the default one). No need for description_id, chrome://flags should not
95 // get translated. The other parts here use ids for historical reasons and
96 // can realistically also be moved to direct description_texts.
97 const char* description_text;
98 const FeatureParam* params;
99 int num_params;
100 };
101
64 // The internal name of the feature entry. This is never shown to the user. 102 // The internal name of the feature entry. This is never shown to the user.
65 // It _is_ however stored in the prefs file, so you shouldn't change the 103 // It _is_ however stored in the prefs file, so you shouldn't change the
66 // name of existing flags. 104 // name of existing flags.
67 const char* internal_name; 105 const char* internal_name;
68 106
69 // String id of the message containing the feature's name. 107 // String id of the message containing the feature's name.
70 int visible_name_id; 108 int visible_name_id;
71 109
72 // String id of the message containing the feature's description. 110 // String id of the message containing the feature's description.
73 int visible_description_id; 111 int visible_description_id;
(...skipping 15 matching lines...) Expand all
89 const char* command_line_value; 127 const char* command_line_value;
90 128
91 // For ENABLE_DISABLE_VALUE, the command line switch and value to explicitly 129 // For ENABLE_DISABLE_VALUE, the command line switch and value to explicitly
92 // disable the feature. 130 // disable the feature.
93 const char* disable_command_line_switch; 131 const char* disable_command_line_switch;
94 const char* disable_command_line_value; 132 const char* disable_command_line_value;
95 133
96 // For FEATURE_VALUE, the base::Feature this entry corresponds to. 134 // For FEATURE_VALUE, the base::Feature this entry corresponds to.
97 const base::Feature* feature; 135 const base::Feature* feature;
98 136
99 // This is used if type is MULTI_VALUE. 137 // Number of options to choose from. This is used if type is MULTI_VALUE,
138 // ENABLE_DISABLE_VALUE, FEATURE_VALUE, or FEATURE_WITH_VARIATIONS_VALUE.
139 int num_options;
140
141 // This describes the options if type is MULTI_VALUE.
100 const Choice* choices; 142 const Choice* choices;
101 143
102 // Number of |choices|. 144 // This describes the options if type is FEATURE_WITH_VARIATIONS_VALUE.
103 // This is used if type is MULTI_VALUE. 145 // The first variation is the default "Enabled" variation, its description_id
104 int num_choices; 146 // is disregarded.
147 const FeatureVariation* feature_variations;
105 148
106 // Returns the name used in prefs for the choice at the specified |index|. 149 // The name of the FieldTrial in which the selected variation parameters
107 std::string NameForChoice(int index) const; 150 // should be registered. This is used if type is
151 // FEATURE_WITH_VARIATIONS_VALUE.
152 const char* feature_trial_name;
108 153
109 // Returns the human readable description for the choice at |index|. 154 // Returns the name used in prefs for the option at the specified |index|.
110 base::string16 DescriptionForChoice(int index) const; 155 // Only used for types that use |num_options|.
156 std::string NameForOption(int index) const;
157
158 // Returns the human readable description for the option at |index|.
159 // Only used for types that use |num_options|.
160 base::string16 DescriptionForOption(int index) const;
161
162 // Returns the choice for the option at |index|. Only applicable for type
163 // FEATURE_MULTI.
164 const FeatureEntry::Choice& ChoiceForOption(int index) const;
165
166 // Returns the state of the feature at |index|. Only applicable for types
167 // FEATURE_VALUE and FEATURE_WITH_VARIATIONS_VALUE.
168 FeatureEntry::FeatureState StateForOption(int index) const;
169
170 // Returns the variation for the option at |index| or nullptr if there is no
171 // variation associated at |index|. Only applicable for types FEATURE_VALUE
172 // and FEATURE_WITH_VARIATIONS_VALUE.
173 const FeatureEntry::FeatureVariation* VariationForOption(int index) const;
111 }; 174 };
112 175
113 namespace testing { 176 namespace testing {
114 177
115 // Separator used for multi values. Multi values are represented in prefs as 178 // Separator used for multi values. Multi values are represented in prefs as
116 // name-of-experiment + kMultiSeparator + selected_index. 179 // name-of-experiment + kMultiSeparator + selected_index.
117 extern const char kMultiSeparator[]; 180 extern const char kMultiSeparator[];
118 181
119 } // namespace 182 } // namespace
120 183
121 } // namespace flag_ui 184 } // namespace flag_ui
122 185
123 #endif // COMPONENTS_FLAGS_UI_FEATURE_ENTRY_H_ 186 #endif // COMPONENTS_FLAGS_UI_FEATURE_ENTRY_H_
OLDNEW
« no previous file with comments | « components/flags_ui/DEPS ('k') | components/flags_ui/feature_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698