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

Side by Side Diff: chrome/browser/about_flags.h

Issue 1407753002: Clean up terminology used in about_flags. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | chrome/browser/about_flags.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_BROWSER_ABOUT_FLAGS_H_ 5 #ifndef CHROME_BROWSER_ABOUT_FLAGS_H_
6 #define CHROME_BROWSER_ABOUT_FLAGS_H_ 6 #define CHROME_BROWSER_ABOUT_FLAGS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 13
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/metrics/histogram_base.h" 15 #include "base/metrics/histogram_base.h"
16 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
17 17
18 class PrefService; 18 class PrefService;
19 19
20 namespace base { 20 namespace base {
21 class ListValue; 21 class ListValue;
22 } 22 }
23 23
24 namespace flags_ui { 24 namespace flags_ui {
25 class FlagsStorage; 25 class FlagsStorage;
26 } 26 }
27 27
28 namespace about_flags { 28 namespace about_flags {
29 29
30 // Experiment is used internally by about_flags to describe an experiment (and 30 // FeatureEntry is used internally by about_flags to describe an experimental
31 // for testing). 31 // feature (and for testing).
Nico 2015/10/14 19:59:08 nit: Since this is maybe less clear now, maybe add
Alexei Svitkine (slow) 2015/10/14 20:14:29 Done.
32 // This is exposed only for testing. 32 // This is exposed only for testing.
33 struct Experiment { 33 struct FeatureEntry {
34 enum Type { 34 enum Type {
35 // An experiment with a single value. This is typically what you want. 35 // A feature with a single flag value. This is typically what you want.
36 SINGLE_VALUE, 36 SINGLE_VALUE,
37 37
38 // A default enabled experiment with a single value to disable it. This is 38 // A default enabled feature with a single flag value to disable it. Please
39 // for default enabled SINGLE_VALUE experiments. Please consider whether 39 // consider whether you really need a flag to disable the feature, and even
40 // you really need a flag to disable the experiment, and even if so remove 40 // if so remove the disable flag as soon as it is no longer needed.
41 // the disable flag as soon as it is no longer needed.
42 SINGLE_DISABLE_VALUE, 41 SINGLE_DISABLE_VALUE,
43 42
44 // The experiment has multiple values only one of which is ever enabled. 43 // The feature has multiple values only one of which is ever enabled.
45 // The first of the values should correspond to a deactivated state for this 44 // The first of the values should correspond to a deactivated state for this
46 // lab (i.e. no command line option). For MULTI_VALUE experiments the 45 // feature (i.e. no command line option). For MULTI_VALUE entries, the
47 // command_line of the Experiment is not used. If the experiment is enabled 46 // command_line of the FeatureEntry is not used. If the experiment is
48 // the command line of the selected Choice is enabled. 47 // enabled the command line of the selected Choice is enabled.
49 MULTI_VALUE, 48 MULTI_VALUE,
50 49
51 // The experiment has three possible values: Default, Enabled and Disabled. 50 // The feature has three possible values: Default, Enabled and Disabled.
52 // This should be used for experiments that may have their own logic to 51 // This should be used for features that may have their own logic to decide
53 // decide if the feature should be on when not explicitly specified via 52 // if the feature should be on when not explicitly specified via about
54 // about flags - for example via FieldTrials. 53 // flags - for example via FieldTrials.
55 ENABLE_DISABLE_VALUE, 54 ENABLE_DISABLE_VALUE,
56 }; 55 };
57 56
58 // Used for MULTI_VALUE types to describe one of the possible values the user 57 // Used for MULTI_VALUE types to describe one of the possible values the user
59 // can select. 58 // can select.
60 struct Choice { 59 struct Choice {
61 // ID of the message containing the choice name. 60 // ID of the message containing the choice name.
62 int description_id; 61 int description_id;
63 62
64 // Command line switch and value to enabled for this choice. 63 // Command line switch and value to enabled for this choice.
65 const char* command_line_switch; 64 const char* command_line_switch;
66 // Simple switches that have no value should use "" for command_line_value. 65 // Simple switches that have no value should use "" for command_line_value.
67 const char* command_line_value; 66 const char* command_line_value;
68 }; 67 };
69 68
70 // The internal name of the experiment. This is never shown to the user. 69 // The internal name of the feature entry. This is never shown to the user.
71 // It _is_ however stored in the prefs file, so you shouldn't change the 70 // It _is_ however stored in the prefs file, so you shouldn't change the
72 // name of existing flags. 71 // name of existing flags.
73 const char* internal_name; 72 const char* internal_name;
74 73
75 // String id of the message containing the experiment's name. 74 // String id of the message containing the feature's name.
76 int visible_name_id; 75 int visible_name_id;
77 76
78 // String id of the message containing the experiment's description. 77 // String id of the message containing the feature's description.
79 int visible_description_id; 78 int visible_description_id;
80 79
81 // The platforms the experiment is available on 80 // The platforms the feature is available on.
82 // Needs to be more than a compile-time #ifdef because of profile sync. 81 // Needs to be more than a compile-time #ifdef because of profile sync.
83 unsigned supported_platforms; // bitmask 82 unsigned supported_platforms; // bitmask
84 83
85 // Type of experiment. 84 // Type of entry.
86 Type type; 85 Type type;
87 86
88 // The commandline switch and value that are added when this flag is active. 87 // The commandline switch and value that are added when this flag is active.
89 // This is different from |internal_name| so that the commandline flag can be 88 // This is different from |internal_name| so that the commandline flag can be
90 // renamed without breaking the prefs file. 89 // renamed without breaking the prefs file.
91 // This is used if type is SINGLE_VALUE or ENABLE_DISABLE_VALUE. 90 // This is used if type is SINGLE_VALUE or ENABLE_DISABLE_VALUE.
92 const char* command_line_switch; 91 const char* command_line_switch;
93 // Simple switches that have no value should use "" for command_line_value. 92 // Simple switches that have no value should use "" for command_line_value.
94 const char* command_line_value; 93 const char* command_line_value;
95 94
(...skipping 13 matching lines...) Expand all
109 std::string NameForChoice(int index) const; 108 std::string NameForChoice(int index) const;
110 109
111 // Returns the human readable description for the choice at |index|. 110 // Returns the human readable description for the choice at |index|.
112 base::string16 DescriptionForChoice(int index) const; 111 base::string16 DescriptionForChoice(int index) const;
113 }; 112 };
114 113
115 // A flag controlling the behavior of the |ConvertFlagsToSwitches| function - 114 // A flag controlling the behavior of the |ConvertFlagsToSwitches| function -
116 // whether it should add the sentinel switches around flags. 115 // whether it should add the sentinel switches around flags.
117 enum SentinelsMode { kNoSentinels, kAddSentinels }; 116 enum SentinelsMode { kNoSentinels, kAddSentinels };
118 117
119 // Reads the Labs |prefs| (called "Labs" for historical reasons) and adds the 118 // Reads the state from |flags_storage| and adds the command line flags
120 // commandline flags belonging to the active experiments to |command_line|. 119 // belonging to the active feature entries to |command_line|.
121 void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage, 120 void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage,
122 base::CommandLine* command_line, 121 base::CommandLine* command_line,
123 SentinelsMode sentinels); 122 SentinelsMode sentinels);
124 123
125 // Compares a set of switches of the two provided command line objects and 124 // Compares a set of switches of the two provided command line objects and
126 // returns true if they are the same and false otherwise. 125 // returns true if they are the same and false otherwise.
127 // If |out_difference| is not NULL, it's filled with set_symmetric_difference 126 // If |out_difference| is not NULL, it's filled with set_symmetric_difference
128 // between sets. 127 // between sets.
129 bool AreSwitchesIdenticalToCurrentCommandLine( 128 bool AreSwitchesIdenticalToCurrentCommandLine(
130 const base::CommandLine& new_cmdline, 129 const base::CommandLine& new_cmdline,
131 const base::CommandLine& active_cmdline, 130 const base::CommandLine& active_cmdline,
132 std::set<base::CommandLine::StringType>* out_difference); 131 std::set<base::CommandLine::StringType>* out_difference);
133 132
134 // Differentiate between generic flags available on a per session base and flags 133 // Differentiate between generic flags available on a per session base and flags
135 // that influence the whole machine and can be said by the admin only. This flag 134 // that influence the whole machine and can be said by the admin only. This flag
136 // is relevant for ChromeOS for now only and dictates whether entries marked 135 // is relevant for ChromeOS for now only and dictates whether entries marked
137 // with the |kOsCrOSOwnerOnly| label should be enabled in the UI or not. 136 // with the |kOsCrOSOwnerOnly| label should be enabled in the UI or not.
138 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags }; 137 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags };
139 138
140 // Get the list of experiments. Experiments that are available on the current 139 // Gets the list of feature entries. Entries that are available for the current
141 // platform are appended to |supported_experiments|; all other experiments are 140 // platform are appended to |supported_entries|; all other entries are appended
142 // appended to |unsupported_experiments|. 141 // to |unsupported_entries|.
143 void GetFlagsExperimentsData(flags_ui::FlagsStorage* flags_storage, 142 void GetFlagFeatureEntries(flags_ui::FlagsStorage* flags_storage,
144 FlagAccess access, 143 FlagAccess access,
145 base::ListValue* supported_experiments, 144 base::ListValue* supported_entries,
146 base::ListValue* unsupported_experiments); 145 base::ListValue* unsupported_entries);
147 146
148 // Returns true if one of the experiment flags has been flipped since startup. 147 // Returns true if one of the feature entry flags has been flipped since
148 // startup.
149 bool IsRestartNeededToCommitChanges(); 149 bool IsRestartNeededToCommitChanges();
150 150
151 // Enables or disables the experiment with id |internal_name|. 151 // Enables or disables the current with id |internal_name|.
152 void SetExperimentEnabled(flags_ui::FlagsStorage* flags_storage, 152 void SetFeatureEntryEnabled(flags_ui::FlagsStorage* flags_storage,
153 const std::string& internal_name, 153 const std::string& internal_name,
154 bool enable); 154 bool enable);
155 155
156 // Removes all switches that were added to a command line by a previous call to 156 // Removes all switches that were added to a command line by a previous call to
157 // |ConvertFlagsToSwitches()|. 157 // |ConvertFlagsToSwitches()|.
158 void RemoveFlagsSwitches( 158 void RemoveFlagsSwitches(
159 std::map<std::string, base::CommandLine::StringType>* switch_list); 159 std::map<std::string, base::CommandLine::StringType>* switch_list);
160 160
161 // Reset all flags to the default state by clearing all flags. 161 // Reset all flags to the default state by clearing all flags.
162 void ResetAllFlags(flags_ui::FlagsStorage* flags_storage); 162 void ResetAllFlags(flags_ui::FlagsStorage* flags_storage);
163 163
164 // Returns the value for the current platform. This is one of the values defined 164 // Returns the value for the current platform. This is one of the values defined
(...skipping 13 matching lines...) Expand all
178 // |command_line_difference| is the result of 178 // |command_line_difference| is the result of
179 // AreSwitchesIdenticalToCurrentCommandLine(). 179 // AreSwitchesIdenticalToCurrentCommandLine().
180 void ReportCustomFlags(const std::string& uma_histogram_hame, 180 void ReportCustomFlags(const std::string& uma_histogram_hame,
181 const std::set<std::string>& command_line_difference); 181 const std::set<std::string>& command_line_difference);
182 182
183 namespace testing { 183 namespace testing {
184 184
185 // Clears internal global state, for unit tests. 185 // Clears internal global state, for unit tests.
186 void ClearState(); 186 void ClearState();
187 187
188 // Sets the list of experiments. Pass in NULL to use the default set. This does 188 // Sets the list of feature entries. Pass in null to use the default set. This
189 // NOT take ownership of the supplied Experiments. 189 // does NOT take ownership of the supplied |entries|.
190 void SetExperiments(const Experiment* e, size_t count); 190 void SetFeatureEntries(const FeatureEntry* entries, size_t count);
191 191
192 // Returns the current set of experiments. 192 // Returns the current set of feature entries.
193 const Experiment* GetExperiments(size_t* count); 193 const FeatureEntry* GetFeatureEntries(size_t* count);
194 194
195 // Separator used for multi values. Multi values are represented in prefs as 195 // Separator used for multi values. Multi values are represented in prefs as
196 // name-of-experiment + kMultiSeparator + selected_index. 196 // name-of-experiment + kMultiSeparator + selected_index.
197 extern const char kMultiSeparator[]; 197 extern const char kMultiSeparator[];
198 198
199 // This value is reported as switch histogram ID if switch name has unknown 199 // This value is reported as switch histogram ID if switch name has unknown
200 // format. 200 // format.
201 extern const base::HistogramBase::Sample kBadSwitchFormatHistogramId; 201 extern const base::HistogramBase::Sample kBadSwitchFormatHistogramId;
202 202
203 } // namespace testing 203 } // namespace testing
204 204
205 } // namespace about_flags 205 } // namespace about_flags
206 206
207 #endif // CHROME_BROWSER_ABOUT_FLAGS_H_ 207 #endif // CHROME_BROWSER_ABOUT_FLAGS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/about_flags.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698