| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 ~FlagsState(); | 66 ~FlagsState(); |
| 67 | 67 |
| 68 // Reads the state from |flags_storage| and adds the command line flags | 68 // Reads the state from |flags_storage| and adds the command line flags |
| 69 // belonging to the active feature entries to |command_line|. Features are | 69 // belonging to the active feature entries to |command_line|. Features are |
| 70 // appended via |enable_features_flag_name| and |disable_features_flag_name|. | 70 // appended via |enable_features_flag_name| and |disable_features_flag_name|. |
| 71 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, | 71 void ConvertFlagsToSwitches(FlagsStorage* flags_storage, |
| 72 base::CommandLine* command_line, | 72 base::CommandLine* command_line, |
| 73 SentinelsMode sentinels, | 73 SentinelsMode sentinels, |
| 74 const char* enable_features_flag_name, | 74 const char* enable_features_flag_name, |
| 75 const char* disable_features_flag_name); | 75 const char* disable_features_flag_name); |
| 76 |
| 77 // Reads the state from |flags_storage| and returns the set of command line |
| 78 // flags that correspond to enabled entries. Does not populate any information |
| 79 // about entries that enable/disable base::Feature states. |
| 80 std::set<std::string> GetSwitchesFromFlags(FlagsStorage* flags_storage); |
| 81 |
| 76 bool IsRestartNeededToCommitChanges(); | 82 bool IsRestartNeededToCommitChanges(); |
| 77 void SetFeatureEntryEnabled(FlagsStorage* flags_storage, | 83 void SetFeatureEntryEnabled(FlagsStorage* flags_storage, |
| 78 const std::string& internal_name, | 84 const std::string& internal_name, |
| 79 bool enable); | 85 bool enable); |
| 80 void RemoveFlagsSwitches( | 86 void RemoveFlagsSwitches( |
| 81 std::map<std::string, base::CommandLine::StringType>* switch_list); | 87 std::map<std::string, base::CommandLine::StringType>* switch_list); |
| 82 void ResetAllFlags(FlagsStorage* flags_storage); | 88 void ResetAllFlags(FlagsStorage* flags_storage); |
| 83 void Reset(); | 89 void Reset(); |
| 84 | 90 |
| 85 // Registers variations parameter values selected for features in about:flags. | 91 // Registers variations parameter values selected for features in about:flags. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 115 // compared. The embedder may use |extra_flag_sentinel_begin_flag_name| and | 121 // compared. The embedder may use |extra_flag_sentinel_begin_flag_name| and |
| 116 // |extra_sentinel_end_flag_name| to specify other delimiters, if supported. | 122 // |extra_sentinel_end_flag_name| to specify other delimiters, if supported. |
| 117 static bool AreSwitchesIdenticalToCurrentCommandLine( | 123 static bool AreSwitchesIdenticalToCurrentCommandLine( |
| 118 const base::CommandLine& new_cmdline, | 124 const base::CommandLine& new_cmdline, |
| 119 const base::CommandLine& active_cmdline, | 125 const base::CommandLine& active_cmdline, |
| 120 std::set<base::CommandLine::StringType>* out_difference, | 126 std::set<base::CommandLine::StringType>* out_difference, |
| 121 const char* extra_flag_sentinel_begin_flag_name, | 127 const char* extra_flag_sentinel_begin_flag_name, |
| 122 const char* extra_flag_sentinel_end_flag_name); | 128 const char* extra_flag_sentinel_end_flag_name); |
| 123 | 129 |
| 124 private: | 130 private: |
| 131 // Keeps track of affected switches for each FeatureEntry, based on which |
| 132 // choice is selected for it. |
| 133 struct SwitchEntry; |
| 134 |
| 125 // Adds mapping to |name_to_switch_map| to set the given switch name/value. | 135 // Adds mapping to |name_to_switch_map| to set the given switch name/value. |
| 126 void AddSwitchMapping(const std::string& key, | 136 void AddSwitchMapping(const std::string& key, |
| 127 const std::string& switch_name, | 137 const std::string& switch_name, |
| 128 const std::string& switch_value, | 138 const std::string& switch_value, |
| 129 std::map<std::string, SwitchEntry>* name_to_switch_map); | 139 std::map<std::string, SwitchEntry>* name_to_switch_map); |
| 130 | 140 |
| 131 // Adds mapping to |name_to_switch_map| to toggle base::Feature |feature_name| | 141 // Adds mapping to |name_to_switch_map| to toggle base::Feature |feature_name| |
| 132 // to state |feature_state|. | 142 // to state |feature_state|. |
| 133 void AddFeatureMapping( | 143 void AddFeatureMapping( |
| 134 const std::string& key, | 144 const std::string& key, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 164 | 174 |
| 165 void GetSanitizedEnabledFlags(FlagsStorage* flags_storage, | 175 void GetSanitizedEnabledFlags(FlagsStorage* flags_storage, |
| 166 std::set<std::string>* result); | 176 std::set<std::string>* result); |
| 167 | 177 |
| 168 // Variant of GetSanitizedEnabledFlags that also removes any flags that aren't | 178 // Variant of GetSanitizedEnabledFlags that also removes any flags that aren't |
| 169 // enabled on the current platform. | 179 // enabled on the current platform. |
| 170 void GetSanitizedEnabledFlagsForCurrentPlatform( | 180 void GetSanitizedEnabledFlagsForCurrentPlatform( |
| 171 FlagsStorage* flags_storage, | 181 FlagsStorage* flags_storage, |
| 172 std::set<std::string>* result); | 182 std::set<std::string>* result); |
| 173 | 183 |
| 184 // Generates a flags to switches mapping based on the set of enabled flags |
| 185 // from |flags_storage|. On output, |enabled_entries| will contain the |
| 186 // internal names of enabled flags and |name_to_switch_map| will contain |
| 187 // information on how they map to command-line flags or features. |
| 188 void GenerateFlagsToSwitchesMapping( |
| 189 FlagsStorage* flags_storage, |
| 190 std::set<std::string>* enabled_entries, |
| 191 std::map<std::string, SwitchEntry>* name_to_switch_map); |
| 192 |
| 174 const FeatureEntry* feature_entries_; | 193 const FeatureEntry* feature_entries_; |
| 175 size_t num_feature_entries_; | 194 size_t num_feature_entries_; |
| 176 | 195 |
| 177 bool needs_restart_; | 196 bool needs_restart_; |
| 178 std::map<std::string, std::string> flags_switches_; | 197 std::map<std::string, std::string> flags_switches_; |
| 179 | 198 |
| 180 // Map from switch name to a set of string, that keeps track which strings | 199 // Map from switch name to a set of string, that keeps track which strings |
| 181 // were appended to existing (list value) switches. | 200 // were appended to existing (list value) switches. |
| 182 std::map<std::string, std::set<std::string>> appended_switches_; | 201 std::map<std::string, std::set<std::string>> appended_switches_; |
| 183 | 202 |
| 184 DISALLOW_COPY_AND_ASSIGN(FlagsState); | 203 DISALLOW_COPY_AND_ASSIGN(FlagsState); |
| 185 }; | 204 }; |
| 186 | 205 |
| 187 } // namespace flags_ui | 206 } // namespace flags_ui |
| 188 | 207 |
| 189 #endif // COMPONENTS_FLAGS_UI_FLAGS_STATE_H_ | 208 #endif // COMPONENTS_FLAGS_UI_FLAGS_STATE_H_ |
| OLD | NEW |