OLD | NEW |
(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 #ifndef COMPONENTS_FLAGS_UI_FEATURE_ENTRY_H_ |
| 6 #define COMPONENTS_FLAGS_UI_FEATURE_ENTRY_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/strings/string16.h" |
| 11 |
| 12 namespace base { |
| 13 struct Feature; |
| 14 } |
| 15 |
| 16 namespace flags_ui { |
| 17 |
| 18 // FeatureEntry is used to describe an experimental feature. |
| 19 // |
| 20 // Note that features should eventually be either turned on by default with no |
| 21 // about_flags entries or deleted. Most feature entries should only be around |
| 22 // for a few milestones, until their full launch. |
| 23 struct FeatureEntry { |
| 24 enum Type { |
| 25 // A feature with a single flag value. This is typically what you want. |
| 26 SINGLE_VALUE, |
| 27 |
| 28 // A default enabled feature with a single flag value to disable it. Please |
| 29 // consider whether you really need a flag to disable the feature, and even |
| 30 // if so remove the disable flag as soon as it is no longer needed. |
| 31 SINGLE_DISABLE_VALUE, |
| 32 |
| 33 // The feature has multiple values only one of which is ever enabled. |
| 34 // The first of the values should correspond to a deactivated state for this |
| 35 // feature (i.e. no command line option). For MULTI_VALUE entries, the |
| 36 // command_line of the FeatureEntry is not used. If the experiment is |
| 37 // enabled the command line of the selected Choice is enabled. |
| 38 MULTI_VALUE, |
| 39 |
| 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 |
| 42 // if the feature should be on when not explicitly specified via about |
| 43 // flags - for example via FieldTrials. |
| 44 ENABLE_DISABLE_VALUE, |
| 45 |
| 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 |
| 48 // to Default, the normal default value of the feature is used. |
| 49 FEATURE_VALUE, |
| 50 }; |
| 51 |
| 52 // Used for MULTI_VALUE types to describe one of the possible values the user |
| 53 // can select. |
| 54 struct Choice { |
| 55 // ID of the message containing the choice name. |
| 56 int description_id; |
| 57 |
| 58 // Command line switch and value to enabled for this choice. |
| 59 const char* command_line_switch; |
| 60 // Simple switches that have no value should use "" for command_line_value. |
| 61 const char* command_line_value; |
| 62 }; |
| 63 |
| 64 // 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 |
| 66 // name of existing flags. |
| 67 const char* internal_name; |
| 68 |
| 69 // String id of the message containing the feature's name. |
| 70 int visible_name_id; |
| 71 |
| 72 // String id of the message containing the feature's description. |
| 73 int visible_description_id; |
| 74 |
| 75 // The platforms the feature is available on. |
| 76 // Needs to be more than a compile-time #ifdef because of profile sync. |
| 77 unsigned supported_platforms; // bitmask |
| 78 |
| 79 // Type of entry. |
| 80 Type type; |
| 81 |
| 82 // The commandline switch and value that are added when this flag is active. |
| 83 // This is different from |internal_name| so that the commandline flag can be |
| 84 // renamed without breaking the prefs file. |
| 85 // This is used if type is SINGLE_VALUE or ENABLE_DISABLE_VALUE. |
| 86 const char* command_line_switch; |
| 87 |
| 88 // Simple switches that have no value should use "" for command_line_value. |
| 89 const char* command_line_value; |
| 90 |
| 91 // For ENABLE_DISABLE_VALUE, the command line switch and value to explicitly |
| 92 // disable the feature. |
| 93 const char* disable_command_line_switch; |
| 94 const char* disable_command_line_value; |
| 95 |
| 96 // For FEATURE_VALUE, the base::Feature this entry corresponds to. |
| 97 const base::Feature* feature; |
| 98 |
| 99 // This is used if type is MULTI_VALUE. |
| 100 const Choice* choices; |
| 101 |
| 102 // Number of |choices|. |
| 103 // This is used if type is MULTI_VALUE. |
| 104 int num_choices; |
| 105 |
| 106 // Returns the name used in prefs for the choice at the specified |index|. |
| 107 std::string NameForChoice(int index) const; |
| 108 |
| 109 // Returns the human readable description for the choice at |index|. |
| 110 base::string16 DescriptionForChoice(int index) const; |
| 111 }; |
| 112 |
| 113 namespace testing { |
| 114 |
| 115 // Separator used for multi values. Multi values are represented in prefs as |
| 116 // name-of-experiment + kMultiSeparator + selected_index. |
| 117 extern const char kMultiSeparator[]; |
| 118 |
| 119 } // namespace |
| 120 |
| 121 } // namespace flag_ui |
| 122 |
| 123 #endif // COMPONENTS_FLAGS_UI_FEATURE_ENTRY_H_ |
OLD | NEW |