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 #include "components/flags_ui/flags_state.h" | 5 #include "components/flags_ui/flags_state.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 const auto& entry_it = name_to_switch_map.find(entry_name); | 279 const auto& entry_it = name_to_switch_map.find(entry_name); |
280 DCHECK(entry_it != name_to_switch_map.end()); | 280 DCHECK(entry_it != name_to_switch_map.end()); |
281 | 281 |
282 const SwitchEntry& entry = entry_it->second; | 282 const SwitchEntry& entry = entry_it->second; |
283 if (!entry.switch_name.empty()) | 283 if (!entry.switch_name.empty()) |
284 switches.insert("--" + entry.switch_name); | 284 switches.insert("--" + entry.switch_name); |
285 } | 285 } |
286 return switches; | 286 return switches; |
287 } | 287 } |
288 | 288 |
| 289 std::set<std::string> FlagsState::GetFeaturesFromFlags( |
| 290 FlagsStorage* flags_storage) { |
| 291 std::set<std::string> enabled_entries; |
| 292 std::map<std::string, SwitchEntry> name_to_switch_map; |
| 293 GenerateFlagsToSwitchesMapping(flags_storage, &enabled_entries, |
| 294 &name_to_switch_map); |
| 295 |
| 296 std::set<std::string> features; |
| 297 for (const std::string& entry_name : enabled_entries) { |
| 298 const auto& entry_it = name_to_switch_map.find(entry_name); |
| 299 DCHECK(entry_it != name_to_switch_map.end()); |
| 300 |
| 301 const SwitchEntry& entry = entry_it->second; |
| 302 if (!entry.feature_name.empty()) { |
| 303 if (entry.feature_state) |
| 304 features.insert(entry.feature_name + ":enabled"); |
| 305 else |
| 306 features.insert(entry.feature_name + ":disabled"); |
| 307 } |
| 308 } |
| 309 return features; |
| 310 } |
| 311 |
289 bool FlagsState::IsRestartNeededToCommitChanges() { | 312 bool FlagsState::IsRestartNeededToCommitChanges() { |
290 return needs_restart_; | 313 return needs_restart_; |
291 } | 314 } |
292 | 315 |
293 void FlagsState::SetFeatureEntryEnabled(FlagsStorage* flags_storage, | 316 void FlagsState::SetFeatureEntryEnabled(FlagsStorage* flags_storage, |
294 const std::string& internal_name, | 317 const std::string& internal_name, |
295 bool enable) { | 318 bool enable) { |
296 size_t at_index = internal_name.find(testing::kMultiSeparator); | 319 size_t at_index = internal_name.find(testing::kMultiSeparator); |
297 if (at_index != std::string::npos) { | 320 if (at_index != std::string::npos) { |
298 DCHECK(enable); | 321 DCHECK(enable); |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 state == FeatureEntry::FeatureState::ENABLED, | 772 state == FeatureEntry::FeatureState::ENABLED, |
750 name_to_switch_map); | 773 name_to_switch_map); |
751 } | 774 } |
752 } | 775 } |
753 break; | 776 break; |
754 } | 777 } |
755 } | 778 } |
756 } | 779 } |
757 | 780 |
758 } // namespace flags_ui | 781 } // namespace flags_ui |
OLD | NEW |