1 // Copyright (c) 2013 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.
5 #include "chrome/common/extensions/permissions/chrome_api_permissions.h"
7 #include "chrome/grit/generated_resources.h"
8 #include "extensions/common/permissions/api_permission.h"
9 #include "extensions/common/permissions/api_permission_set.h"
10 #include "extensions/common/permissions/media_galleries_permission.h"
11 #include "extensions/common/permissions/permission_message.h"
12 #include "extensions/common/permissions/permissions_info.h"
13 #include "extensions/strings/grit/extensions_strings.h"
15 namespace extensions
{
19 const char kWindowsPermission
[] = "windows";
22 APIPermission
* CreateAPIPermission(const APIPermissionInfo
* permission
) {
23 return new T(permission
);
28 std::vector
<APIPermissionInfo
*> ChromeAPIPermissions::GetAllPermissions()
30 // WARNING: If you are modifying a permission message in this list, be sure to
31 // add the corresponding permission message rule to
32 // ChromePermissionMessageProvider::GetCoalescedPermissionMessages as well.
33 APIPermissionInfo::InitInfo permissions_to_register
[] = {
34 // Register permissions for all extension types.
35 {APIPermission::kBackground
, "background"},
36 {APIPermission::kDeclarativeContent
, "declarativeContent"},
37 {APIPermission::kDesktopCapture
, "desktopCapture"},
38 {APIPermission::kDesktopCapturePrivate
, "desktopCapturePrivate"},
39 {APIPermission::kDownloads
, "downloads"},
40 {APIPermission::kDownloadsOpen
, "downloads.open"},
41 {APIPermission::kDownloadsShelf
, "downloads.shelf"},
42 {APIPermission::kEasyUnlockPrivate
, "easyUnlockPrivate"},
43 {APIPermission::kIdentity
, "identity"},
44 {APIPermission::kIdentityEmail
, "identity.email"},
45 {APIPermission::kExperimental
, "experimental",
46 APIPermissionInfo::kFlagCannotBeOptional
},
47 {APIPermission::kEmbeddedExtensionOptions
, "embeddedExtensionOptions",
48 APIPermissionInfo::kFlagCannotBeOptional
},
49 {APIPermission::kGeolocation
, "geolocation",
50 APIPermissionInfo::kFlagCannotBeOptional
},
51 {APIPermission::kNotifications
, "notifications"},
52 {APIPermission::kGcdPrivate
, "gcdPrivate"},
53 {APIPermission::kGcm
, "gcm"},
54 {APIPermission::kNotificationProvider
, "notificationProvider"},
56 // Register extension permissions.
57 {APIPermission::kAccessibilityFeaturesModify
,
58 "accessibilityFeatures.modify"},
59 {APIPermission::kAccessibilityFeaturesRead
, "accessibilityFeatures.read"},
60 {APIPermission::kAccessibilityPrivate
, "accessibilityPrivate",
61 APIPermissionInfo::kFlagCannotBeOptional
},
62 {APIPermission::kActiveTab
, "activeTab"},
63 {APIPermission::kAudioModem
, "audioModem"},
64 {APIPermission::kBookmark
, "bookmarks"},
65 {APIPermission::kBrailleDisplayPrivate
, "brailleDisplayPrivate",
66 APIPermissionInfo::kFlagCannotBeOptional
},
67 {APIPermission::kBrowsingData
, "browsingData"},
68 {APIPermission::kContentSettings
, "contentSettings"},
69 {APIPermission::kContextMenus
, "contextMenus"},
70 {APIPermission::kCookie
, "cookies"},
71 {APIPermission::kCopresence
, "copresence"},
72 {APIPermission::kCopresencePrivate
, "copresencePrivate"},
73 {APIPermission::kCryptotokenPrivate
, "cryptotokenPrivate"},
74 {APIPermission::kDataReductionProxy
, "dataReductionProxy",
75 APIPermissionInfo::kFlagImpliesFullURLAccess
|
76 APIPermissionInfo::kFlagCannotBeOptional
},
77 {APIPermission::kEnterpriseDeviceAttributes
,
78 "enterprise.deviceAttributes"},
79 {APIPermission::kEnterprisePlatformKeys
, "enterprise.platformKeys"},
80 {APIPermission::kFileBrowserHandler
, "fileBrowserHandler",
81 APIPermissionInfo::kFlagCannotBeOptional
},
82 {APIPermission::kFontSettings
, "fontSettings",
83 APIPermissionInfo::kFlagCannotBeOptional
},
84 {APIPermission::kHistory
, "history"},
85 {APIPermission::kIdltest
, "idltest"},
86 {APIPermission::kInput
, "input"},
87 {APIPermission::kLocation
, "location",
88 APIPermissionInfo::kFlagCannotBeOptional
},
89 {APIPermission::kManagement
, "management"},
90 {APIPermission::kMDns
, "mdns", APIPermissionInfo::kFlagCannotBeOptional
},
91 {APIPermission::kNativeMessaging
, "nativeMessaging"},
92 {APIPermission::kPlatformKeys
, "platformKeys"},
93 {APIPermission::kPrivacy
, "privacy"},
94 {APIPermission::kProcesses
, "processes"},
95 {APIPermission::kSessions
, "sessions"},
96 {APIPermission::kSignedInDevices
, "signedInDevices"},
97 {APIPermission::kSyncFileSystem
, "syncFileSystem"},
98 {APIPermission::kTab
, "tabs"},
99 {APIPermission::kTopSites
, "topSites"},
100 {APIPermission::kTts
, "tts", APIPermissionInfo::kFlagCannotBeOptional
},
101 {APIPermission::kTtsEngine
, "ttsEngine",
102 APIPermissionInfo::kFlagCannotBeOptional
},
103 {APIPermission::kWallpaper
, "wallpaper",
104 APIPermissionInfo::kFlagCannotBeOptional
},
105 {APIPermission::kWebNavigation
, "webNavigation"},
107 // Register private permissions.
108 {APIPermission::kScreenlockPrivate
, "screenlockPrivate",
109 APIPermissionInfo::kFlagCannotBeOptional
},
110 {APIPermission::kActivityLogPrivate
, "activityLogPrivate",
111 APIPermissionInfo::kFlagCannotBeOptional
},
112 {APIPermission::kAutoTestPrivate
, "autotestPrivate",
113 APIPermissionInfo::kFlagCannotBeOptional
},
114 {APIPermission::kBookmarkManagerPrivate
, "bookmarkManagerPrivate",
115 APIPermissionInfo::kFlagCannotBeOptional
},
116 {APIPermission::kCast
, "cast", APIPermissionInfo::kFlagCannotBeOptional
},
117 {APIPermission::kChromeosInfoPrivate
, "chromeosInfoPrivate",
118 APIPermissionInfo::kFlagCannotBeOptional
},
119 {APIPermission::kCommandsAccessibility
, "commands.accessibility",
120 APIPermissionInfo::kFlagCannotBeOptional
},
121 {APIPermission::kCommandLinePrivate
, "commandLinePrivate",
122 APIPermissionInfo::kFlagCannotBeOptional
},
123 {APIPermission::kDeveloperPrivate
, "developerPrivate",
124 APIPermissionInfo::kFlagCannotBeOptional
},
125 {APIPermission::kDial
, "dial", APIPermissionInfo::kFlagCannotBeOptional
},
126 {APIPermission::kDownloadsInternal
, "downloadsInternal"},
127 {APIPermission::kExperienceSamplingPrivate
, "experienceSamplingPrivate",
128 APIPermissionInfo::kFlagCannotBeOptional
},
129 {APIPermission::kFileBrowserHandlerInternal
, "fileBrowserHandlerInternal",
130 APIPermissionInfo::kFlagCannotBeOptional
},
131 {APIPermission::kFileManagerPrivate
, "fileManagerPrivate",
132 APIPermissionInfo::kFlagCannotBeOptional
},
133 {APIPermission::kHotwordPrivate
, "hotwordPrivate",
134 APIPermissionInfo::kFlagCannotBeOptional
},
135 {APIPermission::kIdentityPrivate
, "identityPrivate",
136 APIPermissionInfo::kFlagCannotBeOptional
},
137 {APIPermission::kLogPrivate
, "logPrivate",
138 APIPermissionInfo::kFlagCannotBeOptional
},
139 {APIPermission::kWebcamPrivate
, "webcamPrivate"},
140 {APIPermission::kMediaPlayerPrivate
, "mediaPlayerPrivate",
141 APIPermissionInfo::kFlagCannotBeOptional
},
142 {APIPermission::kMediaRouterPrivate
, "mediaRouterPrivate",
143 APIPermissionInfo::kFlagCannotBeOptional
},
144 {APIPermission::kMetricsPrivate
, "metricsPrivate",
145 APIPermissionInfo::kFlagCannotBeOptional
},
146 {APIPermission::kMusicManagerPrivate
, "musicManagerPrivate",
147 APIPermissionInfo::kFlagCannotBeOptional
},
148 {APIPermission::kPreferencesPrivate
, "preferencesPrivate",
149 APIPermissionInfo::kFlagCannotBeOptional
},
150 {APIPermission::kSystemPrivate
, "systemPrivate",
151 APIPermissionInfo::kFlagCannotBeOptional
},
152 {APIPermission::kCloudPrintPrivate
, "cloudPrintPrivate",
153 APIPermissionInfo::kFlagCannotBeOptional
},
154 {APIPermission::kInputMethodPrivate
, "inputMethodPrivate",
155 APIPermissionInfo::kFlagCannotBeOptional
},
156 {APIPermission::kEchoPrivate
, "echoPrivate",
157 APIPermissionInfo::kFlagCannotBeOptional
},
158 {APIPermission::kFeedbackPrivate
, "feedbackPrivate",
159 APIPermissionInfo::kFlagCannotBeOptional
},
160 {APIPermission::kImageWriterPrivate
, "imageWriterPrivate",
161 APIPermissionInfo::kFlagCannotBeOptional
},
162 {APIPermission::kReadingListPrivate
, "readingListPrivate",
163 APIPermissionInfo::kFlagCannotBeOptional
},
164 {APIPermission::kRtcPrivate
, "rtcPrivate",
165 APIPermissionInfo::kFlagCannotBeOptional
},
166 {APIPermission::kTerminalPrivate
, "terminalPrivate",
167 APIPermissionInfo::kFlagCannotBeOptional
},
168 {APIPermission::kVirtualKeyboardPrivate
, "virtualKeyboardPrivate",
169 APIPermissionInfo::kFlagCannotBeOptional
},
170 {APIPermission::kWallpaperPrivate
, "wallpaperPrivate",
171 APIPermissionInfo::kFlagCannotBeOptional
},
172 {APIPermission::kWebstorePrivate
, "webstorePrivate",
173 APIPermissionInfo::kFlagCannotBeOptional
},
174 {APIPermission::kStreamsPrivate
, "streamsPrivate",
175 APIPermissionInfo::kFlagCannotBeOptional
},
176 {APIPermission::kEnterprisePlatformKeysPrivate
,
177 "enterprise.platformKeysPrivate",
178 APIPermissionInfo::kFlagCannotBeOptional
},
179 {APIPermission::kWebrtcAudioPrivate
, "webrtcAudioPrivate",
180 APIPermissionInfo::kFlagCannotBeOptional
},
181 {APIPermission::kWebrtcDesktopCapturePrivate
,
182 "webrtcDesktopCapturePrivate", APIPermissionInfo::kFlagCannotBeOptional
},
183 {APIPermission::kWebrtcLoggingPrivate
, "webrtcLoggingPrivate",
184 APIPermissionInfo::kFlagCannotBeOptional
},
185 {APIPermission::kPrincipalsPrivate
, "principalsPrivate",
186 APIPermissionInfo::kFlagCannotBeOptional
},
187 {APIPermission::kFirstRunPrivate
, "firstRunPrivate",
188 APIPermissionInfo::kFlagCannotBeOptional
},
189 {APIPermission::kInlineInstallPrivate
, "inlineInstallPrivate"},
190 {APIPermission::kSettingsPrivate
, "settingsPrivate",
191 APIPermissionInfo::kFlagCannotBeOptional
},
192 {APIPermission::kSearchEnginesPrivate
, "searchEnginesPrivate",
193 APIPermissionInfo::kFlagCannotBeOptional
},
194 {APIPermission::kAutofillPrivate
, "autofillPrivate",
195 APIPermissionInfo::kFlagCannotBeOptional
},
196 {APIPermission::kWebstoreWidgetPrivate
, "webstoreWidgetPrivate",
197 APIPermissionInfo::kFlagCannotBeOptional
},
198 {APIPermission::kPasswordsPrivate
, "passwordsPrivate",
199 APIPermissionInfo::kFlagCannotBeOptional
},
200 {APIPermission::kUsersPrivate
, "usersPrivate",
201 APIPermissionInfo::kFlagCannotBeOptional
},
202 {APIPermission::kLanguageSettingsPrivate
, "languageSettingsPrivate",
203 APIPermissionInfo::kFlagCannotBeOptional
},
205 // Full url access permissions.
206 {APIPermission::kDebugger
, "debugger",
207 APIPermissionInfo::kFlagImpliesFullURLAccess
|
208 APIPermissionInfo::kFlagCannotBeOptional
},
209 {APIPermission::kDevtools
, "devtools",
210 APIPermissionInfo::kFlagImpliesFullURLAccess
|
211 APIPermissionInfo::kFlagCannotBeOptional
|
212 APIPermissionInfo::kFlagInternal
},
213 {APIPermission::kPageCapture
, "pageCapture",
214 APIPermissionInfo::kFlagImpliesFullURLAccess
},
215 {APIPermission::kTabCapture
, "tabCapture",
216 APIPermissionInfo::kFlagImpliesFullURLAccess
},
217 {APIPermission::kTabCaptureForTab
, "tabCaptureForTab",
218 APIPermissionInfo::kFlagInternal
},
219 {APIPermission::kPlugin
, "plugin",
220 APIPermissionInfo::kFlagImpliesFullURLAccess
|
221 APIPermissionInfo::kFlagImpliesFullAccess
|
222 APIPermissionInfo::kFlagCannotBeOptional
|
223 APIPermissionInfo::kFlagInternal
},
224 {APIPermission::kProxy
, "proxy",
225 APIPermissionInfo::kFlagImpliesFullURLAccess
|
226 APIPermissionInfo::kFlagCannotBeOptional
},
228 // Platform-app permissions.
230 // The permission string for "fileSystem" is only shown when
231 // "write" or "directory" is present. Read-only access is only
232 // granted after the user has been shown a file or directory
233 // chooser dialog and selected a file or directory. Selecting
234 // the file or directory is considered consent to read it.
235 {APIPermission::kFileSystem
, "fileSystem"},
236 {APIPermission::kFileSystemDirectory
, "fileSystem.directory"},
237 {APIPermission::kFileSystemProvider
, "fileSystemProvider"},
238 {APIPermission::kFileSystemRequestFileSystem
,
239 "fileSystem.requestFileSystem"},
240 {APIPermission::kFileSystemRetainEntries
, "fileSystem.retainEntries"},
241 {APIPermission::kFileSystemWrite
, "fileSystem.write"},
242 {APIPermission::kFileSystemWriteDirectory
, "fileSystem.writeDirectory"},
243 {APIPermission::kMediaGalleries
, "mediaGalleries",
244 APIPermissionInfo::kFlagNone
,
245 &CreateAPIPermission
<MediaGalleriesPermission
>},
246 {APIPermission::kPointerLock
, "pointerLock"},
247 {APIPermission::kCastStreaming
, "cast.streaming"},
248 {APIPermission::kBrowser
, "browser"},
249 {APIPermission::kInterceptAllKeys
, "app.window.interceptAllKeys"},
250 {APIPermission::kLauncherSearchProvider
, "launcherSearchProvider"},
252 // Settings override permissions.
253 {APIPermission::kHomepage
, "homepage",
254 APIPermissionInfo::kFlagCannotBeOptional
|
255 APIPermissionInfo::kFlagInternal
},
256 {APIPermission::kSearchProvider
, "searchProvider",
257 APIPermissionInfo::kFlagCannotBeOptional
|
258 APIPermissionInfo::kFlagInternal
},
259 {APIPermission::kStartupPages
, "startupPages",
260 APIPermissionInfo::kFlagCannotBeOptional
|
261 APIPermissionInfo::kFlagInternal
},
264 std::vector
<APIPermissionInfo
*> permissions
;
266 for (size_t i
= 0; i
< arraysize(permissions_to_register
); ++i
)
267 permissions
.push_back(new APIPermissionInfo(permissions_to_register
[i
]));
271 std::vector
<PermissionsProvider::AliasInfo
>
272 ChromeAPIPermissions::GetAllAliases() const {
274 std::vector
<PermissionsProvider::AliasInfo
> aliases
;
275 aliases
.push_back(PermissionsProvider::AliasInfo("tabs", kWindowsPermission
));
279 } // namespace extensions