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