Chromium Code Reviews| 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 ae9bfaae28d35ebe689de7cc5ff7634a2ce52976..f419086a379a4a943824dee9b0d89f7737efd623 100644 |
| --- a/chrome/browser/resources/bluetooth_internals/adapter_broker.js |
| +++ b/chrome/browser/resources/bluetooth_internals/adapter_broker.js |
| @@ -27,6 +27,29 @@ 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>} |
|
dpapad
2016/11/10 19:05:02
!Promise<!...>
mbrunson
2016/11/10 22:02:22
Done.
|
| + */ |
| + 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( |
|
dpapad
2016/11/10 19:05:02
Isn't this equivalent to
interfaces.BluetoothAdap
mbrunson
2016/11/10 22:02:22
response.result is a number. ConnectResult is an o
|
| + interfaces.BluetoothAdapter.ConnectResult)[response.result]; |
| + |
| + throw new Error(errorString); |
| + } |
| + |
| + return interfaces.Connection.bindHandleToProxy( |
| + response.device, |
| + interfaces.BluetoothDevice.Device); |
| + }); |
| + }, |
| + |
| + /** |
| * Sets client of Adapter service. |
| * @param {!interfaces.BluetoothAdapter.AdapterClient} adapterClient |
| */ |