Index: extensions/common/features/base_feature_provider.cc |
diff --git a/extensions/common/features/base_feature_provider.cc b/extensions/common/features/base_feature_provider.cc |
index 57ee6523413b4c2f1032dde3f4857402779c0f5e..4b03fd0eca742c5ab2c79a8558f2cf92bfff91d1 100644 |
--- a/extensions/common/features/base_feature_provider.cc |
+++ b/extensions/common/features/base_feature_provider.cc |
@@ -6,84 +6,16 @@ |
#include <stack> |
-#include "base/json/json_reader.h" |
-#include "base/lazy_instance.h" |
#include "base/strings/string_split.h" |
#include "base/strings/string_util.h" |
#include "extensions/common/extensions_client.h" |
-#include "extensions/common/features/api_feature.h" |
#include "extensions/common/features/complex_feature.h" |
-#include "extensions/common/features/manifest_feature.h" |
-#include "extensions/common/features/permission_feature.h" |
-#include "grit/common_resources.h" |
-#include "ui/base/resource/resource_bundle.h" |
+#include "extensions/common/features/simple_feature.h" |
namespace extensions { |
namespace { |
-template<class FeatureClass> |
-SimpleFeature* CreateFeature() { |
- SimpleFeature* feature = new FeatureClass(); |
- ExtensionsClient::Get()->AddExtraFeatureFilters(feature); |
- return feature; |
-} |
- |
-static BaseFeatureProvider* LoadProvider( |
- const std::string& name, |
- BaseFeatureProvider::FeatureFactory factory, |
- int resource_id) { |
- const std::string& features_file = |
- ResourceBundle::GetSharedInstance().GetRawDataResource( |
- resource_id).as_string(); |
- int error_code = 0; |
- std::string error_message; |
- scoped_ptr<base::Value> value(base::JSONReader::ReadAndReturnError( |
- features_file, base::JSON_PARSE_RFC, |
- &error_code, &error_message)); |
- DCHECK(value) << "Could not load features: " << name << " " |
- << error_message; |
- scoped_ptr<base::DictionaryValue> value_as_dict; |
- if (value) { |
- CHECK(value->IsType(base::Value::TYPE_DICTIONARY)) << name; |
- value_as_dict.reset(static_cast<base::DictionaryValue*>(value.release())); |
- } else { |
- // http://crbug.com/176381 |
- value_as_dict.reset(new base::DictionaryValue()); |
- } |
- return new BaseFeatureProvider(*value_as_dict, factory); |
-} |
- |
-struct Static { |
- Static() { |
- feature_providers["api"] = make_linked_ptr( |
- LoadProvider("api", |
- &CreateFeature<APIFeature>, |
- IDR_EXTENSION_API_FEATURES)); |
- feature_providers["permission"] = make_linked_ptr( |
- LoadProvider("permission", |
- &CreateFeature<PermissionFeature>, |
- IDR_EXTENSION_PERMISSION_FEATURES)); |
- feature_providers["manifest"] = make_linked_ptr( |
- LoadProvider("manifest", |
- &CreateFeature<ManifestFeature>, |
- IDR_EXTENSION_MANIFEST_FEATURES)); |
- } |
- |
- typedef std::map<std::string, linked_ptr<FeatureProvider> > |
- FeatureProviderMap; |
- |
- FeatureProvider* GetFeatures(const std::string& name) const { |
- FeatureProviderMap::const_iterator it = feature_providers.find(name); |
- CHECK(it != feature_providers.end()); |
- return it->second.get(); |
- } |
- |
- FeatureProviderMap feature_providers; |
-}; |
- |
-base::LazyInstance<Static> g_static = LAZY_INSTANCE_INITIALIZER; |
- |
bool ParseFeature(const base::DictionaryValue* value, |
const std::string& name, |
SimpleFeature* feature) { |
@@ -98,8 +30,7 @@ bool ParseFeature(const base::DictionaryValue* value, |
BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root, |
FeatureFactory factory) |
- : factory_(factory ? factory : |
- static_cast<FeatureFactory>(&CreateFeature<SimpleFeature>)) { |
+ : factory_(factory) { |
for (base::DictionaryValue::Iterator iter(root); !iter.IsAtEnd(); |
iter.Advance()) { |
if (iter.value().GetType() == base::Value::TYPE_DICTIONARY) { |
@@ -185,12 +116,6 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root, |
BaseFeatureProvider::~BaseFeatureProvider() { |
} |
-// static |
-FeatureProvider* BaseFeatureProvider::GetByName( |
- const std::string& name) { |
- return g_static.Get().GetFeatures(name); |
-} |
- |
const std::vector<std::string>& BaseFeatureProvider::GetAllFeatureNames() |
const { |
if (feature_names_.empty()) { |