| 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 <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 | 13 |
| 14 class PrefService; | 14 class PrefService; |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class ListValue; | 17 class ListValue; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace about_flags { | 20 namespace about_flags { |
| 21 | 21 |
| 22 // Enumeration of OSs. | 22 // Enumeration of OSs. |
| 23 // This is exposed only for testing. | 23 // This is exposed only for testing. |
| 24 enum { kOsMac = 1 << 0, kOsWin = 1 << 1, kOsLinux = 1 << 2 , kOsCrOS = 1 << 3, | 24 enum { kOsMac = 1 << 0, kOsWin = 1 << 1, kOsLinux = 1 << 2 , kOsCrOS = 1 << 3, |
| 25 kOsAndroid = 1 << 4 }; | 25 kOsAndroid = 1 << 4, kOsCrOSOwnerOnly = 1 << 5 }; |
| 26 | 26 |
| 27 // Experiment is used internally by about_flags to describe an experiment (and | 27 // Experiment is used internally by about_flags to describe an experiment (and |
| 28 // for testing). | 28 // for testing). |
| 29 // This is exposed only for testing. | 29 // This is exposed only for testing. |
| 30 struct Experiment { | 30 struct Experiment { |
| 31 enum Type { | 31 enum Type { |
| 32 // An experiment with a single value. This is typically what you want. | 32 // An experiment with a single value. This is typically what you want. |
| 33 SINGLE_VALUE, | 33 SINGLE_VALUE, |
| 34 | 34 |
| 35 // The experiment has multiple values only one of which is ever enabled. | 35 // The experiment has multiple values only one of which is ever enabled. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 std::string NameForChoice(int index) const; | 100 std::string NameForChoice(int index) const; |
| 101 | 101 |
| 102 // Returns the human readable description for the choice at |index|. | 102 // Returns the human readable description for the choice at |index|. |
| 103 string16 DescriptionForChoice(int index) const; | 103 string16 DescriptionForChoice(int index) const; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 // Reads the Labs |prefs| (called "Labs" for historical reasons) and adds the | 106 // Reads the Labs |prefs| (called "Labs" for historical reasons) and adds the |
| 107 // commandline flags belonging to the active experiments to |command_line|. | 107 // commandline flags belonging to the active experiments to |command_line|. |
| 108 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line); | 108 void ConvertFlagsToSwitches(PrefService* prefs, CommandLine* command_line); |
| 109 | 109 |
| 110 // Differentiate between generic flags available on a per session base and flags |
| 111 // that influence the whole machine and can be said by the admin only. This flag |
| 112 // is relevant for ChromeOS for now only and dictates whether entries marked |
| 113 // with the |kOsCrOSOwnerOnly| label should be enabled in the UI or not. |
| 114 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags }; |
| 115 |
| 110 // Get a list of all available experiments. The caller owns the result. | 116 // Get a list of all available experiments. The caller owns the result. |
| 111 base::ListValue* GetFlagsExperimentsData(PrefService* prefs); | 117 base::ListValue* GetFlagsExperimentsData(PrefService* prefs, FlagAccess access); |
| 112 | 118 |
| 113 // Returns true if one of the experiment flags has been flipped since startup. | 119 // Returns true if one of the experiment flags has been flipped since startup. |
| 114 bool IsRestartNeededToCommitChanges(); | 120 bool IsRestartNeededToCommitChanges(); |
| 115 | 121 |
| 116 // Enables or disables the experiment with id |internal_name|. | 122 // Enables or disables the experiment with id |internal_name|. |
| 117 void SetExperimentEnabled( | 123 void SetExperimentEnabled( |
| 118 PrefService* prefs, const std::string& internal_name, bool enable); | 124 PrefService* prefs, const std::string& internal_name, bool enable); |
| 119 | 125 |
| 120 // Removes all switches that were added to a command line by a previous call to | 126 // Removes all switches that were added to a command line by a previous call to |
| 121 // |ConvertFlagsToSwitches()|. | 127 // |ConvertFlagsToSwitches()|. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 148 | 154 |
| 149 // Separator used for multi values. Multi values are represented in prefs as | 155 // Separator used for multi values. Multi values are represented in prefs as |
| 150 // name-of-experiment + kMultiSeparator + selected_index. | 156 // name-of-experiment + kMultiSeparator + selected_index. |
| 151 extern const char kMultiSeparator[]; | 157 extern const char kMultiSeparator[]; |
| 152 | 158 |
| 153 } // namespace testing | 159 } // namespace testing |
| 154 | 160 |
| 155 } // namespace about_flags | 161 } // namespace about_flags |
| 156 | 162 |
| 157 #endif // CHROME_BROWSER_ABOUT_FLAGS_H_ | 163 #endif // CHROME_BROWSER_ABOUT_FLAGS_H_ |
| OLD | NEW |