Index: chrome/browser/extensions/api/bluetooth/bluetooth_api.cc |
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc |
index 875e36a7cc8a03851937f3c7eba585cf009867a6..38b2ab316c5a4429685ab3bb2c3922ee81fa3544 100644 |
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc |
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc |
@@ -19,6 +19,7 @@ |
#include "chrome/browser/extensions/extension_system.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/common/extensions/api/bluetooth.h" |
+#include "chrome/common/extensions/permissions/bluetooth_device_permission.h" |
#include "content/public/browser/browser_thread.h" |
#include "device/bluetooth/bluetooth_adapter.h" |
#include "device/bluetooth/bluetooth_device.h" |
@@ -62,6 +63,7 @@ const char kCouldNotGetLocalOutOfBandPairingData[] = |
"Could not get local Out Of Band Pairing Data"; |
const char kCouldNotSetOutOfBandPairingData[] = |
"Could not set Out Of Band Pairing Data"; |
+const char kDevicePermissionDenied[] = "Permission to access device denied"; |
const char kFailedToConnect[] = "Connection failed"; |
const char kInvalidDevice[] = "Invalid device"; |
const char kInvalidUuid[] = "Invalid UUID"; |
@@ -343,6 +345,13 @@ bool BluetoothConnectFunction::RunImpl() { |
EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); |
const bluetooth::ConnectOptions& options = params->options; |
+ BluetoothDevicePermission::CheckParam param(options.device_address); |
+ if (!GetExtension()->CheckAPIPermissionWithParam( |
+ APIPermission::kBluetoothDevice, ¶m)) { |
+ SetError(kDevicePermissionDenied); |
+ return false; |
+ } |
+ |
std::string uuid = device::bluetooth_utils::CanonicalUuid( |
options.service_uuid); |
if (uuid.empty()) { |