| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/feature_provider.h" | 5 #include "extensions/common/features/feature_provider.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 // All children have names before (parent.name() + ('.'+1)). | 158 // All children have names before (parent.name() + ('.'+1)). |
| 159 ++prefix.back(); | 159 ++prefix.back(); |
| 160 const FeatureMap::const_iterator after_children = | 160 const FeatureMap::const_iterator after_children = |
| 161 features_.lower_bound(prefix); | 161 features_.lower_bound(prefix); |
| 162 | 162 |
| 163 std::vector<Feature*> result; | 163 std::vector<Feature*> result; |
| 164 result.reserve(std::distance(first_child, after_children)); | 164 result.reserve(std::distance(first_child, after_children)); |
| 165 for (FeatureMap::const_iterator it = first_child; it != after_children; | 165 for (FeatureMap::const_iterator it = first_child; it != after_children; |
| 166 ++it) { | 166 ++it) { |
| 167 result.push_back(it->second.get()); | 167 if (!it->second->no_parent()) |
| 168 result.push_back(it->second.get()); |
| 168 } | 169 } |
| 169 return result; | 170 return result; |
| 170 } | 171 } |
| 171 | 172 |
| 172 const FeatureMap& FeatureProvider::GetAllFeatures() const { | 173 const FeatureMap& FeatureProvider::GetAllFeatures() const { |
| 173 return features_; | 174 return features_; |
| 174 } | 175 } |
| 175 | 176 |
| 176 void FeatureProvider::AddFeature(base::StringPiece name, | 177 void FeatureProvider::AddFeature(base::StringPiece name, |
| 177 std::unique_ptr<Feature> feature) { | 178 std::unique_ptr<Feature> feature) { |
| 178 features_[name.as_string()] = std::move(feature); | 179 features_[name.as_string()] = std::move(feature); |
| 179 } | 180 } |
| 180 | 181 |
| 181 void FeatureProvider::AddFeature(base::StringPiece name, Feature* feature) { | 182 void FeatureProvider::AddFeature(base::StringPiece name, Feature* feature) { |
| 182 features_[name.as_string()] = std::unique_ptr<Feature>(feature); | 183 features_[name.as_string()] = std::unique_ptr<Feature>(feature); |
| 183 } | 184 } |
| 184 | 185 |
| 185 } // namespace extensions | 186 } // namespace extensions |
| OLD | NEW |