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::unique_ptr<FeatureList> features) { | 9 ComplexFeature::ComplexFeature(const std::vector<Feature*>& features) { |
10 DCHECK_GT(features->size(), 0UL); | 10 DCHECK_GT(features.size(), 0UL); |
11 features_.swap(*features); | 11 for (Feature* f : features) |
| 12 features_.push_back(std::unique_ptr<Feature>(f)); |
12 no_parent_ = features_[0]->no_parent(); | 13 no_parent_ = features_[0]->no_parent(); |
13 | 14 |
14 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) | 15 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
15 // Verify IsInternal and no_parent is consistent across all features. | 16 // Verify IsInternal and no_parent is consistent across all features. |
16 bool first_is_internal = features_[0]->IsInternal(); | 17 bool first_is_internal = features_[0]->IsInternal(); |
17 for (FeatureList::const_iterator it = features_.begin() + 1; | 18 for (FeatureList::const_iterator it = features_.begin() + 1; |
18 it != features_.end(); | 19 it != features_.end(); |
19 ++it) { | 20 ++it) { |
20 DCHECK(first_is_internal == (*it)->IsInternal()) | 21 DCHECK(first_is_internal == (*it)->IsInternal()) |
21 << "Complex feature must have consistent values of " | 22 << "Complex feature must have consistent values of " |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 return false; | 97 return false; |
97 } | 98 } |
98 | 99 |
99 bool ComplexFeature::IsInternal() const { | 100 bool ComplexFeature::IsInternal() const { |
100 // Constructor verifies that composed features are consistent, thus we can | 101 // Constructor verifies that composed features are consistent, thus we can |
101 // return just the first feature's value. | 102 // return just the first feature's value. |
102 return features_[0]->IsInternal(); | 103 return features_[0]->IsInternal(); |
103 } | 104 } |
104 | 105 |
105 } // namespace extensions | 106 } // namespace extensions |
OLD | NEW |