Index: extensions/common/features/json_feature_provider.cc |
diff --git a/extensions/common/features/base_feature_provider.cc b/extensions/common/features/json_feature_provider.cc |
similarity index 72% |
copy from extensions/common/features/base_feature_provider.cc |
copy to extensions/common/features/json_feature_provider.cc |
index 40065ff01fece213028bf1cc832ba13efb9bc8b4..15eba689bc76c4d23d63a59d8c8ffe08d19968e5 100644 |
--- a/extensions/common/features/base_feature_provider.cc |
+++ b/extensions/common/features/json_feature_provider.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "extensions/common/features/base_feature_provider.h" |
+#include "extensions/common/features/json_feature_provider.h" |
#include <stddef.h> |
@@ -43,7 +43,7 @@ bool ParseFeature(const base::DictionaryValue* value, |
} // namespace |
-BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root, |
+JSONFeatureProvider::JSONFeatureProvider(const base::DictionaryValue& root, |
FeatureFactory factory) |
: factory_(factory) { |
for (base::DictionaryValue::Iterator iter(root); !iter.IsAtEnd(); |
@@ -62,7 +62,7 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root, |
// If one of the features has "noparent" set, stop pushing features on |
// the stack. The features will then be parsed in order, starting with |
// the farthest parent that is either top level or has "noparent" set. |
- std::stack<std::pair<std::string, const base::DictionaryValue*> > |
+ std::stack<std::pair<std::string, const base::DictionaryValue*>> |
parse_stack; |
while (!split.empty()) { |
std::string parent_name = base::JoinString(split, "."); |
@@ -80,7 +80,8 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root, |
break; |
parent = nullptr; |
} |
- CHECK(parent) << parent_name << " must declare one of its features" |
+ CHECK(parent) |
+ << parent_name << " must declare one of its features" |
<< " the default parent, with {\"default_parent\": true}."; |
} |
parse_stack.push(std::make_pair(parent_name, parent)); |
@@ -95,8 +96,7 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root, |
// Parse all parent features. |
bool parse_error = false; |
while (!parse_stack.empty()) { |
- if (!ParseFeature(parse_stack.top().second, |
- parse_stack.top().first, |
+ if (!ParseFeature(parse_stack.top().second, parse_stack.top().first, |
feature.get())) { |
parse_error = true; |
break; |
@@ -144,53 +144,6 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root, |
} |
} |
-BaseFeatureProvider::~BaseFeatureProvider() { |
-} |
- |
-const FeatureMap& BaseFeatureProvider::GetAllFeatures() const { |
- return features_; |
-} |
- |
-Feature* BaseFeatureProvider::GetFeature(const std::string& name) const { |
- FeatureMap::const_iterator iter = features_.find(name); |
- if (iter != features_.end()) |
- return iter->second.get(); |
- else |
- return nullptr; |
-} |
- |
-Feature* BaseFeatureProvider::GetParent(Feature* feature) const { |
- CHECK(feature); |
- if (feature->no_parent()) |
- return nullptr; |
- |
- std::vector<std::string> split = base::SplitString( |
- feature->name(), ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
- if (split.size() < 2) |
- return nullptr; |
- split.pop_back(); |
- return GetFeature(base::JoinString(split, ".")); |
-} |
- |
-// Children of a given API are named starting with parent.name()+".", which |
-// means they'll be contiguous in the features_ std::map. |
-std::vector<Feature*> BaseFeatureProvider::GetChildren(const Feature& parent) |
- const { |
- std::string prefix = parent.name() + "."; |
- const FeatureMap::const_iterator first_child = features_.lower_bound(prefix); |
- |
- // All children have names before (parent.name() + ('.'+1)). |
- ++prefix.back(); |
- const FeatureMap::const_iterator after_children = |
- features_.lower_bound(prefix); |
- |
- std::vector<Feature*> result; |
- result.reserve(std::distance(first_child, after_children)); |
- for (FeatureMap::const_iterator it = first_child; it != after_children; |
- ++it) { |
- result.push_back(it->second.get()); |
- } |
- return result; |
-} |
+JSONFeatureProvider::~JSONFeatureProvider() {} |
} // namespace extensions |