Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / extensions / common / permissions / extensions_api_permissions.cc
blobc9eb11b5e7944e4f9ac16f03ac1f6f5d7f416adf
1 // Copyright 2014 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 "extensions/common/permissions/extensions_api_permissions.h"
7 #include <vector>
9 #include "extensions/common/permissions/api_permission.h"
10 #include "extensions/common/permissions/socket_permission.h"
11 #include "extensions/common/permissions/usb_device_permission.h"
12 #include "grit/extensions_strings.h"
14 namespace extensions {
16 namespace {
18 const char kOldAlwaysOnTopWindowsPermission[] = "alwaysOnTopWindows";
19 const char kOldFullscreenPermission[] = "fullscreen";
20 const char kOldOverrideEscFullscreenPermission[] = "overrideEscFullscreen";
21 const char kOldUnlimitedStoragePermission[] = "unlimited_storage";
23 template <typename T>
24 APIPermission* CreateAPIPermission(const APIPermissionInfo* permission) {
25 return new T(permission);
28 } // namespace
30 std::vector<APIPermissionInfo*> ExtensionsAPIPermissions::GetAllPermissions()
31 const {
32 // WARNING: If you are modifying a permission message in this list, be sure to
33 // add the corresponding permission message rule to
34 // ChromePermissionMessageProvider::GetCoalescedPermissionMessages as well.
35 APIPermissionInfo::InitInfo permissions_to_register[] = {
36 {APIPermission::kAlarms, "alarms"},
37 {APIPermission::kAlphaEnabled, "app.window.alpha"},
38 {APIPermission::kAlwaysOnTopWindows, "app.window.alwaysOnTop"},
39 {APIPermission::kAppView,
40 "appview",
41 APIPermissionInfo::kFlagCannotBeOptional},
42 {APIPermission::kAudio, "audio"},
43 {APIPermission::kAudioCapture, "audioCapture"},
44 {APIPermission::kBluetoothPrivate,
45 "bluetoothPrivate",
46 APIPermissionInfo::kFlagCannotBeOptional},
47 {APIPermission::kClipboardRead,
48 "clipboardRead",
49 APIPermissionInfo::kFlagSupportsContentCapabilities},
50 {APIPermission::kClipboardWrite,
51 "clipboardWrite",
52 APIPermissionInfo::kFlagSupportsContentCapabilities},
53 {APIPermission::kDeclarativeWebRequest, "declarativeWebRequest"},
54 {APIPermission::kDiagnostics,
55 "diagnostics",
56 APIPermissionInfo::kFlagCannotBeOptional},
57 {APIPermission::kDns, "dns"},
58 {APIPermission::kDocumentScan, "documentScan"},
59 {APIPermission::kExtensionView,
60 "extensionview",
61 APIPermissionInfo::kFlagCannotBeOptional},
62 {APIPermission::kExternallyConnectableAllUrls,
63 "externally_connectable.all_urls"},
64 {APIPermission::kFullscreen, "app.window.fullscreen"},
65 {APIPermission::kHid, "hid"},
66 {APIPermission::kImeWindowEnabled, "app.window.ime"},
67 {APIPermission::kOverrideEscFullscreen,
68 "app.window.fullscreen.overrideEsc"},
69 {APIPermission::kIdle, "idle"},
70 {APIPermission::kNetworkingConfig, "networking.config"},
71 {APIPermission::kNetworkingPrivate,
72 "networkingPrivate",
73 APIPermissionInfo::kFlagCannotBeOptional},
74 {APIPermission::kPower, "power"},
75 {APIPermission::kPrinterProvider, "printerProvider"},
76 {APIPermission::kSerial, "serial"},
77 {APIPermission::kSocket,
78 "socket",
79 APIPermissionInfo::kFlagCannotBeOptional,
80 &CreateAPIPermission<SocketPermission>},
81 {APIPermission::kStorage, "storage"},
82 {APIPermission::kSystemCpu, "system.cpu"},
83 {APIPermission::kSystemMemory, "system.memory"},
84 {APIPermission::kSystemNetwork, "system.network"},
85 {APIPermission::kSystemDisplay, "system.display"},
86 {APIPermission::kSystemStorage, "system.storage"},
87 {APIPermission::kU2fDevices, "u2fDevices"},
88 {APIPermission::kUnlimitedStorage,
89 "unlimitedStorage",
90 APIPermissionInfo::kFlagCannotBeOptional |
91 APIPermissionInfo::kFlagSupportsContentCapabilities},
92 {APIPermission::kUsb, "usb", APIPermissionInfo::kFlagNone},
93 {APIPermission::kUsbDevice,
94 "usbDevices",
95 APIPermissionInfo::kFlagNone,
96 &CreateAPIPermission<UsbDevicePermission>},
97 {APIPermission::kVideoCapture, "videoCapture"},
98 {APIPermission::kVpnProvider,
99 "vpnProvider",
100 APIPermissionInfo::kFlagCannotBeOptional},
101 // NOTE(kalman): This is provided by a manifest property but needs to
102 // appear in the install permission dialogue, so we need a fake
103 // permission for it. See http://crbug.com/247857.
104 {APIPermission::kWebConnectable,
105 "webConnectable",
106 APIPermissionInfo::kFlagCannotBeOptional |
107 APIPermissionInfo::kFlagInternal},
108 {APIPermission::kWebRequest, "webRequest"},
109 {APIPermission::kWebRequestBlocking, "webRequestBlocking"},
110 {APIPermission::kWebView,
111 "webview",
112 APIPermissionInfo::kFlagCannotBeOptional},
113 {APIPermission::kWindowShape, "app.window.shape"},
116 std::vector<APIPermissionInfo*> permissions;
117 for (size_t i = 0; i < arraysize(permissions_to_register); ++i)
118 permissions.push_back(new APIPermissionInfo(permissions_to_register[i]));
119 return permissions;
122 std::vector<PermissionsProvider::AliasInfo>
123 ExtensionsAPIPermissions::GetAllAliases() const {
124 std::vector<PermissionsProvider::AliasInfo> aliases;
125 aliases.push_back(PermissionsProvider::AliasInfo(
126 "app.window.alwaysOnTop", kOldAlwaysOnTopWindowsPermission));
127 aliases.push_back(PermissionsProvider::AliasInfo("app.window.fullscreen",
128 kOldFullscreenPermission));
129 aliases.push_back(
130 PermissionsProvider::AliasInfo("app.window.fullscreen.overrideEsc",
131 kOldOverrideEscFullscreenPermission));
132 aliases.push_back(PermissionsProvider::AliasInfo(
133 "unlimitedStorage", kOldUnlimitedStoragePermission));
134 return aliases;
137 } // namespace extensions