Chromium Code Reviews| Index: chrome/common/extensions/features/complex_feature.cc |
| diff --git a/chrome/common/extensions/features/complex_feature.cc b/chrome/common/extensions/features/complex_feature.cc |
| index a1cedfaacba76e4e0f5747180ee15629a13949a2..d73084e74413f5985ee5e0d3f7ab4e009fa4d1b7 100644 |
| --- a/chrome/common/extensions/features/complex_feature.cc |
| +++ b/chrome/common/extensions/features/complex_feature.cc |
| @@ -9,6 +9,17 @@ namespace extensions { |
| ComplexFeature::ComplexFeature(scoped_ptr<FeatureList> features) { |
| DCHECK_GT(features->size(), 0UL); |
| features_.swap(*features); |
| + |
| + // Verify IsBlockedInServiceWorker is consistent across all features. |
|
not at google - send to devlin
2014/03/28 17:30:49
cool, good idea. Any chance you do the same for Ge
scheib
2014/03/28 18:15:21
Done.
|
| + bool first_blocked_in_service_worker = |
| + features_[0]->IsBlockedInServiceWorker(); |
| + for (FeatureList::const_iterator it = features_.begin() + 1; |
| + it != features_.end(); |
| + ++it) { |
| + DCHECK(first_blocked_in_service_worker == (*it)->IsBlockedInServiceWorker()) |
| + << "Complex feature must have consistent values of " |
| + "blocked_in_service_worker across all sub features."; |
| + } |
| } |
| ComplexFeature::~ComplexFeature() { |
| @@ -57,6 +68,22 @@ Feature::Availability ComplexFeature::IsAvailableToContext( |
| return first_availability; |
| } |
| +bool ComplexFeature::IsIdInWhitelist(const std::string& extension_id) const { |
| + for (FeatureList::const_iterator it = features_.begin(); |
| + it != features_.end(); |
| + ++it) { |
| + if ((*it)->IsIdInWhitelist(extension_id)) |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| +bool ComplexFeature::IsBlockedInServiceWorker() const { |
| + // Constructor verifies that composed features are consistent, thus we can |
| + // return just the first feature's value. |
| + return features_[0]->IsBlockedInServiceWorker(); |
| +} |
| + |
| std::set<Feature::Context>* ComplexFeature::GetContexts() { |
| // TODO(justinlin): Current use cases for ComplexFeatures are simple (e.g. |
| // allow API in dev channel for everyone but stable channel for a whitelist), |
| @@ -82,13 +109,4 @@ std::string ComplexFeature::GetAvailabilityMessage(AvailabilityResult result, |
| return features_[0]->GetAvailabilityMessage(result, type, url, context); |
| } |
| -bool ComplexFeature::IsIdInWhitelist(const std::string& extension_id) const { |
| - for (FeatureList::const_iterator it = features_.begin(); |
| - it != features_.end(); ++it) { |
| - if ((*it)->IsIdInWhitelist(extension_id)) |
| - return true; |
| - } |
| - return false; |
| -} |
| - |
| } // namespace extensions |