OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/extensions/permissions/api_permission.h" | 5 #include "chrome/common/extensions/permissions/api_permission.h" |
6 | 6 |
7 #include "chrome/common/extensions/permissions/bluetooth_device_permission.h" | |
8 #include "chrome/common/extensions/permissions/permissions_info.h" | 7 #include "chrome/common/extensions/permissions/permissions_info.h" |
9 #include "chrome/common/extensions/permissions/socket_permission.h" | 8 #include "chrome/common/extensions/permissions/socket_permission.h" |
10 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
11 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
12 | 11 |
13 namespace { | 12 namespace { |
14 | 13 |
15 using extensions::APIPermission; | 14 using extensions::APIPermission; |
16 using extensions::APIPermissionInfo; | 15 using extensions::APIPermissionInfo; |
17 using extensions::PermissionMessage; | 16 using extensions::PermissionMessage; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 APIPermission::~APIPermission() { } | 109 APIPermission::~APIPermission() { } |
111 | 110 |
112 APIPermission::ID APIPermission::id() const { | 111 APIPermission::ID APIPermission::id() const { |
113 return info()->id(); | 112 return info()->id(); |
114 } | 113 } |
115 | 114 |
116 const char* APIPermission::name() const { | 115 const char* APIPermission::name() const { |
117 return info()->name(); | 116 return info()->name(); |
118 } | 117 } |
119 | 118 |
120 std::string APIPermission::ToString() const { | |
121 return name(); | |
122 } | |
123 | |
124 bool APIPermission::ManifestEntryForbidden() const { | |
125 return false; | |
126 } | |
127 | |
128 PermissionMessage APIPermission::GetMessage_() const { | 119 PermissionMessage APIPermission::GetMessage_() const { |
129 return info()->GetMessage_(); | 120 return info()->GetMessage_(); |
130 } | 121 } |
131 | 122 |
132 // | 123 // |
133 // APIPermissionInfo | 124 // APIPermissionInfo |
134 // | 125 // |
135 | 126 |
136 APIPermissionInfo::APIPermissionInfo( | 127 APIPermissionInfo::APIPermissionInfo( |
137 APIPermission::ID id, | 128 APIPermission::ID id, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 { APIPermission::kMediaGalleries, "mediaGalleries" }, | 316 { APIPermission::kMediaGalleries, "mediaGalleries" }, |
326 { APIPermission::kMediaGalleriesRead, "mediaGalleries.read" }, | 317 { APIPermission::kMediaGalleriesRead, "mediaGalleries.read" }, |
327 { APIPermission::kMediaGalleriesAllAutoDetected, | 318 { APIPermission::kMediaGalleriesAllAutoDetected, |
328 "mediaGalleries.allAutoDetected", kFlagNone, | 319 "mediaGalleries.allAutoDetected", kFlagNone, |
329 IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_ALL_GALLERIES, | 320 IDS_EXTENSION_PROMPT_WARNING_MEDIA_GALLERIES_ALL_GALLERIES, |
330 PermissionMessage::kMediaGalleriesAllGalleries }, | 321 PermissionMessage::kMediaGalleriesAllGalleries }, |
331 { APIPermission::kPushMessaging, "pushMessaging", kFlagCannotBeOptional }, | 322 { APIPermission::kPushMessaging, "pushMessaging", kFlagCannotBeOptional }, |
332 { APIPermission::kBluetooth, "bluetooth", kFlagNone, | 323 { APIPermission::kBluetooth, "bluetooth", kFlagNone, |
333 IDS_EXTENSION_PROMPT_WARNING_BLUETOOTH, | 324 IDS_EXTENSION_PROMPT_WARNING_BLUETOOTH, |
334 PermissionMessage::kBluetooth }, | 325 PermissionMessage::kBluetooth }, |
335 { APIPermission::kBluetoothDevice, "bluetoothDevice", | |
336 kFlagNone, 0, PermissionMessage::kNone, | |
337 &::CreateAPIPermission<BluetoothDevicePermission> }, | |
338 { APIPermission::kUsb, "usb", kFlagNone, | 326 { APIPermission::kUsb, "usb", kFlagNone, |
339 IDS_EXTENSION_PROMPT_WARNING_USB, | 327 IDS_EXTENSION_PROMPT_WARNING_USB, |
340 PermissionMessage::kUsb }, | 328 PermissionMessage::kUsb }, |
341 { APIPermission::kSystemIndicator, "systemIndicator", kFlagNone, | 329 { APIPermission::kSystemIndicator, "systemIndicator", kFlagNone, |
342 IDS_EXTENSION_PROMPT_WARNING_SYSTEM_INDICATOR, | 330 IDS_EXTENSION_PROMPT_WARNING_SYSTEM_INDICATOR, |
343 PermissionMessage::kSystemIndicator }, | 331 PermissionMessage::kSystemIndicator }, |
344 }; | 332 }; |
345 | 333 |
346 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(PermissionsToRegister); ++i) { | 334 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(PermissionsToRegister); ++i) { |
347 const PermissionRegistration& pr = PermissionsToRegister[i]; | 335 const PermissionRegistration& pr = PermissionsToRegister[i]; |
348 info->RegisterPermission( | 336 info->RegisterPermission( |
349 pr.id, pr.name, pr.l10n_message_id, | 337 pr.id, pr.name, pr.l10n_message_id, |
350 pr.message_id ? pr.message_id : PermissionMessage::kNone, | 338 pr.message_id ? pr.message_id : PermissionMessage::kNone, |
351 pr.flags, | 339 pr.flags, |
352 pr.constructor); | 340 pr.constructor); |
353 } | 341 } |
354 | 342 |
355 // Register aliases. | 343 // Register aliases. |
356 info->RegisterAlias("unlimitedStorage", kOldUnlimitedStoragePermission); | 344 info->RegisterAlias("unlimitedStorage", kOldUnlimitedStoragePermission); |
357 info->RegisterAlias("tabs", kWindowsPermission); | 345 info->RegisterAlias("tabs", kWindowsPermission); |
358 } | 346 } |
359 | 347 |
360 } // namespace extensions | 348 } // namespace extensions |
OLD | NEW |