Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / extensions / common / permissions / extensions_api_permissions.cc
blobe4cbb8f1681be619b355eb8744e8f82f920aaaa8
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 "extensions/common/permissions/api_permission.h"
8 #include "extensions/common/permissions/permission_message.h"
9 #include "extensions/common/permissions/socket_permission.h"
10 #include "extensions/common/permissions/usb_device_permission.h"
11 #include "grit/extensions_strings.h"
13 namespace extensions {
15 namespace {
17 template <typename T>
18 APIPermission* CreateAPIPermission(const APIPermissionInfo* permission) {
19 return new T(permission);
22 } // namespace
24 std::vector<APIPermissionInfo*> ExtensionsAPIPermissions::GetAllPermissions()
25 const {
26 APIPermissionInfo::InitInfo permissions_to_register[] = {
27 {APIPermission::kAudioCapture, "audioCapture",
28 APIPermissionInfo::kFlagNone, IDS_EXTENSION_PROMPT_WARNING_AUDIO_CAPTURE,
29 PermissionMessage::kAudioCapture},
30 {APIPermission::kDns, "dns"},
31 {APIPermission::kHid, "hid", APIPermissionInfo::kFlagNone,
32 IDS_EXTENSION_PROMPT_WARNING_HID, PermissionMessage::kHid},
33 {APIPermission::kPower, "power"},
34 {APIPermission::kSerial, "serial", APIPermissionInfo::kFlagNone,
35 IDS_EXTENSION_PROMPT_WARNING_SERIAL, PermissionMessage::kSerial},
36 // Because warning messages for the "socket" permission vary based
37 // on the permissions parameters, no message ID or message text is
38 // specified here. The message ID and text used will be
39 // determined at run-time in the |SocketPermission| class.
40 {APIPermission::kSocket, "socket",
41 APIPermissionInfo::kFlagCannotBeOptional, 0, PermissionMessage::kNone,
42 &CreateAPIPermission<SocketPermission>},
43 {APIPermission::kStorage, "storage"},
44 {APIPermission::kUsb, "usb", APIPermissionInfo::kFlagNone,
45 IDS_EXTENSION_PROMPT_WARNING_USB, PermissionMessage::kUsb},
46 {APIPermission::kUsbDevice, "usbDevices", APIPermissionInfo::kFlagNone, 0,
47 PermissionMessage::kNone, &CreateAPIPermission<UsbDevicePermission>},
48 {APIPermission::kVideoCapture, "videoCapture",
49 APIPermissionInfo::kFlagNone, IDS_EXTENSION_PROMPT_WARNING_VIDEO_CAPTURE,
50 PermissionMessage::kVideoCapture},
53 std::vector<APIPermissionInfo*> permissions;
54 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(permissions_to_register); ++i)
55 permissions.push_back(new APIPermissionInfo(permissions_to_register[i]));
56 return permissions;
59 std::vector<PermissionsProvider::AliasInfo>
60 ExtensionsAPIPermissions::GetAllAliases() const {
61 return std::vector<PermissionsProvider::AliasInfo>();
64 } // namespace extensions