| 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..5a7791ef6aff12dd15c6cc3197710aab2386c503 100644
|
| --- a/chrome/common/extensions/features/complex_feature.cc
|
| +++ b/chrome/common/extensions/features/complex_feature.cc
|
| @@ -9,6 +9,28 @@ namespace extensions {
|
| ComplexFeature::ComplexFeature(scoped_ptr<FeatureList> features) {
|
| DCHECK_GT(features->size(), 0UL);
|
| features_.swap(*features);
|
| +
|
| +#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
|
| + // Verify GetContexts, IsInternal, & IsBlockedInServiceWorker are consistent
|
| + // across all features.
|
| + std::set<Feature::Context>* first_contexts = features_[0]->GetContexts();
|
| + bool first_is_internal = features_[0]->IsInternal();
|
| + bool first_blocked_in_service_worker =
|
| + features_[0]->IsBlockedInServiceWorker();
|
| + for (FeatureList::const_iterator it = features_.begin() + 1;
|
| + it != features_.end();
|
| + ++it) {
|
| + DCHECK(*first_contexts == *(*it)->GetContexts())
|
| + << "Complex feature must have consistent values of "
|
| + "contexts across all sub features.";
|
| + DCHECK(first_is_internal == (*it)->IsInternal())
|
| + << "Complex feature must have consistent values of "
|
| + "internal across all sub features.";
|
| + DCHECK(first_blocked_in_service_worker == (*it)->IsBlockedInServiceWorker())
|
| + << "Complex feature must have consistent values of "
|
| + "blocked_in_service_worker across all sub features.";
|
| + }
|
| +#endif
|
| }
|
|
|
| ComplexFeature::~ComplexFeature() {
|
| @@ -57,6 +79,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 +120,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
|
|
|