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

Side by Side Diff: chrome/common/extensions/simple_feature_provider.h

Issue 9950046: Implement FeatureProvider for ExtensionAPI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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_SIMPLE_FEATURE_PROVIDER_H_ 5 #ifndef CHROME_COMMON_EXTENSIONS_SIMPLE_FEATURE_PROVIDER_H_
6 #define CHROME_COMMON_EXTENSIONS_SIMPLE_FEATURE_PROVIDER_H_ 6 #define CHROME_COMMON_EXTENSIONS_SIMPLE_FEATURE_PROVIDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/common/extensions/feature.h" 14 #include "chrome/common/extensions/feature.h"
15 #include "chrome/common/extensions/feature_provider.h"
15 16
16 namespace extensions { 17 namespace extensions {
17 18
18 // Reads Features out of a simple JSON file description. 19 // Reads Features out of a simple JSON file description.
19 class SimpleFeatureProvider { 20 class SimpleFeatureProvider : public FeatureProvider {
20 public: 21 public:
21 // Create an instance for an arbitrary hunk of JSON. This is typically used 22 typedef Feature*(*FeatureFactory)();
22 // during tests. 23
23 explicit SimpleFeatureProvider(scoped_ptr<DictionaryValue> root); 24 // Creates a new SimpleFeatureProvider. Pass null to |factory| to have the
25 // provider create plain old Factory instances.
koz (OOO until 15th September) 2012/04/02 06:39:48 plain old Factory instances -> plain old Feature i
26 SimpleFeatureProvider(scoped_ptr<DictionaryValue> root,
27 FeatureFactory factory);
24 ~SimpleFeatureProvider(); 28 ~SimpleFeatureProvider();
25 29
26 // 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
27 // Chrome as a resource. 31 // Chrome as a resource.
28 static SimpleFeatureProvider* GetManifestFeatures(); 32 static SimpleFeatureProvider* GetManifestFeatures();
29 33
30 // 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
31 // Chrome as a resource. 35 // Chrome as a resource.
32 static SimpleFeatureProvider* GetPermissionFeatures(); 36 static SimpleFeatureProvider* GetPermissionFeatures();
33 37
34 // Returns all features described by this instance. 38 // Returns all features described by this instance.
35 std::set<std::string> GetAllFeatureNames() const; 39 std::set<std::string> GetAllFeatureNames() const;
36 40
37 // Gets the feature |feature_name|, if it exists. 41 // Gets the feature |feature_name|, if it exists.
38 scoped_ptr<Feature> GetFeature(const std::string& feature_name) const; 42 virtual scoped_ptr<Feature> GetFeature(
43 const std::string& feature_name) OVERRIDE;
39 44
40 private: 45 private:
41 scoped_ptr<DictionaryValue> root_; 46 scoped_ptr<DictionaryValue> root_;
47 FeatureFactory factory_;
42 }; 48 };
43 49
44 } // namespace extensions 50 } // namespace extensions
45 51
46 #endif // CHROME_COMMON_EXTENSIONS_SIMPLE_FEATURE_PROVIDER_H_ 52 #endif // CHROME_COMMON_EXTENSIONS_SIMPLE_FEATURE_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698