Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / extensions / common / features / feature_provider.h
blob40d8ab84f6d8cf19b69ffd62116ed92b162a9542
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_COMMON_FEATURES_FEATURE_PROVIDER_H_
6 #define EXTENSIONS_COMMON_FEATURES_FEATURE_PROVIDER_H_
8 #include <string>
9 #include <vector>
11 namespace extensions {
13 class Feature;
15 // Implemented by classes that can vend features.
16 class FeatureProvider {
17 public:
18 FeatureProvider() {}
19 virtual ~FeatureProvider() {}
22 // Static helpers.
25 // Gets a FeatureProvider for a specific type, like "permission".
26 static const FeatureProvider* GetByName(const std::string& name);
28 // Directly access the common FeatureProvider types.
29 // Each is equivalent to GetByName('featuretype').
30 static const FeatureProvider* GetAPIFeatures();
31 static const FeatureProvider* GetManifestFeatures();
32 static const FeatureProvider* GetPermissionFeatures();
33 static const FeatureProvider* GetBehaviorFeatures();
35 // Directly get Features from the common FeatureProvider types.
36 // Each is equivalent to GetByName('featuretype')->GetFeature(name).
37 static const Feature* GetAPIFeature(const std::string& name);
38 static const Feature* GetManifestFeature(const std::string& name);
39 static const Feature* GetPermissionFeature(const std::string& name);
40 static const Feature* GetBehaviorFeature(const std::string& name);
43 // Instance methods.
46 // Returns the feature with the specified name.
47 virtual Feature* GetFeature(const std::string& name) const = 0;
49 // Returns the parent feature of |feature|, or NULL if there isn't one.
50 virtual Feature* GetParent(Feature* feature) const = 0;
52 // Returns the features inside the |parent| namespace, recursively.
53 virtual std::vector<Feature*> GetChildren(const Feature& parent) const = 0;
55 // Returns all features described by this instance, in asciibetical order.
56 virtual const std::vector<std::string>& GetAllFeatureNames() const = 0;
59 } // namespace extensions
61 #endif // EXTENSIONS_COMMON_FEATURES_FEATURE_PROVIDER_H_