| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_FLAGS_UI_FLAGS_STATE_H_ | 5 #ifndef COMPONENTS_FLAGS_UI_FLAGS_STATE_H_ |
| 6 #define COMPONENTS_FLAGS_UI_FLAGS_STATE_H_ | 6 #define COMPONENTS_FLAGS_UI_FLAGS_STATE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.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/callback_forward.h" | 14 #include "base/callback_forward.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class ListValue; | 19 class ListValue; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace flags_ui { | 22 namespace flags_ui { |
| 23 | 23 |
| 24 // Internal functionality exposed for tests. |
| 25 namespace internal { |
| 26 // The trial group selected when feature variation parameters are registered via |
| 27 // FlagsState::RegisterFeatureVariationParameters(). |
| 28 extern const char kTrialGroupAboutFlags[]; |
| 29 } // namespace internal |
| 30 |
| 24 struct FeatureEntry; | 31 struct FeatureEntry; |
| 25 class FlagsStorage; | 32 class FlagsStorage; |
| 26 struct SwitchEntry; | 33 struct SwitchEntry; |
| 27 | 34 |
| 28 // Enumeration of OSs. | 35 // Enumeration of OSs. |
| 29 enum { | 36 enum { |
| 30 kOsMac = 1 << 0, | 37 kOsMac = 1 << 0, |
| 31 kOsWin = 1 << 1, | 38 kOsWin = 1 << 1, |
| 32 kOsLinux = 1 << 2, | 39 kOsLinux = 1 << 2, |
| 33 kOsCrOS = 1 << 3, | 40 kOsCrOS = 1 << 3, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 49 // be the ones marked for Apple review (which otherwise will not be shown). | 56 // be the ones marked for Apple review (which otherwise will not be shown). |
| 50 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags, | 57 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags, |
| 51 kAppleReviewAccessToFlags }; | 58 kAppleReviewAccessToFlags }; |
| 52 | 59 |
| 53 // Stores and encapsulates the little state that about:flags has. | 60 // Stores and encapsulates the little state that about:flags has. |
| 54 class FlagsState { | 61 class FlagsState { |
| 55 public: | 62 public: |
| 56 FlagsState(const FeatureEntry* feature_entries, size_t num_feature_entries); | 63 FlagsState(const FeatureEntry* feature_entries, size_t num_feature_entries); |
| 57 ~FlagsState(); | 64 ~FlagsState(); |
| 58 | 65 |
| 66 // Reads the state from |flags_storage| and adds the command line flags |
| 67 // belonging to the active feature entries to |command_line|. Features are |
| 68 // appended via |enable_features_flag_name| and |disable_features_flag_name|. |
| 59 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, | 69 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, |
| 60 base::CommandLine* command_line, | 70 base::CommandLine* command_line, |
| 61 SentinelsMode sentinels, | 71 SentinelsMode sentinels, |
| 62 const char* enable_features_flag_name, | 72 const char* enable_features_flag_name, |
| 63 const char* disable_features_flag_name); | 73 const char* disable_features_flag_name); |
| 64 bool IsRestartNeededToCommitChanges(); | 74 bool IsRestartNeededToCommitChanges(); |
| 65 void SetFeatureEntryEnabled(FlagsStorage* flags_storage, | 75 void SetFeatureEntryEnabled(FlagsStorage* flags_storage, |
| 66 const std::string& internal_name, | 76 const std::string& internal_name, |
| 67 bool enable); | 77 bool enable); |
| 68 void RemoveFlagsSwitches( | 78 void RemoveFlagsSwitches( |
| 69 std::map<std::string, base::CommandLine::StringType>* switch_list); | 79 std::map<std::string, base::CommandLine::StringType>* switch_list); |
| 70 void ResetAllFlags(FlagsStorage* flags_storage); | 80 void ResetAllFlags(FlagsStorage* flags_storage); |
| 71 void Reset(); | 81 void Reset(); |
| 72 | 82 |
| 83 // Registers variations parameter values stored in |flags_storage| (previously |
| 84 // selected in about:flags). |
| 85 void RegisterAllFeatureVariationParameters(FlagsStorage* flags_storage); |
| 86 |
| 73 // Gets the list of feature entries. Entries that are available for the | 87 // Gets the list of feature entries. Entries that are available for the |
| 74 // current platform are appended to |supported_entries|; all other entries are | 88 // current platform are appended to |supported_entries|; all other entries are |
| 75 // appended to |unsupported_entries|. | 89 // appended to |unsupported_entries|. |
| 76 void GetFlagFeatureEntries( | 90 void GetFlagFeatureEntries( |
| 77 FlagsStorage* flags_storage, | 91 FlagsStorage* flags_storage, |
| 78 FlagAccess access, | 92 FlagAccess access, |
| 79 base::ListValue* supported_entries, | 93 base::ListValue* supported_entries, |
| 80 base::ListValue* unsupported_entries, | 94 base::ListValue* unsupported_entries, |
| 81 base::Callback<bool(const FeatureEntry&)> skip_feature_entry); | 95 base::Callback<bool(const FeatureEntry&)> skip_feature_entry); |
| 82 | 96 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // Map from switch name to a set of string, that keeps track which strings | 172 // Map from switch name to a set of string, that keeps track which strings |
| 159 // were appended to existing (list value) switches. | 173 // were appended to existing (list value) switches. |
| 160 std::map<std::string, std::set<std::string>> appended_switches_; | 174 std::map<std::string, std::set<std::string>> appended_switches_; |
| 161 | 175 |
| 162 DISALLOW_COPY_AND_ASSIGN(FlagsState); | 176 DISALLOW_COPY_AND_ASSIGN(FlagsState); |
| 163 }; | 177 }; |
| 164 | 178 |
| 165 } // namespace flags_ui | 179 } // namespace flags_ui |
| 166 | 180 |
| 167 #endif // COMPONENTS_FLAGS_UI_FLAGS_STATE_H_ | 181 #endif // COMPONENTS_FLAGS_UI_FLAGS_STATE_H_ |
| OLD | NEW |