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

Side by Side Diff: chrome/common/extensions/permissions/api_permission.h

Issue 13947050: Stop forcing optional permission on usbDevices section (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove APIPermissionInfo::kFlagMustBeOptional and related tests. Created 7 years, 7 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 (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_PERMISSIONS_API_PERMISSION_H_ 5 #ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_API_PERMISSION_H_
6 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_API_PERMISSION_H_ 6 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_API_PERMISSION_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 enum Flag { 214 enum Flag {
215 kFlagNone = 0, 215 kFlagNone = 0,
216 216
217 // Indicates if the permission implies full access (native code). 217 // Indicates if the permission implies full access (native code).
218 kFlagImpliesFullAccess = 1 << 0, 218 kFlagImpliesFullAccess = 1 << 0,
219 219
220 // Indicates if the permission implies full URL access. 220 // Indicates if the permission implies full URL access.
221 kFlagImpliesFullURLAccess = 1 << 1, 221 kFlagImpliesFullURLAccess = 1 << 1,
222 222
223 // Indicates that extensions cannot specify the permission as optional. 223 // Indicates that extensions cannot specify the permission as optional.
224 kFlagCannotBeOptional = 1 << 3, 224 kFlagCannotBeOptional = 1 << 3
225
226 // Indicates that extensions must specify the permission as optional.
227 kFlagMustBeOptional = 1 << 4
228 }; 225 };
229 226
230 typedef APIPermission* (*APIPermissionConstructor)(const APIPermissionInfo*); 227 typedef APIPermission* (*APIPermissionConstructor)(const APIPermissionInfo*);
231 228
232 typedef std::set<APIPermission::ID> IDSet; 229 typedef std::set<APIPermission::ID> IDSet;
233 230
234 ~APIPermissionInfo(); 231 ~APIPermissionInfo();
235 232
236 // Creates a APIPermission instance. 233 // Creates a APIPermission instance.
237 APIPermission* CreateAPIPermission() const; 234 APIPermission* CreateAPIPermission() const;
(...skipping 19 matching lines...) Expand all
257 bool implies_full_url_access() const { 254 bool implies_full_url_access() const {
258 return (flags_ & kFlagImpliesFullURLAccess) != 0; 255 return (flags_ & kFlagImpliesFullURLAccess) != 0;
259 } 256 }
260 257
261 // Returns true if this permission can be added and removed via the 258 // Returns true if this permission can be added and removed via the
262 // optional permissions extension API. 259 // optional permissions extension API.
263 bool supports_optional() const { 260 bool supports_optional() const {
264 return (flags_ & kFlagCannotBeOptional) == 0; 261 return (flags_ & kFlagCannotBeOptional) == 0;
265 } 262 }
266 263
267 // Returns true if this permission must be added and removed via the
268 // optional permissions extension API.
269 bool must_be_optional() const {
270 return (flags_ & kFlagMustBeOptional) != 0;
271 }
272
273 private: 264 private:
274 // Instances should only be constructed from within a 265 // Instances should only be constructed from within a
275 // PermissionsInfo::Delegate. 266 // PermissionsInfo::Delegate.
276 friend class ChromeAPIPermissions; 267 friend class ChromeAPIPermissions;
277 // Implementations of APIPermission will want to get the permission message, 268 // Implementations of APIPermission will want to get the permission message,
278 // but this class's implementation should be hidden from everyone else. 269 // but this class's implementation should be hidden from everyone else.
279 friend class APIPermission; 270 friend class APIPermission;
280 271
281 explicit APIPermissionInfo( 272 explicit APIPermissionInfo(
282 APIPermission::ID id, 273 APIPermission::ID id,
(...skipping 11 matching lines...) Expand all
294 const char* const name_; 285 const char* const name_;
295 const int flags_; 286 const int flags_;
296 const int l10n_message_id_; 287 const int l10n_message_id_;
297 const PermissionMessage::ID message_id_; 288 const PermissionMessage::ID message_id_;
298 const APIPermissionConstructor api_permission_constructor_; 289 const APIPermissionConstructor api_permission_constructor_;
299 }; 290 };
300 291
301 } // namespace extensions 292 } // namespace extensions
302 293
303 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_API_PERMISSION_H_ 294 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_API_PERMISSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698