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