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