OLD | NEW |
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_FEATURES_SIMPLE_FEATURE_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_ |
6 #define CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_ | 6 #define CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 min_manifest_version_ = min_manifest_version; | 47 min_manifest_version_ = min_manifest_version; |
48 } | 48 } |
49 | 49 |
50 int max_manifest_version() const { return max_manifest_version_; } | 50 int max_manifest_version() const { return max_manifest_version_; } |
51 void set_max_manifest_version(int max_manifest_version) { | 51 void set_max_manifest_version(int max_manifest_version) { |
52 max_manifest_version_ = max_manifest_version; | 52 max_manifest_version_ = max_manifest_version; |
53 } | 53 } |
54 | 54 |
55 Availability IsAvailableToContext(const Extension* extension, | 55 Availability IsAvailableToContext(const Extension* extension, |
56 Context context) const { | 56 Context context) const { |
57 return IsAvailableToContext(extension, context, GetCurrentPlatform()); | 57 return IsAvailableToContext(extension, context, GURL()); |
| 58 } |
| 59 Availability IsAvailableToContext(const Extension* extension, |
| 60 Context context, |
| 61 Platform platform) const { |
| 62 return IsAvailableToContext(extension, context, GURL(), platform); |
| 63 } |
| 64 Availability IsAvailableToContext(const Extension* extension, |
| 65 Context context, |
| 66 const GURL& url) const { |
| 67 return IsAvailableToContext(extension, context, url, GetCurrentPlatform()); |
58 } | 68 } |
59 | 69 |
60 // extension::Feature: | 70 // extension::Feature: |
61 virtual Availability IsAvailableToManifest(const std::string& extension_id, | 71 virtual Availability IsAvailableToManifest(const std::string& extension_id, |
62 Manifest::Type type, | 72 Manifest::Type type, |
63 Location location, | 73 Location location, |
64 int manifest_version, | 74 int manifest_version, |
65 Platform platform) const OVERRIDE; | 75 Platform platform) const OVERRIDE; |
66 | 76 |
67 virtual Availability IsAvailableToContext(const Extension* extension, | 77 virtual Availability IsAvailableToContext(const Extension* extension, |
68 Context context, | 78 Context context, |
| 79 const GURL& url, |
69 Platform platform) const OVERRIDE; | 80 Platform platform) const OVERRIDE; |
70 | 81 |
71 virtual std::string GetAvailabilityMessage( | 82 virtual std::string GetAvailabilityMessage(AvailabilityResult result, |
72 AvailabilityResult result, Manifest::Type type) const OVERRIDE; | 83 Manifest::Type type, |
| 84 const GURL& url) const OVERRIDE; |
73 | 85 |
74 virtual std::set<Context>* GetContexts() OVERRIDE; | 86 virtual std::set<Context>* GetContexts() OVERRIDE; |
75 | 87 |
76 protected: | 88 protected: |
77 Availability CreateAvailability(AvailabilityResult result) const; | 89 Availability CreateAvailability(AvailabilityResult result) const; |
78 Availability CreateAvailability(AvailabilityResult result, | 90 Availability CreateAvailability(AvailabilityResult result, |
79 Manifest::Type type) const; | 91 Manifest::Type type) const; |
| 92 Availability CreateAvailability(AvailabilityResult result, |
| 93 const GURL& url) const; |
80 bool IsIdInWhitelist(const std::string& extension_id) const; | 94 bool IsIdInWhitelist(const std::string& extension_id) const; |
81 | 95 |
82 private: | 96 private: |
83 // For clarity and consistency, we handle the default value of each of these | 97 // For clarity and consistency, we handle the default value of each of these |
84 // members the same way: it matches everything. It is up to the higher level | 98 // members the same way: it matches everything. It is up to the higher level |
85 // code that reads Features out of static data to validate that data and set | 99 // code that reads Features out of static data to validate that data and set |
86 // sensible defaults. | 100 // sensible defaults. |
87 std::set<std::string> whitelist_; | 101 std::set<std::string> whitelist_; |
88 std::set<Manifest::Type> extension_types_; | 102 std::set<Manifest::Type> extension_types_; |
89 std::set<Context> contexts_; | 103 std::set<Context> contexts_; |
| 104 URLPatternSet matches_; |
90 Location location_; // we only care about component/not-component now | 105 Location location_; // we only care about component/not-component now |
91 Platform platform_; // we only care about chromeos/not-chromeos now | 106 Platform platform_; // we only care about chromeos/not-chromeos now |
92 int min_manifest_version_; | 107 int min_manifest_version_; |
93 int max_manifest_version_; | 108 int max_manifest_version_; |
94 chrome::VersionInfo::Channel channel_; | 109 chrome::VersionInfo::Channel channel_; |
95 | 110 |
96 FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, Context); | 111 FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, Context); |
97 }; | 112 }; |
98 | 113 |
99 } // namespace extensions | 114 } // namespace extensions |
100 | 115 |
101 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_ | 116 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_ |
OLD | NEW |