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"
9 #include "extensions/common/permissions/api_permission.h"
10 #include "extensions/common/permissions/permission_message.h"
11 #include "extensions/common/permissions/socket_permission.h"
12 #include "extensions/common/permissions/usb_device_permission.h"
13 #include "grit/extensions_strings.h"
15 namespace extensions
{
19 const char kOldAlwaysOnTopWindowsPermission
[] = "alwaysOnTopWindows";
20 const char kOldFullscreenPermission
[] = "fullscreen";
21 const char kOldOverrideEscFullscreenPermission
[] = "overrideEscFullscreen";
24 APIPermission
* CreateAPIPermission(const APIPermissionInfo
* permission
) {
25 return new T(permission
);
30 std::vector
<APIPermissionInfo
*> ExtensionsAPIPermissions::GetAllPermissions()
32 APIPermissionInfo::InitInfo permissions_to_register
[] = {
33 {APIPermission::kAlphaEnabled
, "app.window.alpha"},
34 {APIPermission::kAlwaysOnTopWindows
, "app.window.alwaysOnTop"},
35 {APIPermission::kAppView
, "appview",
36 APIPermissionInfo::kFlagCannotBeOptional
},
37 {APIPermission::kAudioCapture
, "audioCapture",
38 APIPermissionInfo::kFlagNone
, IDS_EXTENSION_PROMPT_WARNING_AUDIO_CAPTURE
,
39 PermissionMessage::kAudioCapture
},
40 {APIPermission::kBluetoothPrivate
, "bluetoothPrivate",
41 APIPermissionInfo::kFlagCannotBeOptional
,
42 IDS_EXTENSION_PROMPT_WARNING_BLUETOOTH_PRIVATE
,
43 PermissionMessage::kBluetoothPrivate
},
44 {APIPermission::kDeclarativeWebRequest
, "declarativeWebRequest",
45 APIPermissionInfo::kFlagNone
,
46 IDS_EXTENSION_PROMPT_WARNING_DECLARATIVE_WEB_REQUEST
,
47 PermissionMessage::kDeclarativeWebRequest
},
48 {APIPermission::kDns
, "dns"},
49 {APIPermission::kExternallyConnectableAllUrls
,
50 "externally_connectable.all_urls"},
51 {APIPermission::kFullscreen
, "app.window.fullscreen"},
52 {APIPermission::kHid
, "hid", APIPermissionInfo::kFlagNone
,
53 IDS_EXTENSION_PROMPT_WARNING_HID
, PermissionMessage::kHid
},
54 {APIPermission::kImeWindowEnabled
, "app.window.ime"},
55 {APIPermission::kOverrideEscFullscreen
,
56 "app.window.fullscreen.overrideEsc"},
57 {APIPermission::kPower
, "power"},
58 {APIPermission::kSerial
, "serial", APIPermissionInfo::kFlagNone
,
59 IDS_EXTENSION_PROMPT_WARNING_SERIAL
, PermissionMessage::kSerial
},
60 // Because warning messages for the "socket" permission vary based
61 // on the permissions parameters, no message ID or message text is
62 // specified here. The message ID and text used will be
63 // determined at run-time in the |SocketPermission| class.
64 {APIPermission::kSocket
, "socket",
65 APIPermissionInfo::kFlagCannotBeOptional
, 0, PermissionMessage::kNone
,
66 &CreateAPIPermission
<SocketPermission
>},
67 {APIPermission::kStorage
, "storage"},
68 {APIPermission::kSystemCpu
, "system.cpu"},
69 {APIPermission::kSystemMemory
, "system.memory"},
70 {APIPermission::kSystemNetwork
, "system.network"},
71 {APIPermission::kSystemDisplay
, "system.display"},
72 {APIPermission::kSystemStorage
, "system.storage"},
73 {APIPermission::kU2fDevices
, "u2fDevices", APIPermissionInfo::kFlagNone
,
74 IDS_EXTENSION_PROMPT_WARNING_U2F_DEVICES
,
75 PermissionMessage::kU2fDevices
},
76 {APIPermission::kUsb
, "usb", APIPermissionInfo::kFlagNone
},
77 {APIPermission::kUsbDevice
, "usbDevices", APIPermissionInfo::kFlagNone
, 0,
78 PermissionMessage::kNone
, &CreateAPIPermission
<UsbDevicePermission
>},
79 {APIPermission::kVideoCapture
, "videoCapture",
80 APIPermissionInfo::kFlagNone
, IDS_EXTENSION_PROMPT_WARNING_VIDEO_CAPTURE
,
81 PermissionMessage::kVideoCapture
},
82 {APIPermission::kVpnProvider
, "vpnProvider",
83 APIPermissionInfo::kFlagCannotBeOptional
,
84 IDS_EXTENSION_PROMPT_WARNING_VPN
, PermissionMessage::kVpnProvider
},
85 // NOTE(kalman): This is provided by a manifest property but needs to
86 // appear in the install permission dialogue, so we need a fake
87 // permission for it. See http://crbug.com/247857.
88 {APIPermission::kWebConnectable
, "webConnectable",
89 APIPermissionInfo::kFlagCannotBeOptional
|
90 APIPermissionInfo::kFlagInternal
,
91 IDS_EXTENSION_PROMPT_WARNING_WEB_CONNECTABLE
,
92 PermissionMessage::kWebConnectable
},
93 {APIPermission::kWebRequest
, "webRequest"},
94 {APIPermission::kWebRequestBlocking
, "webRequestBlocking"},
95 {APIPermission::kWebView
, "webview",
96 APIPermissionInfo::kFlagCannotBeOptional
},
97 {APIPermission::kWindowShape
, "app.window.shape"},
100 std::vector
<APIPermissionInfo
*> permissions
;
101 for (size_t i
= 0; i
< arraysize(permissions_to_register
); ++i
)
102 permissions
.push_back(new APIPermissionInfo(permissions_to_register
[i
]));
106 std::vector
<PermissionsProvider::AliasInfo
>
107 ExtensionsAPIPermissions::GetAllAliases() const {
108 std::vector
<PermissionsProvider::AliasInfo
> aliases
;
109 aliases
.push_back(PermissionsProvider::AliasInfo(
110 "app.window.alwaysOnTop", kOldAlwaysOnTopWindowsPermission
));
111 aliases
.push_back(PermissionsProvider::AliasInfo("app.window.fullscreen",
112 kOldFullscreenPermission
));
114 PermissionsProvider::AliasInfo("app.window.fullscreen.overrideEsc",
115 kOldOverrideEscFullscreenPermission
));
119 } // namespace extensions