| Index: chrome/common/extensions/features/base_feature_provider.cc
|
| diff --git a/chrome/common/extensions/features/base_feature_provider.cc b/chrome/common/extensions/features/base_feature_provider.cc
|
| index 285426d147d108f684711b6ef13a51a177ddc7e8..0a6ab9fd77f107e3dd4fe46720c9f7c0d7397206 100644
|
| --- a/chrome/common/extensions/features/base_feature_provider.cc
|
| +++ b/chrome/common/extensions/features/base_feature_provider.cc
|
| @@ -36,7 +36,7 @@ class LazyFeatureProvider : public FeatureProvider {
|
| return GetBaseFeatureProvider()->GetFeature(name);
|
| }
|
|
|
| - virtual std::set<std::string> GetAllFeatureNames() OVERRIDE {
|
| + virtual std::vector<std::string> GetAllFeatureNames() OVERRIDE {
|
| return GetBaseFeatureProvider()->GetAllFeatureNames();
|
| }
|
|
|
| @@ -105,11 +105,22 @@ struct Static {
|
|
|
| base::LazyInstance<Static> g_static = LAZY_INSTANCE_INITIALIZER;
|
|
|
| -bool ParseFeature(const DictionaryValue* value,
|
| +bool ParseFeature(const DictionaryValue& root,
|
| + const DictionaryValue* value,
|
| const std::string& name,
|
| SimpleFeature* feature) {
|
| + std::string error;
|
| + std::string parent_name;
|
| + if (value->GetString("parent", &parent_name)) {
|
| + const DictionaryValue* parent = NULL;
|
| + CHECK(root.GetDictionaryWithoutPathExpansion(parent_name, &parent));
|
| + scoped_ptr<DictionaryValue> value_with_parent(parent->DeepCopy());
|
| + value_with_parent->MergeDictionary(value);
|
| + error = feature->Parse(value_with_parent.get());
|
| + } else {
|
| + error = feature->Parse(value);
|
| + }
|
| feature->set_name(name);
|
| - std::string error = feature->Parse(value);
|
| if (!error.empty())
|
| LOG(ERROR) << error;
|
| return error.empty();
|
| @@ -125,10 +136,12 @@ BaseFeatureProvider::BaseFeatureProvider(const DictionaryValue& root,
|
| if (iter.value().GetType() == Value::TYPE_DICTIONARY) {
|
| linked_ptr<SimpleFeature> feature((*factory_)());
|
|
|
| - if (!ParseFeature(static_cast<const DictionaryValue*>(&iter.value()),
|
| + if (!ParseFeature(root,
|
| + static_cast<const DictionaryValue*>(&iter.value()),
|
| iter.key(),
|
| - feature.get()))
|
| + feature.get())) {
|
| continue;
|
| + }
|
|
|
| features_[iter.key()] = feature;
|
| } else if (iter.value().GetType() == Value::TYPE_LIST) {
|
| @@ -148,10 +161,12 @@ BaseFeatureProvider::BaseFeatureProvider(const DictionaryValue& root,
|
| }
|
|
|
| scoped_ptr<SimpleFeature> feature((*factory_)());
|
| - if (!ParseFeature(static_cast<const DictionaryValue*>(*list_iter),
|
| + if (!ParseFeature(root,
|
| + static_cast<const DictionaryValue*>(*list_iter),
|
| iter.key(),
|
| - feature.get()))
|
| + feature.get())) {
|
| continue;
|
| + }
|
|
|
| features->push_back(feature.release());
|
| }
|
| @@ -176,13 +191,14 @@ FeatureProvider* BaseFeatureProvider::GetByName(
|
| return g_static.Get().LazyGetFeatures(name);
|
| }
|
|
|
| -std::set<std::string> BaseFeatureProvider::GetAllFeatureNames() {
|
| - std::set<std::string> result;
|
| - for (FeatureMap::const_iterator iter = features_.begin();
|
| - iter != features_.end(); ++iter) {
|
| - result.insert(iter->first);
|
| +std::vector<std::string> BaseFeatureProvider::GetAllFeatureNames() {
|
| + if (feature_names_.empty()) {
|
| + for (FeatureMap::const_iterator iter = features_.begin();
|
| + iter != features_.end(); ++iter) {
|
| + feature_names_.push_back(iter->first);
|
| + }
|
| }
|
| - return result;
|
| + return feature_names_;
|
| }
|
|
|
| Feature* BaseFeatureProvider::GetFeature(const std::string& name) {
|
|
|