| 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_COMPLEX_FEATURE_H_ | 5 #ifndef EXTENSIONS_COMMON_FEATURES_COMPLEX_FEATURE_H_ |
| 6 #define EXTENSIONS_COMMON_FEATURES_COMPLEX_FEATURE_H_ | 6 #define EXTENSIONS_COMMON_FEATURES_COMPLEX_FEATURE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "extensions/common/extension.h" | 15 #include "extensions/common/extension.h" |
| 16 #include "extensions/common/features/feature.h" | 16 #include "extensions/common/features/feature.h" |
| 17 #include "extensions/common/manifest.h" | 17 #include "extensions/common/manifest.h" |
| 18 | 18 |
| 19 namespace extensions { | 19 namespace extensions { |
| 20 | 20 |
| 21 // A ComplexFeature is composed of one or many Features. A ComplexFeature | 21 // A ComplexFeature is composed of one or many Features. A ComplexFeature |
| 22 // is available if any Feature (i.e. permission rule) that composes it is | 22 // is available if any Feature (i.e. permission rule) that composes it is |
| 23 // available, but not if only some combination of Features is available. | 23 // available, but not if only some combination of Features is available. |
| 24 class ComplexFeature : public Feature { | 24 class ComplexFeature : public Feature { |
| 25 public: | 25 public: |
| 26 // Takes ownership of Feature*s contained in |features|. | 26 using FeatureList = std::vector<std::unique_ptr<Feature>>; |
| 27 explicit ComplexFeature(std::vector<Feature*>* features); | 27 |
| 28 explicit ComplexFeature(std::unique_ptr<FeatureList> features); |
| 28 ~ComplexFeature() override; | 29 ~ComplexFeature() override; |
| 29 | 30 |
| 30 // extensions::Feature: | 31 // extensions::Feature: |
| 31 Availability IsAvailableToManifest(const std::string& extension_id, | 32 Availability IsAvailableToManifest(const std::string& extension_id, |
| 32 Manifest::Type type, | 33 Manifest::Type type, |
| 33 Manifest::Location location, | 34 Manifest::Location location, |
| 34 int manifest_version, | 35 int manifest_version, |
| 35 Platform platform) const override; | 36 Platform platform) const override; |
| 36 | 37 |
| 37 Availability IsAvailableToContext(const Extension* extension, | 38 Availability IsAvailableToContext(const Extension* extension, |
| 38 Context context, | 39 Context context, |
| 39 const GURL& url, | 40 const GURL& url, |
| 40 Platform platform) const override; | 41 Platform platform) const override; |
| 41 | 42 |
| 42 bool IsIdInBlacklist(const std::string& extension_id) const override; | 43 bool IsIdInBlacklist(const std::string& extension_id) const override; |
| 43 bool IsIdInWhitelist(const std::string& extension_id) const override; | 44 bool IsIdInWhitelist(const std::string& extension_id) const override; |
| 44 | 45 |
| 45 protected: | 46 protected: |
| 46 // Feature: | 47 // Feature: |
| 47 bool IsInternal() const override; | 48 bool IsInternal() const override; |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 FRIEND_TEST_ALL_PREFIXES(FeaturesGenerationTest, FeaturesTest); | 51 FRIEND_TEST_ALL_PREFIXES(FeaturesGenerationTest, FeaturesTest); |
| 51 | 52 |
| 52 using FeatureList = std::vector<std::unique_ptr<Feature>>; | |
| 53 FeatureList features_; | 53 FeatureList features_; |
| 54 | 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(ComplexFeature); | 55 DISALLOW_COPY_AND_ASSIGN(ComplexFeature); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 } // namespace extensions | 58 } // namespace extensions |
| 59 | 59 |
| 60 #endif // EXTENSIONS_COMMON_FEATURES_COMPLEX_FEATURE_H_ | 60 #endif // EXTENSIONS_COMMON_FEATURES_COMPLEX_FEATURE_H_ |
| OLD | NEW |