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/socket_permission.h"
11 #include "extensions/common/permissions/usb_device_permission.h"
12 #include "grit/extensions_strings.h"
14 namespace extensions
{
18 const char kOldAlwaysOnTopWindowsPermission
[] = "alwaysOnTopWindows";
19 const char kOldFullscreenPermission
[] = "fullscreen";
20 const char kOldOverrideEscFullscreenPermission
[] = "overrideEscFullscreen";
21 const char kOldUnlimitedStoragePermission
[] = "unlimited_storage";
24 APIPermission
* CreateAPIPermission(const APIPermissionInfo
* permission
) {
25 return new T(permission
);
30 std::vector
<APIPermissionInfo
*> ExtensionsAPIPermissions::GetAllPermissions()
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
,
41 APIPermissionInfo::kFlagCannotBeOptional
},
42 {APIPermission::kAudio
, "audio"},
43 {APIPermission::kAudioCapture
, "audioCapture"},
44 {APIPermission::kBluetoothPrivate
,
46 APIPermissionInfo::kFlagCannotBeOptional
},
47 {APIPermission::kClipboardRead
,
49 APIPermissionInfo::kFlagSupportsContentCapabilities
},
50 {APIPermission::kClipboardWrite
,
52 APIPermissionInfo::kFlagSupportsContentCapabilities
},
53 {APIPermission::kDeclarativeWebRequest
, "declarativeWebRequest"},
54 {APIPermission::kDiagnostics
,
56 APIPermissionInfo::kFlagCannotBeOptional
},
57 {APIPermission::kDns
, "dns"},
58 {APIPermission::kDocumentScan
, "documentScan"},
59 {APIPermission::kExtensionView
,
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
,
73 APIPermissionInfo::kFlagCannotBeOptional
},
74 {APIPermission::kPower
, "power"},
75 {APIPermission::kPrinterProvider
, "printerProvider"},
76 {APIPermission::kSerial
, "serial"},
77 {APIPermission::kSocket
,
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
,
90 APIPermissionInfo::kFlagCannotBeOptional
|
91 APIPermissionInfo::kFlagSupportsContentCapabilities
},
92 {APIPermission::kUsb
, "usb", APIPermissionInfo::kFlagNone
},
93 {APIPermission::kUsbDevice
,
95 APIPermissionInfo::kFlagNone
,
96 &CreateAPIPermission
<UsbDevicePermission
>},
97 {APIPermission::kVideoCapture
, "videoCapture"},
98 {APIPermission::kVpnProvider
,
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
,
106 APIPermissionInfo::kFlagCannotBeOptional
|
107 APIPermissionInfo::kFlagInternal
},
108 {APIPermission::kWebRequest
, "webRequest"},
109 {APIPermission::kWebRequestBlocking
, "webRequestBlocking"},
110 {APIPermission::kWebView
,
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
]));
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
));
130 PermissionsProvider::AliasInfo("app.window.fullscreen.overrideEsc",
131 kOldOverrideEscFullscreenPermission
));
132 aliases
.push_back(PermissionsProvider::AliasInfo(
133 "unlimitedStorage", kOldUnlimitedStoragePermission
));
137 } // namespace extensions