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

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

Issue 10649003: Move each permission classes to its own files in extensions/permissions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase on HEAD Created 8 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_API_PERMISSION_H_
6 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_API_PERMISSION_H_
7 #pragma once
8
9 #include <set>
10
11 #include "chrome/common/extensions/permissions/permission_message.h"
12
13 namespace extensions {
14
15 class PermissionsInfo;
16
17 // The APIPermission is an immutable class that describes a single
18 // named permission (API permission).
19 class APIPermission {
20 public:
21 enum ID {
22 // Error codes.
23 kInvalid = -2,
24 kUnknown = -1,
25
26 // Real permissions.
27 kActiveTab,
28 kAlarms,
29 kAppNotifications,
30 kAppWindow,
31 kAudioCapture,
32 kBackground,
33 kBookmark,
34 kBrowsingData,
35 kChromeAuthPrivate,
36 kChromeosInfoPrivate,
37 kClipboardRead,
38 kClipboardWrite,
39 kContentSettings,
40 kContextMenus,
41 kCookie,
42 kDebugger,
43 kDeclarative,
44 kDeclarativeWebRequest,
45 kDevtools,
46 kEchoPrivate,
47 kDownloads,
48 kExperimental,
49 kFileBrowserHandler,
50 kFileBrowserHandlerInternal,
51 kFileBrowserPrivate,
52 kFileSystem,
53 kGeolocation,
54 kHistory,
55 kIdle,
56 kInput,
57 kInputMethodPrivate,
58 kKeybinding,
59 kManagedModePrivate,
60 kManagement,
61 kMediaPlayerPrivate,
62 kMetricsPrivate,
63 kNotification,
64 kPageCapture,
65 kPlugin,
66 kPrivacy,
67 kProxy,
68 kSocket,
69 kStorage,
70 kSystemPrivate,
71 kTab,
72 kTerminalPrivate,
73 kTopSites,
74 kTts,
75 kTtsEngine,
76 kUnlimitedStorage,
77 kUsb,
78 kVideoCapture,
79 kWebNavigation,
80 kWebRequest,
81 kWebRequestBlocking,
82 kWebRequestInternal,
83 kWebSocketProxyPrivate,
84 kWebstorePrivate,
85 kEnumBoundary
86 };
87
88 enum Flag {
89 kFlagNone = 0,
90
91 // Indicates if the permission implies full access (native code).
92 kFlagImpliesFullAccess = 1 << 0,
93
94 // Indicates if the permission implies full URL access.
95 kFlagImpliesFullURLAccess = 1 << 1,
96
97 // Indicates that extensions cannot specify the permission as optional.
98 kFlagCannotBeOptional = 1 << 3
99 };
100
101 typedef std::set<ID> IDSet;
102
103 ~APIPermission();
104
105 // Returns the localized permission message associated with this api.
106 PermissionMessage GetMessage() const;
107
108 int flags() const { return flags_; }
109
110 ID id() const { return id_; }
111
112 // Returns the message id associated with this permission.
113 PermissionMessage::ID message_id() const {
114 return message_id_;
115 }
116
117 // Returns the name of this permission.
118 const char* name() const { return name_; }
119
120 // Returns true if this permission implies full access (e.g., native code).
121 bool implies_full_access() const {
122 return (flags_ & kFlagImpliesFullAccess) != 0;
123 }
124
125 // Returns true if this permission implies full URL access.
126 bool implies_full_url_access() const {
127 return (flags_ & kFlagImpliesFullURLAccess) != 0;
128 }
129
130 // Returns true if this permission can be added and removed via the
131 // optional permissions extension API.
132 bool supports_optional() const {
133 return (flags_ & kFlagCannotBeOptional) == 0;
134 }
135
136 private:
137 // Instances should only be constructed from within PermissionsInfo.
138 friend class PermissionsInfo;
139
140 explicit APIPermission(
141 ID id,
142 const char* name,
143 int l10n_message_id,
144 PermissionMessage::ID message_id,
145 int flags);
146
147 // Register ALL the permissions!
148 static void RegisterAllPermissions(PermissionsInfo* info);
149
150 ID id_;
151 const char* name_;
152 int flags_;
153 int l10n_message_id_;
154 PermissionMessage::ID message_id_;
155 };
156
157 typedef std::set<APIPermission::ID> APIPermissionSet;
158
159 } // namespace extensions
160
161 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_API_PERMISSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698