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> |
| 8 #include <utility> |
| 9 |
7 #include "base/callback.h" | 10 #include "base/callback.h" |
8 #include "base/feature_list.h" | 11 #include "base/feature_list.h" |
9 #include "base/logging.h" | 12 #include "base/logging.h" |
10 #include "base/macros.h" | 13 #include "base/macros.h" |
11 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
12 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
14 #include "base/values.h" | 17 #include "base/values.h" |
15 #include "build/build_config.h" | 18 #include "build/build_config.h" |
16 #include "components/flags_ui/feature_entry.h" | 19 #include "components/flags_ui/feature_entry.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 159 } |
157 | 160 |
158 // Returns the Value representing the choice data in the specified entry. | 161 // Returns the Value representing the choice data in the specified entry. |
159 base::Value* CreateChoiceData(const FeatureEntry& entry, | 162 base::Value* CreateChoiceData(const FeatureEntry& entry, |
160 const std::set<std::string>& enabled_entries) { | 163 const std::set<std::string>& enabled_entries) { |
161 DCHECK(entry.type == FeatureEntry::MULTI_VALUE || | 164 DCHECK(entry.type == FeatureEntry::MULTI_VALUE || |
162 entry.type == FeatureEntry::ENABLE_DISABLE_VALUE || | 165 entry.type == FeatureEntry::ENABLE_DISABLE_VALUE || |
163 entry.type == FeatureEntry::FEATURE_VALUE); | 166 entry.type == FeatureEntry::FEATURE_VALUE); |
164 base::ListValue* result = new base::ListValue; | 167 base::ListValue* result = new base::ListValue; |
165 for (int i = 0; i < entry.num_choices; ++i) { | 168 for (int i = 0; i < entry.num_choices; ++i) { |
166 base::DictionaryValue* value = new base::DictionaryValue; | 169 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); |
167 const std::string name = entry.NameForChoice(i); | 170 const std::string name = entry.NameForChoice(i); |
168 value->SetString("internal_name", name); | 171 value->SetString("internal_name", name); |
169 value->SetString("description", entry.DescriptionForChoice(i)); | 172 value->SetString("description", entry.DescriptionForChoice(i)); |
170 value->SetBoolean("selected", enabled_entries.count(name) > 0); | 173 value->SetBoolean("selected", enabled_entries.count(name) > 0); |
171 result->Append(value); | 174 result->Append(std::move(value)); |
172 } | 175 } |
173 return result; | 176 return result; |
174 } | 177 } |
175 | 178 |
176 } // namespace | 179 } // namespace |
177 | 180 |
178 // Keeps track of affected switches for each FeatureEntry, based on which | 181 // Keeps track of affected switches for each FeatureEntry, based on which |
179 // choice is selected for it. | 182 // choice is selected for it. |
180 struct SwitchEntry { | 183 struct SwitchEntry { |
181 // Corresponding base::Feature to toggle. | 184 // Corresponding base::Feature to toggle. |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 } | 634 } |
632 | 635 |
633 std::set<std::string> new_enabled_entries = | 636 std::set<std::string> new_enabled_entries = |
634 base::STLSetIntersection<std::set<std::string>>(platform_entries, | 637 base::STLSetIntersection<std::set<std::string>>(platform_entries, |
635 *result); | 638 *result); |
636 | 639 |
637 result->swap(new_enabled_entries); | 640 result->swap(new_enabled_entries); |
638 } | 641 } |
639 | 642 |
640 } // namespace flags_ui | 643 } // namespace flags_ui |
OLD | NEW |