| 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 <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 about_flags { | 24 namespace about_flags { |
| 25 | 25 |
| 26 class FlagsStorage; | 26 class FlagsStorage; |
| 27 | 27 |
| 28 // Experiment is used internally by about_flags to describe an experiment (and | 28 // Entry is used internally by about_flags to describe an experiment (and |
| 29 // for testing). | 29 // for testing). |
| 30 // This is exposed only for testing. | 30 // This is exposed only for testing. |
| 31 struct Experiment { | 31 struct Entry { |
| 32 enum Type { | 32 enum Type { |
| 33 // An experiment with a single value. This is typically what you want. | 33 // An experiment with a single value. This is typically what you want. |
| 34 SINGLE_VALUE, | 34 SINGLE_VALUE, |
| 35 | 35 |
| 36 // The experiment has multiple values only one of which is ever enabled. | 36 // The experiment has multiple values only one of which is ever enabled. |
| 37 // The first of the values should correspond to a deactivated state for this | 37 // The first of the values should correspond to a deactivated state for this |
| 38 // lab (i.e. no command line option). For MULTI_VALUE experiments the | 38 // lab (i.e. no command line option). For MULTI_VALUE experiments the |
| 39 // command_line of the Experiment is not used. If the experiment is enabled | 39 // command_line of the Experiment is not used. If the experiment is enabled |
| 40 // the command line of the selected Choice is enabled. | 40 // the command line of the selected Choice is enabled. |
| 41 MULTI_VALUE, | 41 MULTI_VALUE, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 const base::CommandLine& new_cmdline, | 122 const base::CommandLine& new_cmdline, |
| 123 const base::CommandLine& active_cmdline, | 123 const base::CommandLine& active_cmdline, |
| 124 std::set<base::CommandLine::StringType>* out_difference); | 124 std::set<base::CommandLine::StringType>* out_difference); |
| 125 | 125 |
| 126 // Differentiate between generic flags available on a per session base and flags | 126 // Differentiate between generic flags available on a per session base and flags |
| 127 // that influence the whole machine and can be said by the admin only. This flag | 127 // that influence the whole machine and can be said by the admin only. This flag |
| 128 // is relevant for ChromeOS for now only and dictates whether entries marked | 128 // is relevant for ChromeOS for now only and dictates whether entries marked |
| 129 // with the |kOsCrOSOwnerOnly| label should be enabled in the UI or not. | 129 // with the |kOsCrOSOwnerOnly| label should be enabled in the UI or not. |
| 130 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags }; | 130 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags }; |
| 131 | 131 |
| 132 // Get the list of experiments. Experiments that are available on the current | 132 // Get the list of entries. Entries that are available on the current platform |
| 133 // platform are appended to |supported_experiments|; all other experiments are | 133 // are appended to |supported_entries|; all other entries are appended to |
| 134 // appended to |unsupported_experiments|. | 134 // |unsupported_entries|. |
| 135 void GetFlagsExperimentsData(FlagsStorage* flags_storage, | 135 void GetFlagsEntryData(FlagsStorage* flags_storage, |
| 136 FlagAccess access, | 136 FlagAccess access, |
| 137 base::ListValue* supported_experiments, | 137 base::ListValue* supported_entries, |
| 138 base::ListValue* unsupported_experiments); | 138 base::ListValue* unsupported_entries); |
| 139 | 139 |
| 140 // Returns true if one of the experiment flags has been flipped since startup. | 140 // Returns true if one of the experiment flags has been flipped since startup. |
| 141 bool IsRestartNeededToCommitChanges(); | 141 bool IsRestartNeededToCommitChanges(); |
| 142 | 142 |
| 143 // Enables or disables the experiment with id |internal_name|. | 143 // Enables or disables the experiment with id |internal_name|. |
| 144 void SetExperimentEnabled(FlagsStorage* flags_storage, | 144 void SetEntryEnabled(FlagsStorage* flags_storage, |
| 145 const std::string& internal_name, | 145 const std::string& internal_name, |
| 146 bool enable); | 146 bool enable); |
| 147 | 147 |
| 148 // Removes all switches that were added to a command line by a previous call to | 148 // Removes all switches that were added to a command line by a previous call to |
| 149 // |ConvertFlagsToSwitches()|. | 149 // |ConvertFlagsToSwitches()|. |
| 150 void RemoveFlagsSwitches( | 150 void RemoveFlagsSwitches( |
| 151 std::map<std::string, base::CommandLine::StringType>* switch_list); | 151 std::map<std::string, base::CommandLine::StringType>* switch_list); |
| 152 | 152 |
| 153 // Reset all flags to the default state by clearing all flags. | 153 // Reset all flags to the default state by clearing all flags. |
| 154 void ResetAllFlags(FlagsStorage* flags_storage); | 154 void ResetAllFlags(FlagsStorage* flags_storage); |
| 155 | 155 |
| 156 // Returns the value for the current platform. This is one of the values defined | 156 // Returns the value for the current platform. This is one of the values defined |
| (...skipping 13 matching lines...) Expand all Loading... |
| 170 // |command_line_difference| is the result of | 170 // |command_line_difference| is the result of |
| 171 // AreSwitchesIdenticalToCurrentCommandLine(). | 171 // AreSwitchesIdenticalToCurrentCommandLine(). |
| 172 void ReportCustomFlags(const std::string& uma_histogram_hame, | 172 void ReportCustomFlags(const std::string& uma_histogram_hame, |
| 173 const std::set<std::string>& command_line_difference); | 173 const std::set<std::string>& command_line_difference); |
| 174 | 174 |
| 175 namespace testing { | 175 namespace testing { |
| 176 | 176 |
| 177 // Clears internal global state, for unit tests. | 177 // Clears internal global state, for unit tests. |
| 178 void ClearState(); | 178 void ClearState(); |
| 179 | 179 |
| 180 // Sets the list of experiments. Pass in NULL to use the default set. This does | 180 // Sets the list of entries. Pass in NULL to use the default set. This does |
| 181 // NOT take ownership of the supplied Experiments. | 181 // NOT take ownership of the supplied Entries. |
| 182 void SetExperiments(const Experiment* e, size_t count); | 182 void SetEntries(const Entry* e, size_t count); |
| 183 | 183 |
| 184 // Returns the current set of experiments. | 184 // Returns the current set of entries. |
| 185 const Experiment* GetExperiments(size_t* count); | 185 const Entry* GetEntries(size_t* count); |
| 186 | 186 |
| 187 // Separator used for multi values. Multi values are represented in prefs as | 187 // Separator used for multi values. Multi values are represented in prefs as |
| 188 // name-of-experiment + kMultiSeparator + selected_index. | 188 // name-of-experiment + kMultiSeparator + selected_index. |
| 189 extern const char kMultiSeparator[]; | 189 extern const char kMultiSeparator[]; |
| 190 | 190 |
| 191 // This value is reported as switch histogram ID if switch name has unknown | 191 // This value is reported as switch histogram ID if switch name has unknown |
| 192 // format. | 192 // format. |
| 193 extern const base::HistogramBase::Sample kBadSwitchFormatHistogramId; | 193 extern const base::HistogramBase::Sample kBadSwitchFormatHistogramId; |
| 194 | 194 |
| 195 } // namespace testing | 195 } // namespace testing |
| 196 | 196 |
| 197 } // namespace about_flags | 197 } // namespace about_flags |
| 198 | 198 |
| 199 #endif // CHROME_BROWSER_ABOUT_FLAGS_H_ | 199 #endif // CHROME_BROWSER_ABOUT_FLAGS_H_ |
| OLD | NEW |