Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 + a fixed list of variations of parameters | |
| 52 // of the given feature [V_1, ..., V_n]. The entry will have n+2 states: | |
| 53 // Default, Enabled: V_1, ..., Enabled: V_n, Disabled. When not specified or | |
| 54 // set to Default, the normal default values of the feature and of the | |
| 55 // parameters are used. | |
| 56 FEATURE_WITH_VARIATIONS_VALUE, | |
| 57 }; | |
| 58 | |
| 59 // Describes state of a feature. | |
| 60 enum State { | |
| 61 // The state of the feature is not overridden by the user. | |
| 62 DEFAULT, | |
| 63 // The feature is enabled by the user. | |
| 64 ENABLED, | |
| 65 // The feature is disabled by the user. | |
| 66 DISABLED, | |
| 50 }; | 67 }; |
| 51 | 68 |
| 52 // Used for MULTI_VALUE types to describe one of the possible values the user | 69 // Used for MULTI_VALUE types to describe one of the possible values the user |
| 53 // can select. | 70 // can select. |
| 54 struct Choice { | 71 struct Choice { |
| 55 // ID of the message containing the choice name. | 72 // ID of the message containing the choice name. |
| 56 int description_id; | 73 int description_id; |
| 57 | 74 |
| 58 // Command line switch and value to enabled for this choice. | 75 // Command line switch and value to enabled for this choice. |
| 59 const char* command_line_switch; | 76 const char* command_line_switch; |
| 60 // Simple switches that have no value should use "" for command_line_value. | 77 // Simple switches that have no value should use "" for command_line_value. |
| 61 const char* command_line_value; | 78 const char* command_line_value; |
| 62 }; | 79 }; |
| 63 | 80 |
| 81 // Configures one parameter for FEATURE_WITH_VARIATIONS_VALUE. | |
| 82 struct FeatureParam { | |
| 83 const char* param_name; | |
| 84 const char* param_value; | |
| 85 }; | |
| 86 | |
| 87 // Specified one variation (list of parameter values) for | |
| 88 // FEATURE_WITH_VARIATIONS_VALUE. | |
| 89 struct FeatureVariation { | |
| 90 const char* description_text; | |
| 91 const FeatureParam* params; | |
| 92 int num_params; | |
| 93 }; | |
| 94 | |
| 64 // The internal name of the feature entry. This is never shown to the user. | 95 // 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 | 96 // It _is_ however stored in the prefs file, so you shouldn't change the |
| 66 // name of existing flags. | 97 // name of existing flags. |
| 67 const char* internal_name; | 98 const char* internal_name; |
| 68 | 99 |
| 69 // String id of the message containing the feature's name. | 100 // String id of the message containing the feature's name. |
| 70 int visible_name_id; | 101 int visible_name_id; |
| 71 | 102 |
| 72 // String id of the message containing the feature's description. | 103 // String id of the message containing the feature's description. |
| 73 int visible_description_id; | 104 int visible_description_id; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 92 // disable the feature. | 123 // disable the feature. |
| 93 const char* disable_command_line_switch; | 124 const char* disable_command_line_switch; |
| 94 const char* disable_command_line_value; | 125 const char* disable_command_line_value; |
| 95 | 126 |
| 96 // For FEATURE_VALUE, the base::Feature this entry corresponds to. | 127 // For FEATURE_VALUE, the base::Feature this entry corresponds to. |
| 97 const base::Feature* feature; | 128 const base::Feature* feature; |
| 98 | 129 |
| 99 // This is used if type is MULTI_VALUE. | 130 // This is used if type is MULTI_VALUE. |
| 100 const Choice* choices; | 131 const Choice* choices; |
| 101 | 132 |
| 102 // Number of |choices|. | 133 // This is used if type is FEATURE_WITH_VARIATIONS_VALUE. The first variation |
| 103 // This is used if type is MULTI_VALUE. | 134 // is the default "Enabled" variation, its description_id is disregarded. |
| 104 int num_choices; | 135 const FeatureVariation* feature_variations; |
| 105 | 136 |
| 106 // Returns the name used in prefs for the choice at the specified |index|. | 137 // The name of the Finch trial in which the selected variation parameters |
|
Alexei Svitkine (slow)
2016/06/08 18:54:35
Finch is an internal codename and shouldn't be use
jkrcal
2016/06/09 09:55:15
Done.
| |
| 107 std::string NameForChoice(int index) const; | 138 // should be registered. This is used if type is |
| 139 // FEATURE_WITH_VARIATIONS_VALUE. | |
| 140 const char* feature_trial; | |
|
Alexei Svitkine (slow)
2016/06/08 18:54:35
feature_trial_name
jkrcal
2016/06/09 09:55:15
Done.
| |
| 108 | 141 |
| 109 // Returns the human readable description for the choice at |index|. | 142 // Number of options to choose from. This is used if type is MULTI_VALUE, |
| 110 base::string16 DescriptionForChoice(int index) const; | 143 // ENABLE_DISABLE_VALUE, FEATURE_VALUE, or FEATURE_WITH_VARIATIONS_VALUE. |
| 144 int num_options; | |
| 145 | |
| 146 // Returns the name used in prefs for the option at the specified |index|. | |
| 147 // Only used for types that use |num_options|. | |
| 148 std::string NameForOption(int index) const; | |
| 149 | |
| 150 // Returns the human readable description for the option at |index|. | |
| 151 // Only used for types that use |num_options|. | |
| 152 base::string16 DescriptionForOption(int index) const; | |
| 153 | |
| 154 // Returns the state of the feature at |index|. Only applicable for types | |
| 155 // FEATURE_VALUE and FEATURE_WITH_VARIATIONS_VALUE. | |
| 156 FeatureEntry::State StateForOption(int index) const; | |
| 157 | |
| 158 // Returns the variation for the option at |index| or nullptr if there is no | |
| 159 // variation associated at |index|. Only applicable for types FEATURE_VALUE | |
| 160 // and FEATURE_WITH_VARIATIONS_VALUE. | |
| 161 const FeatureEntry::FeatureVariation* VariationForOption(int index) const; | |
| 111 }; | 162 }; |
| 112 | 163 |
| 113 namespace testing { | 164 namespace testing { |
| 114 | 165 |
| 115 // Separator used for multi values. Multi values are represented in prefs as | 166 // Separator used for multi values. Multi values are represented in prefs as |
| 116 // name-of-experiment + kMultiSeparator + selected_index. | 167 // name-of-experiment + kMultiSeparator + selected_index. |
| 117 extern const char kMultiSeparator[]; | 168 extern const char kMultiSeparator[]; |
| 118 | 169 |
| 119 } // namespace | 170 } // namespace |
| 120 | 171 |
| 121 } // namespace flag_ui | 172 } // namespace flag_ui |
| 122 | 173 |
| 123 #endif // COMPONENTS_FLAGS_UI_FEATURE_ENTRY_H_ | 174 #endif // COMPONENTS_FLAGS_UI_FEATURE_ENTRY_H_ |
| OLD | NEW |