Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1486)

Unified Diff: chrome/browser/extensions/api/bluetooth/bluetooth_api.cc

Issue 11413099: Bluetooth API Permission Dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix memory leak Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/extensions/api/permissions/permissions_api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, &param)) {
+ SetError(kDevicePermissionDenied);
+ return false;
+ }
+
std::string uuid = device::bluetooth_utils::CanonicalUuid(
options.service_uuid);
if (uuid.empty()) {
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/extensions/api/permissions/permissions_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698