Chromium Code Reviews| 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> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 | 43 |
| 44 // Differentiate between generic flags available on a per session base and flags | 44 // Differentiate between generic flags available on a per session base and flags |
| 45 // that influence the whole machine and can be said by the admin only. This flag | 45 // that influence the whole machine and can be said by the admin only. This flag |
| 46 // is relevant for ChromeOS for now only and dictates whether entries marked | 46 // is relevant for ChromeOS for now only and dictates whether entries marked |
| 47 // with the |kOsCrOSOwnerOnly| label should be enabled in the UI or not. | 47 // with the |kOsCrOSOwnerOnly| label should be enabled in the UI or not. |
| 48 // On iOS, |kAppleReviewAccessToFlags| indicates that the flags shown should | 48 // On iOS, |kAppleReviewAccessToFlags| indicates that the flags shown should |
| 49 // be the ones marked for Apple review (which otherwise will not be shown). | 49 // be the ones marked for Apple review (which otherwise will not be shown). |
| 50 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags, | 50 enum FlagAccess { kGeneralAccessFlagsOnly, kOwnerAccessToFlags, |
| 51 kAppleReviewAccessToFlags }; | 51 kAppleReviewAccessToFlags }; |
| 52 | 52 |
| 53 // The trial group selected when feature variation parameters are registered via | |
| 54 // FlagsState::RegisterFeatureVariationParameters(). | |
| 55 const char kTrialGroupAboutFlags[] = "AboutFlags"; | |
|
Alexei Svitkine (slow)
2016/06/10 15:46:49
Please put this in an "internal" namespace, since
jkrcal
2016/06/14 10:04:22
Done.
| |
| 56 | |
| 53 // Stores and encapsulates the little state that about:flags has. | 57 // Stores and encapsulates the little state that about:flags has. |
| 54 class FlagsState { | 58 class FlagsState { |
| 55 public: | 59 public: |
| 56 FlagsState(const FeatureEntry* feature_entries, size_t num_feature_entries); | 60 FlagsState(const FeatureEntry* feature_entries, size_t num_feature_entries); |
| 57 ~FlagsState(); | 61 ~FlagsState(); |
| 58 | 62 |
| 63 // Reads the state from |flags_storage| and adds the command line flags | |
| 64 // belonging to the active feature entries to |command_line|. Features are | |
| 65 // appended via | |
|
Alexei Svitkine (slow)
2016/06/10 15:46:49
Nit: wrapping is off.
jkrcal
2016/06/14 10:04:22
Done.
| |
| 66 // |enable_features_flag_name| and |disable_features_flag_name|. | |
| 59 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, | 67 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, |
| 60 base::CommandLine* command_line, | 68 base::CommandLine* command_line, |
| 61 SentinelsMode sentinels, | 69 SentinelsMode sentinels, |
| 62 const char* enable_features_flag_name, | 70 const char* enable_features_flag_name, |
| 63 const char* disable_features_flag_name); | 71 const char* disable_features_flag_name); |
| 64 bool IsRestartNeededToCommitChanges(); | 72 bool IsRestartNeededToCommitChanges(); |
| 65 void SetFeatureEntryEnabled(FlagsStorage* flags_storage, | 73 void SetFeatureEntryEnabled(FlagsStorage* flags_storage, |
| 66 const std::string& internal_name, | 74 const std::string& internal_name, |
| 67 bool enable); | 75 bool enable); |
| 68 void RemoveFlagsSwitches( | 76 void RemoveFlagsSwitches( |
| 69 std::map<std::string, base::CommandLine::StringType>* switch_list); | 77 std::map<std::string, base::CommandLine::StringType>* switch_list); |
| 70 void ResetAllFlags(FlagsStorage* flags_storage); | 78 void ResetAllFlags(FlagsStorage* flags_storage); |
| 71 void Reset(); | 79 void Reset(); |
| 72 | 80 |
| 81 // Registers variations parameter values stored in |flags_storage| (previously | |
| 82 // selected in about:flags). | |
| 83 void RegisterAllFeatureVariationParameters(FlagsStorage* flags_storage); | |
| 84 | |
| 73 // Gets the list of feature entries. Entries that are available for the | 85 // Gets the list of feature entries. Entries that are available for the |
| 74 // current platform are appended to |supported_entries|; all other entries are | 86 // current platform are appended to |supported_entries|; all other entries are |
| 75 // appended to |unsupported_entries|. | 87 // appended to |unsupported_entries|. |
| 76 void GetFlagFeatureEntries( | 88 void GetFlagFeatureEntries( |
| 77 FlagsStorage* flags_storage, | 89 FlagsStorage* flags_storage, |
| 78 FlagAccess access, | 90 FlagAccess access, |
| 79 base::ListValue* supported_entries, | 91 base::ListValue* supported_entries, |
| 80 base::ListValue* unsupported_entries, | 92 base::ListValue* unsupported_entries, |
| 81 base::Callback<bool(const FeatureEntry&)> skip_feature_entry); | 93 base::Callback<bool(const FeatureEntry&)> skip_feature_entry); |
| 82 | 94 |
| (...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 | 170 // Map from switch name to a set of string, that keeps track which strings |
| 159 // were appended to existing (list value) switches. | 171 // were appended to existing (list value) switches. |
| 160 std::map<std::string, std::set<std::string>> appended_switches_; | 172 std::map<std::string, std::set<std::string>> appended_switches_; |
| 161 | 173 |
| 162 DISALLOW_COPY_AND_ASSIGN(FlagsState); | 174 DISALLOW_COPY_AND_ASSIGN(FlagsState); |
| 163 }; | 175 }; |
| 164 | 176 |
| 165 } // namespace flags_ui | 177 } // namespace flags_ui |
| 166 | 178 |
| 167 #endif // COMPONENTS_FLAGS_UI_FLAGS_STATE_H_ | 179 #endif // COMPONENTS_FLAGS_UI_FLAGS_STATE_H_ |
| OLD | NEW |