Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_COMMON_FEATURES_BASE_FEATURE_PROVIDER_H_ | 5 #ifndef EXTENSIONS_COMMON_FEATURES_BASE_FEATURE_PROVIDER_H_ |
| 6 #define EXTENSIONS_COMMON_FEATURES_BASE_FEATURE_PROVIDER_H_ | 6 #define EXTENSIONS_COMMON_FEATURES_BASE_FEATURE_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | |
| 13 #include "extensions/common/features/feature_provider.h" | 14 #include "extensions/common/features/feature_provider.h" |
| 14 #include "extensions/common/features/simple_feature.h" | |
| 15 | |
| 16 namespace Base { | |
| 17 class DictionaryValue; | |
| 18 } | |
| 19 | 15 |
| 20 namespace extensions { | 16 namespace extensions { |
| 17 class Feature; | |
| 21 | 18 |
| 22 // Reads Features out of a simple JSON file description. | |
| 23 class BaseFeatureProvider : public FeatureProvider { | 19 class BaseFeatureProvider : public FeatureProvider { |
|
asargent_no_longer_on_chrome
2016/07/11 22:39:20
nit: this could use a brief class overview comment
Devlin
2016/07/12 00:45:29
Done.
| |
| 24 public: | 20 public: |
| 25 typedef SimpleFeature*(*FeatureFactory)(); | |
| 26 | |
| 27 // Creates a new BaseFeatureProvider. Pass null to |factory| to have the | |
| 28 // provider create plain old Feature instances. | |
| 29 BaseFeatureProvider(const base::DictionaryValue& root, | |
| 30 FeatureFactory factory); | |
| 31 ~BaseFeatureProvider() override; | 21 ~BaseFeatureProvider() override; |
| 32 | 22 |
| 33 // Gets the feature |feature_name|, if it exists. | 23 // Gets the feature |feature_name|, if it exists. |
| 34 Feature* GetFeature(const std::string& feature_name) const override; | 24 Feature* GetFeature(const std::string& feature_name) const override; |
| 35 Feature* GetParent(Feature* feature) const override; | 25 Feature* GetParent(Feature* feature) const override; |
| 36 std::vector<Feature*> GetChildren(const Feature& parent) const override; | 26 std::vector<Feature*> GetChildren(const Feature& parent) const override; |
| 37 | 27 |
| 38 const FeatureMap& GetAllFeatures() const override; | 28 const FeatureMap& GetAllFeatures() const override; |
| 39 | 29 |
| 40 private: | 30 protected: |
| 31 BaseFeatureProvider(); | |
| 41 std::map<std::string, std::unique_ptr<Feature>> features_; | 32 std::map<std::string, std::unique_ptr<Feature>> features_; |
| 42 | 33 |
| 43 // Populated on first use. | 34 private: |
| 44 mutable std::vector<std::string> feature_names_; | 35 DISALLOW_COPY_AND_ASSIGN(BaseFeatureProvider); |
| 45 | |
| 46 FeatureFactory factory_; | |
| 47 }; | 36 }; |
| 48 | 37 |
| 49 } // namespace extensions | 38 } // namespace extensions |
| 50 | 39 |
| 51 #endif // EXTENSIONS_COMMON_FEATURES_BASE_FEATURE_PROVIDER_H_ | 40 #endif // EXTENSIONS_COMMON_FEATURES_BASE_FEATURE_PROVIDER_H_ |
| OLD | NEW |