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 "base/feature_list.h" | 5 #include "base/feature_list.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 for (const auto& entry : overrides_) { | 102 for (const auto& entry : overrides_) { |
103 std::string* target_list = nullptr; | 103 std::string* target_list = nullptr; |
104 switch (entry.second.overridden_state) { | 104 switch (entry.second.overridden_state) { |
105 case OVERRIDE_ENABLE_FEATURE: | 105 case OVERRIDE_ENABLE_FEATURE: |
106 target_list = enable_overrides; | 106 target_list = enable_overrides; |
107 break; | 107 break; |
108 case OVERRIDE_DISABLE_FEATURE: | 108 case OVERRIDE_DISABLE_FEATURE: |
109 target_list = disable_overrides; | 109 target_list = disable_overrides; |
110 break; | 110 break; |
| 111 case OVERRIDE_USE_DEFAULT: |
| 112 continue; |
111 } | 113 } |
112 | 114 |
113 if (!target_list->empty()) | 115 if (!target_list->empty()) |
114 target_list->push_back(','); | 116 target_list->push_back(','); |
115 target_list->append(entry.first); | 117 target_list->append(entry.first); |
116 if (entry.second.field_trial) { | 118 if (entry.second.field_trial) { |
117 target_list->push_back('<'); | 119 target_list->push_back('<'); |
118 target_list->append(entry.second.field_trial->trial_name()); | 120 target_list->append(entry.second.field_trial->trial_name()); |
119 } | 121 } |
120 } | 122 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 172 |
171 auto it = overrides_.find(feature.name); | 173 auto it = overrides_.find(feature.name); |
172 if (it != overrides_.end()) { | 174 if (it != overrides_.end()) { |
173 const OverrideEntry& entry = it->second; | 175 const OverrideEntry& entry = it->second; |
174 | 176 |
175 // Activate the corresponding field trial, if necessary. | 177 // Activate the corresponding field trial, if necessary. |
176 if (entry.field_trial) | 178 if (entry.field_trial) |
177 entry.field_trial->group(); | 179 entry.field_trial->group(); |
178 | 180 |
179 // TODO(asvitkine) Expand this section as more support is added. | 181 // TODO(asvitkine) Expand this section as more support is added. |
180 return entry.overridden_state == OVERRIDE_ENABLE_FEATURE; | 182 |
| 183 // If marked as OVERRIDE_USE_DEFAULT, simply return the default state below. |
| 184 if (entry.overridden_state != OVERRIDE_USE_DEFAULT) |
| 185 return entry.overridden_state == OVERRIDE_ENABLE_FEATURE; |
181 } | 186 } |
182 // Otherwise, return the default state. | 187 // Otherwise, return the default state. |
183 return feature.default_state == FEATURE_ENABLED_BY_DEFAULT; | 188 return feature.default_state == FEATURE_ENABLED_BY_DEFAULT; |
184 } | 189 } |
185 | 190 |
186 void FeatureList::RegisterOverridesFromCommandLine( | 191 void FeatureList::RegisterOverridesFromCommandLine( |
187 const std::string& feature_list, | 192 const std::string& feature_list, |
188 OverrideState overridden_state) { | 193 OverrideState overridden_state) { |
189 for (const auto& value : SplitFeatureListString(feature_list)) { | 194 for (const auto& value : SplitFeatureListString(feature_list)) { |
190 StringPiece feature_name(value); | 195 StringPiece feature_name(value); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 return it->second == &feature; | 236 return it->second == &feature; |
232 } | 237 } |
233 | 238 |
234 FeatureList::OverrideEntry::OverrideEntry(OverrideState overridden_state, | 239 FeatureList::OverrideEntry::OverrideEntry(OverrideState overridden_state, |
235 FieldTrial* field_trial) | 240 FieldTrial* field_trial) |
236 : overridden_state(overridden_state), | 241 : overridden_state(overridden_state), |
237 field_trial(field_trial), | 242 field_trial(field_trial), |
238 overridden_by_field_trial(field_trial != nullptr) {} | 243 overridden_by_field_trial(field_trial != nullptr) {} |
239 | 244 |
240 } // namespace base | 245 } // namespace base |
OLD | NEW |