Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: extensions/common/features/feature.h

Issue 241673002: Support a "policy" extension location in extension features files. At the same (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: format Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_FEATURE_H_ 5 #ifndef EXTENSIONS_COMMON_FEATURES_FEATURE_H_
6 #define EXTENSIONS_COMMON_FEATURES_FEATURE_H_ 6 #define EXTENSIONS_COMMON_FEATURES_FEATURE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 28 matching lines...) Expand all
39 39
40 // A normal web page. This should have an associated URL matching pattern. 40 // A normal web page. This should have an associated URL matching pattern.
41 WEB_PAGE_CONTEXT, 41 WEB_PAGE_CONTEXT,
42 42
43 // A web page context which has been blessed by the user. Typically this 43 // A web page context which has been blessed by the user. Typically this
44 // will be via the installation of a hosted app, so this may host an 44 // will be via the installation of a hosted app, so this may host an
45 // extension. This is not affected by the URL matching pattern. 45 // extension. This is not affected by the URL matching pattern.
46 BLESSED_WEB_PAGE_CONTEXT, 46 BLESSED_WEB_PAGE_CONTEXT,
47 }; 47 };
48 48
49 // The location required of extensions the feature is supported in.
50 enum Location {
51 UNSPECIFIED_LOCATION,
52 COMPONENT_LOCATION
53 };
54
55 // The platforms the feature is supported in. 49 // The platforms the feature is supported in.
56 enum Platform { 50 enum Platform {
57 UNSPECIFIED_PLATFORM, 51 UNSPECIFIED_PLATFORM,
58 CHROMEOS_PLATFORM, 52 CHROMEOS_PLATFORM,
59 LINUX_PLATFORM, 53 LINUX_PLATFORM,
60 MACOSX_PLATFORM, 54 MACOSX_PLATFORM,
61 WIN_PLATFORM 55 WIN_PLATFORM
62 }; 56 };
63 57
64 // Whether a feature is available in a given situation or not, and if not, 58 // Whether a feature is available in a given situation or not, and if not,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 const std::string& message); 99 const std::string& message);
106 100
107 const std::string& name() const { return name_; } 101 const std::string& name() const { return name_; }
108 void set_name(const std::string& name) { name_ = name; } 102 void set_name(const std::string& name) { name_ = name; }
109 const std::set<std::string>& dependencies() const { return dependencies_; } 103 const std::set<std::string>& dependencies() const { return dependencies_; }
110 bool no_parent() const { return no_parent_; } 104 bool no_parent() const { return no_parent_; }
111 105
112 // Gets the platform the code is currently running on. 106 // Gets the platform the code is currently running on.
113 static Platform GetCurrentPlatform(); 107 static Platform GetCurrentPlatform();
114 108
115 // Gets the Feature::Location value for the specified Manifest::Location.
116 static Location ConvertLocation(Manifest::Location extension_location);
117
118 virtual std::set<Context>* GetContexts() = 0; 109 virtual std::set<Context>* GetContexts() = 0;
119 110
120 // Tests whether this is an internal API or not. 111 // Tests whether this is an internal API or not.
121 virtual bool IsInternal() const = 0; 112 virtual bool IsInternal() const = 0;
122 113
123 // Returns True for features excluded from service worker backed contexts. 114 // Returns True for features excluded from service worker backed contexts.
124 virtual bool IsBlockedInServiceWorker() const = 0; 115 virtual bool IsBlockedInServiceWorker() const = 0;
125 116
126 // Returns true if the feature is available to be parsed into a new extension 117 // Returns true if the feature is available to be parsed into a new extension
127 // manifest. 118 // manifest.
128 Availability IsAvailableToManifest(const std::string& extension_id, 119 Availability IsAvailableToManifest(const std::string& extension_id,
129 Manifest::Type type, 120 Manifest::Type type,
130 Location location, 121 Manifest::Location location,
131 int manifest_version) const { 122 int manifest_version) const {
132 return IsAvailableToManifest(extension_id, type, location, manifest_version, 123 return IsAvailableToManifest(extension_id, type, location, manifest_version,
133 GetCurrentPlatform()); 124 GetCurrentPlatform());
134 } 125 }
135 virtual Availability IsAvailableToManifest(const std::string& extension_id, 126 virtual Availability IsAvailableToManifest(const std::string& extension_id,
136 Manifest::Type type, 127 Manifest::Type type,
137 Location location, 128 Manifest::Location location,
138 int manifest_version, 129 int manifest_version,
139 Platform platform) const = 0; 130 Platform platform) const = 0;
140 131
132 // Returns true if the feature is available to |extension|.
133 Availability IsAvailableToExtension(const Extension* extension);
not at google - send to devlin 2014/04/17 21:33:14 always irritated me that we don't have this.
134
141 // Returns true if the feature is available to be used in the specified 135 // Returns true if the feature is available to be used in the specified
142 // extension and context. 136 // extension and context.
143 Availability IsAvailableToContext(const Extension* extension, 137 Availability IsAvailableToContext(const Extension* extension,
144 Context context, 138 Context context,
145 const GURL& url) const { 139 const GURL& url) const {
146 return IsAvailableToContext(extension, context, url, GetCurrentPlatform()); 140 return IsAvailableToContext(extension, context, url, GetCurrentPlatform());
147 } 141 }
148 virtual Availability IsAvailableToContext(const Extension* extension, 142 virtual Availability IsAvailableToContext(const Extension* extension,
149 Context context, 143 Context context,
150 const GURL& url, 144 const GURL& url,
151 Platform platform) const = 0; 145 Platform platform) const = 0;
152 146
153 virtual std::string GetAvailabilityMessage(AvailabilityResult result, 147 virtual std::string GetAvailabilityMessage(AvailabilityResult result,
154 Manifest::Type type, 148 Manifest::Type type,
155 const GURL& url, 149 const GURL& url,
156 Context context) const = 0; 150 Context context) const = 0;
157 151
158 virtual bool IsIdInWhitelist(const std::string& extension_id) const = 0; 152 virtual bool IsIdInWhitelist(const std::string& extension_id) const = 0;
159 153
160 protected: 154 protected:
161 std::string name_; 155 std::string name_;
162 std::set<std::string> dependencies_; 156 std::set<std::string> dependencies_;
163 bool no_parent_; 157 bool no_parent_;
164 }; 158 };
165 159
166 } // namespace extensions 160 } // namespace extensions
167 161
168 #endif // EXTENSIONS_COMMON_FEATURES_FEATURE_H_ 162 #endif // EXTENSIONS_COMMON_FEATURES_FEATURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698