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_SIMPLE_FEATURE_H_ | 5 #ifndef EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ |
6 #define EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ | 6 #define EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
18 #include "extensions/common/features/feature.h" | 18 #include "extensions/common/features/feature.h" |
19 #include "extensions/common/features/simple_feature_filter.h" | 19 #include "extensions/common/features/simple_feature_filter.h" |
20 #include "extensions/common/manifest.h" | 20 #include "extensions/common/manifest.h" |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 | 23 |
24 class SimpleFeature : public Feature { | 24 class SimpleFeature : public Feature { |
25 public: | 25 public: |
26 SimpleFeature(); | 26 SimpleFeature(); |
27 virtual ~SimpleFeature(); | 27 ~SimpleFeature() override; |
28 | 28 |
29 // Similar to Manifest::Location, these are the classes of locations | 29 // Similar to Manifest::Location, these are the classes of locations |
30 // supported in feature files; "component" implies | 30 // supported in feature files; "component" implies |
31 // COMPONENT/EXTERNAL_COMPONENT manifest location types, etc. | 31 // COMPONENT/EXTERNAL_COMPONENT manifest location types, etc. |
32 // | 32 // |
33 // This is only public for testing. Production code should never access it, | 33 // This is only public for testing. Production code should never access it, |
34 // nor should it really have any reason to access the SimpleFeature class | 34 // nor should it really have any reason to access the SimpleFeature class |
35 // directly, it should be dealing with the Feature interface. | 35 // directly, it should be dealing with the Feature interface. |
36 enum Location { | 36 enum Location { |
37 UNSPECIFIED_LOCATION, | 37 UNSPECIFIED_LOCATION, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 Platform platform) const { | 82 Platform platform) const { |
83 return IsAvailableToContext(extension, context, GURL(), platform); | 83 return IsAvailableToContext(extension, context, GURL(), platform); |
84 } | 84 } |
85 Availability IsAvailableToContext(const Extension* extension, | 85 Availability IsAvailableToContext(const Extension* extension, |
86 Context context, | 86 Context context, |
87 const GURL& url) const { | 87 const GURL& url) const { |
88 return IsAvailableToContext(extension, context, url, GetCurrentPlatform()); | 88 return IsAvailableToContext(extension, context, url, GetCurrentPlatform()); |
89 } | 89 } |
90 | 90 |
91 // extension::Feature: | 91 // extension::Feature: |
92 virtual Availability IsAvailableToManifest(const std::string& extension_id, | 92 Availability IsAvailableToManifest(const std::string& extension_id, |
93 Manifest::Type type, | 93 Manifest::Type type, |
94 Manifest::Location location, | 94 Manifest::Location location, |
95 int manifest_version, | 95 int manifest_version, |
96 Platform platform) const override; | 96 Platform platform) const override; |
97 | 97 |
98 virtual Availability IsAvailableToContext(const Extension* extension, | 98 Availability IsAvailableToContext(const Extension* extension, |
99 Context context, | 99 Context context, |
100 const GURL& url, | 100 const GURL& url, |
101 Platform platform) const override; | 101 Platform platform) const override; |
102 | 102 |
103 virtual std::string GetAvailabilityMessage(AvailabilityResult result, | 103 std::string GetAvailabilityMessage(AvailabilityResult result, |
104 Manifest::Type type, | 104 Manifest::Type type, |
105 const GURL& url, | 105 const GURL& url, |
106 Context context) const override; | 106 Context context) const override; |
107 | 107 |
108 virtual bool IsInternal() const override; | 108 bool IsInternal() const override; |
109 | 109 |
110 virtual bool IsIdInBlacklist(const std::string& extension_id) const override; | 110 bool IsIdInBlacklist(const std::string& extension_id) const override; |
111 virtual bool IsIdInWhitelist(const std::string& extension_id) const override; | 111 bool IsIdInWhitelist(const std::string& extension_id) const override; |
112 static bool IsIdInList(const std::string& extension_id, | 112 static bool IsIdInList(const std::string& extension_id, |
113 const std::set<std::string>& list); | 113 const std::set<std::string>& list); |
114 | 114 |
115 protected: | 115 protected: |
116 Availability CreateAvailability(AvailabilityResult result) const; | 116 Availability CreateAvailability(AvailabilityResult result) const; |
117 Availability CreateAvailability(AvailabilityResult result, | 117 Availability CreateAvailability(AvailabilityResult result, |
118 Manifest::Type type) const; | 118 Manifest::Type type) const; |
119 Availability CreateAvailability(AvailabilityResult result, | 119 Availability CreateAvailability(AvailabilityResult result, |
120 const GURL& url) const; | 120 const GURL& url) const; |
121 Availability CreateAvailability(AvailabilityResult result, | 121 Availability CreateAvailability(AvailabilityResult result, |
(...skipping 24 matching lines...) Expand all Loading... |
146 | 146 |
147 typedef std::vector<linked_ptr<SimpleFeatureFilter> > FilterList; | 147 typedef std::vector<linked_ptr<SimpleFeatureFilter> > FilterList; |
148 FilterList filters_; | 148 FilterList filters_; |
149 | 149 |
150 DISALLOW_COPY_AND_ASSIGN(SimpleFeature); | 150 DISALLOW_COPY_AND_ASSIGN(SimpleFeature); |
151 }; | 151 }; |
152 | 152 |
153 } // namespace extensions | 153 } // namespace extensions |
154 | 154 |
155 #endif // EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ | 155 #endif // EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ |
OLD | NEW |