| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_PROVIDER_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_PROVIDER_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_PROVIDER_H_ | 6 #define CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <map> |
| 8 #include <set> | 9 #include <set> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
| 12 #include "base/values.h" | 13 #include "base/values.h" |
| 13 #include "chrome/common/extensions/features/feature.h" | 14 #include "chrome/common/extensions/features/feature.h" |
| 14 #include "chrome/common/extensions/features/feature_provider.h" | 15 #include "chrome/common/extensions/features/feature_provider.h" |
| 16 #include "chrome/common/extensions/features/simple_feature.h" |
| 15 | 17 |
| 16 namespace extensions { | 18 namespace extensions { |
| 17 | 19 |
| 18 // Reads Features out of a simple JSON file description. | 20 // Reads Features out of a simple JSON file description. |
| 19 class SimpleFeatureProvider : public FeatureProvider { | 21 class SimpleFeatureProvider : public FeatureProvider { |
| 20 public: | 22 public: |
| 21 typedef Feature*(*FeatureFactory)(); | 23 typedef SimpleFeature*(*FeatureFactory)(); |
| 22 | 24 |
| 23 // Creates a new SimpleFeatureProvider. Pass null to |factory| to have the | 25 // Creates a new SimpleFeatureProvider. Pass null to |factory| to have the |
| 24 // provider create plain old Feature instances. | 26 // provider create plain old Feature instances. |
| 25 SimpleFeatureProvider(DictionaryValue* root, FeatureFactory factory); | 27 SimpleFeatureProvider(DictionaryValue* root, FeatureFactory factory); |
| 26 virtual ~SimpleFeatureProvider(); | 28 virtual ~SimpleFeatureProvider(); |
| 27 | 29 |
| 28 // Gets an instance for the _manifest_features.json file that is baked into | 30 // Gets an instance for the _manifest_features.json file that is baked into |
| 29 // Chrome as a resource. | 31 // Chrome as a resource. |
| 30 static SimpleFeatureProvider* GetManifestFeatures(); | 32 static SimpleFeatureProvider* GetManifestFeatures(); |
| 31 | 33 |
| 32 // Gets an instance for the _permission_features.json file that is baked into | 34 // Gets an instance for the _permission_features.json file that is baked into |
| 33 // Chrome as a resource. | 35 // Chrome as a resource. |
| 34 static SimpleFeatureProvider* GetPermissionFeatures(); | 36 static SimpleFeatureProvider* GetPermissionFeatures(); |
| 35 | 37 |
| 36 // Returns all features described by this instance. | 38 // Returns all features described by this instance. |
| 37 std::set<std::string> GetAllFeatureNames() const; | 39 std::set<std::string> GetAllFeatureNames() const; |
| 38 | 40 |
| 39 // Gets the feature |feature_name|, if it exists. | 41 // Gets the feature |feature_name|, if it exists. |
| 40 virtual Feature* GetFeature(const std::string& feature_name) OVERRIDE; | 42 virtual SimpleFeature* GetFeature(const std::string& feature_name) OVERRIDE; |
| 41 | 43 |
| 42 private: | 44 private: |
| 43 typedef std::map<std::string, linked_ptr<Feature> > FeatureMap; | 45 typedef std::map<std::string, linked_ptr<SimpleFeature> > FeatureMap; |
| 44 FeatureMap features_; | 46 FeatureMap features_; |
| 45 | 47 |
| 46 FeatureFactory factory_; | 48 FeatureFactory factory_; |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 } // namespace extensions | 51 } // namespace extensions |
| 50 | 52 |
| 51 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_PROVIDER_H_ | 53 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_PROVIDER_H_ |
| OLD | NEW |