| 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> |
| 9 |
| 8 #include <map> | 10 #include <map> |
| 11 #include <set> |
| 9 #include <string> | 12 #include <string> |
| 10 | 13 |
| 11 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 12 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 13 | 16 |
| 14 class PrefService; | 17 class PrefService; |
| 15 | 18 |
| 16 namespace base { | 19 namespace base { |
| 17 class ListValue; | 20 class ListValue; |
| 18 } | 21 } |
| 19 | 22 |
| 20 namespace about_flags { | 23 namespace about_flags { |
| 21 | 24 |
| 22 class FlagsStorage; | 25 class FlagsStorage; |
| 23 | 26 |
| 27 // This value is reported as switch histogram ID if switch name has unknown |
| 28 // format. |
| 29 extern const uint32_t kBadSwitchFormatHistogramId; |
| 30 |
| 24 // Enumeration of OSs. | 31 // Enumeration of OSs. |
| 25 // This is exposed only for testing. | 32 // This is exposed only for testing. |
| 26 enum { kOsMac = 1 << 0, kOsWin = 1 << 1, kOsLinux = 1 << 2 , kOsCrOS = 1 << 3, | 33 enum { kOsMac = 1 << 0, kOsWin = 1 << 1, kOsLinux = 1 << 2 , kOsCrOS = 1 << 3, |
| 27 kOsAndroid = 1 << 4, kOsCrOSOwnerOnly = 1 << 5 }; | 34 kOsAndroid = 1 << 4, kOsCrOSOwnerOnly = 1 << 5 }; |
| 28 | 35 |
| 29 // Experiment is used internally by about_flags to describe an experiment (and | 36 // Experiment is used internally by about_flags to describe an experiment (and |
| 30 // for testing). | 37 // for testing). |
| 31 // This is exposed only for testing. | 38 // This is exposed only for testing. |
| 32 struct Experiment { | 39 struct Experiment { |
| 33 enum Type { | 40 enum Type { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 enum SentinelsMode { kNoSentinels, kAddSentinels }; | 117 enum SentinelsMode { kNoSentinels, kAddSentinels }; |
| 111 | 118 |
| 112 // Reads the Labs |prefs| (called "Labs" for historical reasons) and adds the | 119 // Reads the Labs |prefs| (called "Labs" for historical reasons) and adds the |
| 113 // commandline flags belonging to the active experiments to |command_line|. | 120 // commandline flags belonging to the active experiments to |command_line|. |
| 114 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, | 121 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, |
| 115 base::CommandLine* command_line, | 122 base::CommandLine* command_line, |
| 116 SentinelsMode sentinels); | 123 SentinelsMode sentinels); |
| 117 | 124 |
| 118 // Compares a set of switches of the two provided command line objects and | 125 // Compares a set of switches of the two provided command line objects and |
| 119 // returns true if they are the same and false otherwise. | 126 // returns true if they are the same and false otherwise. |
| 127 // If |out_difference| is not NULL, it's filled with set_symmetric_difference |
| 128 // between sets. |
| 120 bool AreSwitchesIdenticalToCurrentCommandLine( | 129 bool AreSwitchesIdenticalToCurrentCommandLine( |
| 121 const base::CommandLine& new_cmdline, | 130 const base::CommandLine& new_cmdline, |
| 122 const base::CommandLine& active_cmdline); | 131 const base::CommandLine& active_cmdline, |
| 132 std::set<CommandLine::StringType>* out_difference); |
| 123 | 133 |
| 124 // Differentiate between generic flags available on a per session base and flags | 134 // 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 | 135 // 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 | 136 // 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. | 137 // with the |kOsCrOSOwnerOnly| label should be enabled in the UI or not. |
| 128 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags }; | 138 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags }; |
| 129 | 139 |
| 130 // Get the list of experiments. Experiments that are available on the current | 140 // Get the list of experiments. Experiments that are available on the current |
| 131 // platform are appended to |supported_experiments|; all other experiments are | 141 // platform are appended to |supported_experiments|; all other experiments are |
| 132 // appended to |unsupported_experiments|. | 142 // appended to |unsupported_experiments|. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 153 | 163 |
| 154 // 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 |
| 155 // by the OS enum above. | 165 // by the OS enum above. |
| 156 // This is exposed only for testing. | 166 // This is exposed only for testing. |
| 157 int GetCurrentPlatform(); | 167 int GetCurrentPlatform(); |
| 158 | 168 |
| 159 // Sends UMA stats about experimental flag usage. This should be called once per | 169 // Sends UMA stats about experimental flag usage. This should be called once per |
| 160 // startup. | 170 // startup. |
| 161 void RecordUMAStatistics(FlagsStorage* flags_storage); | 171 void RecordUMAStatistics(FlagsStorage* flags_storage); |
| 162 | 172 |
| 173 // Returns the UMA id for the specified switch name. |
| 174 uint32_t GetSwitchUMAId(const std::string& switch_name); |
| 175 |
| 176 // Sends stats (as UMA histogram) about command_line_difference. |
| 177 // This is used on ChromeOS to report flags that lead to browser restart. |
| 178 // |command_line_difference| is the result of |
| 179 // AreSwitchesIdenticalToCurrentCommandLine(). |
| 180 void ReportCustomFlags(const std::string& uma_histogram_hame, |
| 181 const std::set<std::string>& command_line_difference); |
| 182 |
| 163 namespace testing { | 183 namespace testing { |
| 164 | 184 |
| 165 // Clears internal global state, for unit tests. | 185 // Clears internal global state, for unit tests. |
| 166 void ClearState(); | 186 void ClearState(); |
| 167 | 187 |
| 168 // Sets the list of experiments. Pass in NULL to use the default set. This does | 188 // Sets the list of experiments. Pass in NULL to use the default set. This does |
| 169 // NOT take ownership of the supplied Experiments. | 189 // NOT take ownership of the supplied Experiments. |
| 170 void SetExperiments(const Experiment* e, size_t count); | 190 void SetExperiments(const Experiment* e, size_t count); |
| 171 | 191 |
| 172 // Returns the current set of experiments. | 192 // Returns the current set of experiments. |
| 173 const Experiment* GetExperiments(size_t* count); | 193 const Experiment* GetExperiments(size_t* count); |
| 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 |