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

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

Issue 2241203003: Pass user session type to extension feature checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split out some stuff Created 4 years, 4 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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // extension. This is not affected by the URL matching pattern. 46 // extension. This is not affected by the URL matching pattern.
47 BLESSED_WEB_PAGE_CONTEXT, 47 BLESSED_WEB_PAGE_CONTEXT,
48 48
49 // A page within webui. 49 // A page within webui.
50 WEBUI_CONTEXT, 50 WEBUI_CONTEXT,
51 51
52 // A context belonging to a service worker. 52 // A context belonging to a service worker.
53 SERVICE_WORKER_CONTEXT, 53 SERVICE_WORKER_CONTEXT,
54 }; 54 };
55 55
56 // Classes of session types to which features can be restricted in feature
57 // files. The session type describes session based on the type of user that is
58 // active in the current session.
59 enum SessionType {
60 SESSION_TYPE_UNSPECIFIED,
61 // Regular session, i.e. non kiosk app.
62 SESSION_TYPE_REGULAR,
63 // Kiosk app session.
64 SESSION_TYPE_KIOSK,
65 // Helper for determining max enum value - not used as a real type.
66 SESSION_TYPE_MAX = SESSION_TYPE_KIOSK
67 };
68
56 // The platforms the feature is supported in. 69 // The platforms the feature is supported in.
57 enum Platform { 70 enum Platform {
58 UNSPECIFIED_PLATFORM, 71 UNSPECIFIED_PLATFORM,
59 CHROMEOS_PLATFORM, 72 CHROMEOS_PLATFORM,
60 LINUX_PLATFORM, 73 LINUX_PLATFORM,
61 MACOSX_PLATFORM, 74 MACOSX_PLATFORM,
62 WIN_PLATFORM 75 WIN_PLATFORM
63 }; 76 };
64 77
65 // Whether a feature is available in a given situation or not, and if not, 78 // Whether a feature is available in a given situation or not, and if not,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 int manifest_version, 142 int manifest_version,
130 Platform platform) const = 0; 143 Platform platform) const = 0;
131 144
132 // Returns true if the feature is available to |extension|. 145 // Returns true if the feature is available to |extension|.
133 Availability IsAvailableToExtension(const Extension* extension) const; 146 Availability IsAvailableToExtension(const Extension* extension) const;
134 147
135 // Returns true if the feature is available to be used in the specified 148 // Returns true if the feature is available to be used in the specified
136 // extension and context. 149 // extension and context.
137 Availability IsAvailableToContext(const Extension* extension, 150 Availability IsAvailableToContext(const Extension* extension,
138 Context context, 151 Context context,
152 SessionType session_type,
139 const GURL& url) const { 153 const GURL& url) const {
140 return IsAvailableToContext(extension, context, url, GetCurrentPlatform()); 154 return IsAvailableToContext(extension, context, session_type, url,
155 GetCurrentPlatform());
141 } 156 }
142 virtual Availability IsAvailableToContext(const Extension* extension, 157 virtual Availability IsAvailableToContext(const Extension* extension,
143 Context context, 158 Context context,
159 SessionType session_type,
144 const GURL& url, 160 const GURL& url,
145 Platform platform) const = 0; 161 Platform platform) const = 0;
146 162
147 // Returns true if the feature is available to the current environment, 163 // Returns true if the feature is available to the current environment,
148 // without needing to know information about an Extension or any other 164 // without needing to know information about an Extension or any other
149 // contextual information. Typically used when the Feature is purely 165 // contextual information. Typically used when the Feature is purely
150 // configured by command line flags and/or Chrome channel. 166 // configured by command line flags and/or Chrome channel.
151 // 167 //
152 // Generally try not to use this function. Even if you don't think a Feature 168 // Generally try not to use this function. Even if you don't think a Feature
153 // relies on an Extension now - maybe it will, one day, so if there's an 169 // relies on an Extension now - maybe it will, one day, so if there's an
154 // Extension available (or a runtime context, etc) then use the more targeted 170 // Extension available (or a runtime context, etc) then use the more targeted
155 // method instead. 171 // method instead.
156 Availability IsAvailableToEnvironment() const; 172 Availability IsAvailableToEnvironment() const;
157 173
158 virtual bool IsIdInBlacklist(const std::string& extension_id) const = 0; 174 virtual bool IsIdInBlacklist(const std::string& extension_id) const = 0;
159 virtual bool IsIdInWhitelist(const std::string& extension_id) const = 0; 175 virtual bool IsIdInWhitelist(const std::string& extension_id) const = 0;
160 176
161 void set_check_channel(bool check_channel) { check_channel_ = check_channel; } 177 void set_check_channel(bool check_channel) { check_channel_ = check_channel; }
162 178
163 protected: 179 protected:
164 std::string name_; 180 std::string name_;
165 bool no_parent_; 181 bool no_parent_;
166 // TODO(devlin): Remove this once we set the feature channel for tests. 182 // TODO(devlin): Remove this once we set the feature channel for tests.
167 bool check_channel_; 183 bool check_channel_;
168 }; 184 };
169 185
170 } // namespace extensions 186 } // namespace extensions
171 187
172 #endif // EXTENSIONS_COMMON_FEATURES_FEATURE_H_ 188 #endif // EXTENSIONS_COMMON_FEATURES_FEATURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698