Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: chrome/common/extensions/features/base_feature_provider.h

Issue 13997002: Load extensions features file separately when needed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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> 9 #include <set>
10 #include <string> 10 #include <string>
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 an instance for the _api_features.json file that is baked into 29 // Use GetFeaturesByName() to get the BaseFeatureProvider for a specific type.
30 // Chrome as a resource. 30 // If it is possible that the feature provider will not be used, use
31 static BaseFeatureProvider* GetAPIFeatures(); 31 // LazyGetFeaturesByName().
32 32 static BaseFeatureProvider* GetFeaturesByName(const std::string& name);
33 // Gets an instance for the _manifest_features.json file that is baked into 33 static FeatureProvider* LazyGetFeaturesByName(const std::string& name);
not at google - send to devlin 2013/04/10 02:06:22 Is there really a difference? Can you combine thes
cduvall 2013/04/10 02:26:12 They're both needed because GetFeaturesByName() re
not at google - send to devlin 2013/04/10 02:42:13 Ah ok. Perhaps we should pull GetAllFeatureNames i
cduvall 2013/04/10 02:57:56 Done, had to take off the const, because it wouldn
34 // Chrome as a resource.
35 static BaseFeatureProvider* GetManifestFeatures();
36
37 // Gets an instance for the _permission_features.json file that is baked into
38 // Chrome as a resource.
39 static BaseFeatureProvider* GetPermissionFeatures();
40 34
41 // Returns all features described by this instance. 35 // Returns all features described by this instance.
42 std::set<std::string> GetAllFeatureNames() const; 36 std::set<std::string> GetAllFeatureNames() const;
43 37
44 // Gets the feature |feature_name|, if it exists. 38 // Gets the feature |feature_name|, if it exists.
45 virtual Feature* GetFeature(const std::string& feature_name) OVERRIDE; 39 virtual Feature* GetFeature(const std::string& feature_name) OVERRIDE;
46 40
47 private: 41 private:
48 typedef std::map<std::string, linked_ptr<Feature> > FeatureMap; 42 typedef std::map<std::string, linked_ptr<Feature> > FeatureMap;
49 FeatureMap features_; 43 FeatureMap features_;
50 44
51 FeatureFactory factory_; 45 FeatureFactory factory_;
52 }; 46 };
53 47
54 } // namespace extensions 48 } // namespace extensions
55 49
56 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_BASE_FEATURE_PROVIDER_H_ 50 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_BASE_FEATURE_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698