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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 void set_min_manifest_version(int min_manifest_version) { | 46 void set_min_manifest_version(int min_manifest_version) { |
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, |
57 return IsAvailableToContext(extension, context, GetCurrentPlatform()); | 57 const GURL& url) const { |
| 58 return IsAvailableToContext(extension, context, url, GetCurrentPlatform()); |
58 } | 59 } |
59 | 60 |
60 // extension::Feature: | 61 // extension::Feature: |
61 virtual Availability IsAvailableToManifest(const std::string& extension_id, | 62 virtual Availability IsAvailableToManifest(const std::string& extension_id, |
62 Manifest::Type type, | 63 Manifest::Type type, |
63 Location location, | 64 Location location, |
64 int manifest_version, | 65 int manifest_version, |
65 Platform platform) const OVERRIDE; | 66 Platform platform) const OVERRIDE; |
66 | 67 |
67 virtual Availability IsAvailableToContext(const Extension* extension, | 68 virtual Availability IsAvailableToContext(const Extension* extension, |
68 Context context, | 69 Context context, |
| 70 const GURL& url, |
69 Platform platform) const OVERRIDE; | 71 Platform platform) const OVERRIDE; |
70 | 72 |
71 virtual std::string GetAvailabilityMessage( | 73 virtual std::string GetAvailabilityMessage( |
72 AvailabilityResult result, Manifest::Type type) const OVERRIDE; | 74 AvailabilityResult result, Manifest::Type type) const OVERRIDE; |
73 | 75 |
74 virtual std::set<Context>* GetContexts() OVERRIDE; | 76 virtual std::set<Context>* GetContexts() OVERRIDE; |
75 | 77 |
76 protected: | 78 protected: |
77 Availability CreateAvailability(AvailabilityResult result) const; | 79 Availability CreateAvailability(AvailabilityResult result) const; |
78 Availability CreateAvailability(AvailabilityResult result, | 80 Availability CreateAvailability(AvailabilityResult result, |
79 Manifest::Type type) const; | 81 Manifest::Type type) const; |
80 bool IsIdInWhitelist(const std::string& extension_id) const; | 82 bool IsIdInWhitelist(const std::string& extension_id) const; |
81 | 83 |
82 private: | 84 private: |
83 // For clarity and consistency, we handle the default value of each of these | 85 // 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 | 86 // 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 | 87 // code that reads Features out of static data to validate that data and set |
86 // sensible defaults. | 88 // sensible defaults. |
87 std::set<std::string> whitelist_; | 89 std::set<std::string> whitelist_; |
88 std::set<Manifest::Type> extension_types_; | 90 std::set<Manifest::Type> extension_types_; |
89 std::set<Context> contexts_; | 91 std::set<Context> contexts_; |
| 92 URLPatternSet matches_; |
90 Location location_; // we only care about component/not-component now | 93 Location location_; // we only care about component/not-component now |
91 Platform platform_; // we only care about chromeos/not-chromeos now | 94 Platform platform_; // we only care about chromeos/not-chromeos now |
92 int min_manifest_version_; | 95 int min_manifest_version_; |
93 int max_manifest_version_; | 96 int max_manifest_version_; |
94 chrome::VersionInfo::Channel channel_; | 97 chrome::VersionInfo::Channel channel_; |
95 | 98 |
96 FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, Context); | 99 FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, Context); |
97 }; | 100 }; |
98 | 101 |
99 } // namespace extensions | 102 } // namespace extensions |
100 | 103 |
101 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_ | 104 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_ |
OLD | NEW |