Index: chrome/browser/resources/bluetooth_internals/adapter_broker.js |
diff --git a/chrome/browser/resources/bluetooth_internals/adapter_broker.js b/chrome/browser/resources/bluetooth_internals/adapter_broker.js |
index c17c89fe2a4806ce63a0155d4f5fba024ef10c33..7f27d8f902bb35735ab62a3cbd1a091362e67691 100644 |
--- a/chrome/browser/resources/bluetooth_internals/adapter_broker.js |
+++ b/chrome/browser/resources/bluetooth_internals/adapter_broker.js |
@@ -27,6 +27,30 @@ cr.define('adapter_broker', function() { |
__proto__: cr.EventTarget.prototype, |
/** |
+ * Creates a GATT connection to the device with |address|. |
+ * @param {string} address |
+ * @return {Promise<interfaces.BluetoothDevice.Device.proxyClass>} |
+ */ |
+ connectToDevice: function(address) { |
+ return this.adapter_.connectToDevice(address).then(function(response) { |
+ if (response.result != |
+ interfaces.BluetoothAdapter.ConnectResult.SUCCESS) { |
+ // TODO(crbug.com/663394): Replace with more descriptive error |
+ // messages. |
+ var errorString = Object.keys( |
+ interfaces.BluetoothAdapter.ConnectResult)[response.result]; |
+ |
+ throw new Error(errorString); |
+ } |
+ |
+ response.device = interfaces.Connection.bindHandleToProxy( |
+ response.device, |
+ interfaces.BluetoothDevice.Device); |
+ return response; |
ortuno
2016/11/09 03:24:03
Why not return just the device?
mbrunson
2016/11/09 23:39:37
Done.
|
+ }); |
+ }, |
+ |
+ /** |
* Sets client of Adapter service. |
* @param {interfaces.BluetoothAdapter.AdapterClient} adapterClient |
*/ |