OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/common/features/complex_feature.h" | 5 #include "extensions/common/features/complex_feature.h" |
6 | 6 |
7 namespace extensions { | 7 namespace extensions { |
8 | 8 |
9 ComplexFeature::ComplexFeature(std::vector<Feature*>* features) { | 9 ComplexFeature::ComplexFeature(std::vector<Feature*>* features) { |
10 DCHECK_GT(features->size(), 0UL); | 10 DCHECK_GT(features->size(), 0UL); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 bool ComplexFeature::IsIdInWhitelist(const std::string& extension_id) const { | 91 bool ComplexFeature::IsIdInWhitelist(const std::string& extension_id) const { |
92 for (FeatureList::const_iterator it = features_.begin(); | 92 for (FeatureList::const_iterator it = features_.begin(); |
93 it != features_.end(); | 93 it != features_.end(); |
94 ++it) { | 94 ++it) { |
95 if ((*it)->IsIdInWhitelist(extension_id)) | 95 if ((*it)->IsIdInWhitelist(extension_id)) |
96 return true; | 96 return true; |
97 } | 97 } |
98 return false; | 98 return false; |
99 } | 99 } |
100 | 100 |
| 101 Feature::Availability ComplexFeature::IsAvailableToChannel( |
| 102 version_info::Channel channel) const { |
| 103 Feature::Availability first_availability = |
| 104 features_[0]->IsAvailableToChannel(channel); |
| 105 if (first_availability.is_available()) |
| 106 return first_availability; |
| 107 |
| 108 for (FeatureList::const_iterator it = features_.begin() + 1; |
| 109 it != features_.end(); ++it) { |
| 110 Availability availability = (*it)->IsAvailableToChannel(channel); |
| 111 if (availability.is_available()) |
| 112 return availability; |
| 113 } |
| 114 // If none of the SimpleFeatures are available, we return the availability |
| 115 // info of the first SimpleFeature that was not available. |
| 116 return first_availability; |
| 117 } |
| 118 |
101 bool ComplexFeature::IsInternal() const { | 119 bool ComplexFeature::IsInternal() const { |
102 // Constructor verifies that composed features are consistent, thus we can | 120 // Constructor verifies that composed features are consistent, thus we can |
103 // return just the first feature's value. | 121 // return just the first feature's value. |
104 return features_[0]->IsInternal(); | 122 return features_[0]->IsInternal(); |
105 } | 123 } |
106 | 124 |
107 } // namespace extensions | 125 } // namespace extensions |
OLD | NEW |