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_BASE_FEATURE_PROVIDER_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_FEATURES_BASE_FEATURE_PROVIDER_H_ |
6 #define CHROME_COMMON_EXTENSIONS_FEATURES_BASE_FEATURE_PROVIDER_H_ | 6 #define CHROME_COMMON_EXTENSIONS_FEATURES_BASE_FEATURE_PROVIDER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | |
10 #include <string> | 9 #include <string> |
| 10 #include <vector> |
11 | 11 |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/common/extensions/features/feature_provider.h" | 14 #include "chrome/common/extensions/features/feature_provider.h" |
15 #include "chrome/common/extensions/features/simple_feature.h" | 15 #include "chrome/common/extensions/features/simple_feature.h" |
16 | 16 |
17 namespace extensions { | 17 namespace extensions { |
18 | 18 |
19 // Reads Features out of a simple JSON file description. | 19 // Reads Features out of a simple JSON file description. |
20 class BaseFeatureProvider : public FeatureProvider { | 20 class BaseFeatureProvider : public FeatureProvider { |
21 public: | 21 public: |
22 typedef SimpleFeature*(*FeatureFactory)(); | 22 typedef SimpleFeature*(*FeatureFactory)(); |
23 | 23 |
24 // Creates a new BaseFeatureProvider. Pass null to |factory| to have the | 24 // Creates a new BaseFeatureProvider. Pass null to |factory| to have the |
25 // provider create plain old Feature instances. | 25 // provider create plain old Feature instances. |
26 BaseFeatureProvider(const DictionaryValue& root, FeatureFactory factory); | 26 BaseFeatureProvider(const DictionaryValue& root, FeatureFactory factory); |
27 virtual ~BaseFeatureProvider(); | 27 virtual ~BaseFeatureProvider(); |
28 | 28 |
29 // Gets a feature provider for a specific feature type, like "permission". | 29 // Gets a feature provider for a specific feature type, like "permission". |
30 static FeatureProvider* GetByName(const std::string& name); | 30 static FeatureProvider* GetByName(const std::string& name); |
31 | 31 |
32 static FeatureProvider* GetPermissionFeatures() { | 32 static FeatureProvider* GetPermissionFeatures() { |
33 return GetByName("permission"); | 33 return GetByName("permission"); |
34 } | 34 } |
35 | 35 |
36 // Gets the feature |feature_name|, if it exists. | 36 // Gets the feature |feature_name|, if it exists. |
37 virtual Feature* GetFeature(const std::string& feature_name) OVERRIDE; | 37 virtual Feature* GetFeature(const std::string& feature_name) OVERRIDE; |
| 38 virtual Feature* GetParent(Feature* feature) OVERRIDE; |
38 | 39 |
39 virtual std::set<std::string> GetAllFeatureNames() OVERRIDE; | 40 virtual const std::vector<std::string>& GetAllFeatureNames() OVERRIDE; |
40 | 41 |
41 private: | 42 private: |
42 typedef std::map<std::string, linked_ptr<Feature> > FeatureMap; | 43 typedef std::map<std::string, linked_ptr<Feature> > FeatureMap; |
43 FeatureMap features_; | 44 FeatureMap features_; |
44 | 45 |
| 46 std::vector<std::string> feature_names_; |
| 47 |
45 FeatureFactory factory_; | 48 FeatureFactory factory_; |
46 }; | 49 }; |
47 | 50 |
48 } // namespace extensions | 51 } // namespace extensions |
49 | 52 |
50 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_BASE_FEATURE_PROVIDER_H_ | 53 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_BASE_FEATURE_PROVIDER_H_ |
OLD | NEW |