Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: extensions/common/features/feature_provider.cc

Issue 2945383002: [Extensions] Fix FeatureProvider::GetChildren() (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | extensions/common/features/feature_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | extensions/common/features/feature_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698