OLD | NEW |
---|---|
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 <map> | 8 #include <map> |
9 #include <set> | |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "chrome/browser/about_flags_switches_histogram_ids.h" | |
13 | 15 |
14 class PrefService; | 16 class PrefService; |
15 | 17 |
16 namespace base { | 18 namespace base { |
17 class ListValue; | 19 class ListValue; |
18 } | 20 } |
19 | 21 |
20 namespace about_flags { | 22 namespace about_flags { |
21 | 23 |
22 class FlagsStorage; | 24 class FlagsStorage; |
(...skipping 28 matching lines...) Expand all Loading... | |
51 // Used for MULTI_VALUE types to describe one of the possible values the user | 53 // Used for MULTI_VALUE types to describe one of the possible values the user |
52 // can select. | 54 // can select. |
53 struct Choice { | 55 struct Choice { |
54 // ID of the message containing the choice name. | 56 // ID of the message containing the choice name. |
55 int description_id; | 57 int description_id; |
56 | 58 |
57 // Command line switch and value to enabled for this choice. | 59 // Command line switch and value to enabled for this choice. |
58 const char* command_line_switch; | 60 const char* command_line_switch; |
59 // Simple switches that have no value should use "" for command_line_value. | 61 // Simple switches that have no value should use "" for command_line_value. |
60 const char* command_line_value; | 62 const char* command_line_value; |
63 | |
64 // ID of command_line_switch in UMA histograms. | |
65 // On ChromeOS experiments lead to chrome process restart when user logs in. | |
66 // IDs of switches that lead to restart are reported. | |
67 // Must be zero for entries without command_line_switches. | |
68 const int command_line_switch_histogram_id; | |
61 }; | 69 }; |
62 | 70 |
63 // The internal name of the experiment. This is never shown to the user. | 71 // The internal name of the experiment. This is never shown to the user. |
64 // It _is_ however stored in the prefs file, so you shouldn't change the | 72 // It _is_ however stored in the prefs file, so you shouldn't change the |
65 // name of existing flags. | 73 // name of existing flags. |
66 const char* internal_name; | 74 const char* internal_name; |
67 | 75 |
68 // String id of the message containing the experiment's name. | 76 // String id of the message containing the experiment's name. |
69 int visible_name_id; | 77 int visible_name_id; |
70 | 78 |
71 // String id of the message containing the experiment's description. | 79 // String id of the message containing the experiment's description. |
72 int visible_description_id; | 80 int visible_description_id; |
73 | 81 |
74 // The platforms the experiment is available on | 82 // The platforms the experiment is available on |
75 // Needs to be more than a compile-time #ifdef because of profile sync. | 83 // Needs to be more than a compile-time #ifdef because of profile sync. |
76 unsigned supported_platforms; // bitmask | 84 unsigned supported_platforms; // bitmask |
77 | 85 |
78 // Type of experiment. | 86 // Type of experiment. |
79 Type type; | 87 Type type; |
80 | 88 |
81 // The commandline switch and value that are added when this flag is active. | 89 // The commandline switch and value that are added when this flag is active. |
82 // This is different from |internal_name| so that the commandline flag can be | 90 // This is different from |internal_name| so that the commandline flag can be |
83 // renamed without breaking the prefs file. | 91 // renamed without breaking the prefs file. |
84 // This is used if type is SINGLE_VALUE or ENABLE_DISABLE_VALUE. | 92 // This is used if type is SINGLE_VALUE or ENABLE_DISABLE_VALUE. |
85 const char* command_line_switch; | 93 const char* command_line_switch; |
86 // Simple switches that have no value should use "" for command_line_value. | 94 // Simple switches that have no value should use "" for command_line_value. |
87 const char* command_line_value; | 95 const char* command_line_value; |
96 // ID of command_line_switch in UMA histograms. | |
97 // (See Choice::command_line_switch_histogram_id.) | |
98 // Must be zero for entries without command_line_switches. | |
99 const int command_line_switch_histogram_id; | |
88 | 100 |
89 // For ENABLE_DISABLE_VALUE, the command line switch and value to explictly | 101 // For ENABLE_DISABLE_VALUE, the command line switch and value to explictly |
90 // disable the feature. | 102 // disable the feature. |
91 const char* disable_command_line_switch; | 103 const char* disable_command_line_switch; |
92 const char* disable_command_line_value; | 104 const char* disable_command_line_value; |
105 const int disable_command_line_switch_histogram_id; | |
93 | 106 |
94 // This is used if type is MULTI_VALUE. | 107 // This is used if type is MULTI_VALUE. |
95 const Choice* choices; | 108 const Choice* choices; |
96 | 109 |
97 // Number of |choices|. | 110 // Number of |choices|. |
98 // This is used if type is MULTI_VALUE. | 111 // This is used if type is MULTI_VALUE. |
99 int num_choices; | 112 int num_choices; |
100 | 113 |
101 // Returns the name used in prefs for the choice at the specified |index|. | 114 // Returns the name used in prefs for the choice at the specified |index|. |
102 std::string NameForChoice(int index) const; | 115 std::string NameForChoice(int index) const; |
103 | 116 |
104 // Returns the human readable description for the choice at |index|. | 117 // Returns the human readable description for the choice at |index|. |
105 base::string16 DescriptionForChoice(int index) const; | 118 base::string16 DescriptionForChoice(int index) const; |
106 }; | 119 }; |
107 | 120 |
108 // A flag controlling the behavior of the |ConvertFlagsToSwitches| function - | 121 // A flag controlling the behavior of the |ConvertFlagsToSwitches| function - |
109 // whether it should add the sentinel switches around flags. | 122 // whether it should add the sentinel switches around flags. |
110 enum SentinelsMode { kNoSentinels, kAddSentinels }; | 123 enum SentinelsMode { kNoSentinels, kAddSentinels }; |
111 | 124 |
112 // Reads the Labs |prefs| (called "Labs" for historical reasons) and adds the | 125 // Reads the Labs |prefs| (called "Labs" for historical reasons) and adds the |
113 // commandline flags belonging to the active experiments to |command_line|. | 126 // commandline flags belonging to the active experiments to |command_line|. |
114 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, | 127 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, |
115 base::CommandLine* command_line, | 128 base::CommandLine* command_line, |
116 SentinelsMode sentinels); | 129 SentinelsMode sentinels); |
117 | 130 |
131 // Returns a map <command_line_switch, switch_histogram_id>. | |
132 // Map is created if it doesn't exist. | |
133 const std::map<std::string, int>& GetSwitchesHistogramIds(); | |
Lei Zhang
2014/06/27 19:46:44
Having "typedef std::map<std::string, int> Switche
Alexander Alekseev
2014/06/30 15:06:01
Done.
| |
134 | |
118 // Compares a set of switches of the two provided command line objects and | 135 // Compares a set of switches of the two provided command line objects and |
119 // returns true if they are the same and false otherwise. | 136 // returns true if they are the same and false otherwise. |
137 // If |out_difference| is not NULL, it's filled with set_symmetric_difference | |
138 // between sets. | |
120 bool AreSwitchesIdenticalToCurrentCommandLine( | 139 bool AreSwitchesIdenticalToCurrentCommandLine( |
121 const base::CommandLine& new_cmdline, | 140 const base::CommandLine& new_cmdline, |
122 const base::CommandLine& active_cmdline); | 141 const base::CommandLine& active_cmdline, |
142 std::set<CommandLine::StringType>* out_difference); | |
123 | 143 |
124 // Differentiate between generic flags available on a per session base and flags | 144 // Differentiate between generic flags available on a per session base and flags |
125 // that influence the whole machine and can be said by the admin only. This flag | 145 // that influence the whole machine and can be said by the admin only. This flag |
126 // is relevant for ChromeOS for now only and dictates whether entries marked | 146 // is relevant for ChromeOS for now only and dictates whether entries marked |
127 // with the |kOsCrOSOwnerOnly| label should be enabled in the UI or not. | 147 // with the |kOsCrOSOwnerOnly| label should be enabled in the UI or not. |
128 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags }; | 148 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags }; |
129 | 149 |
130 // Get the list of experiments. Experiments that are available on the current | 150 // Get the list of experiments. Experiments that are available on the current |
131 // platform are appended to |supported_experiments|; all other experiments are | 151 // platform are appended to |supported_experiments|; all other experiments are |
132 // appended to |unsupported_experiments|. | 152 // appended to |unsupported_experiments|. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 | 194 |
175 // 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 |
176 // name-of-experiment + kMultiSeparator + selected_index. | 196 // name-of-experiment + kMultiSeparator + selected_index. |
177 extern const char kMultiSeparator[]; | 197 extern const char kMultiSeparator[]; |
178 | 198 |
179 } // namespace testing | 199 } // namespace testing |
180 | 200 |
181 } // namespace about_flags | 201 } // namespace about_flags |
182 | 202 |
183 #endif // CHROME_BROWSER_ABOUT_FLAGS_H_ | 203 #endif // CHROME_BROWSER_ABOUT_FLAGS_H_ |
OLD | NEW |