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

Unified Diff: chrome/browser/resources/bluetooth_internals/adapter_broker.js

Issue 2448713002: bluetooth: Add Device connection logic and accompanying user interface. (Closed)
Patch Set: Remove binding variable in Device.Create Created 4 years, 1 month 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
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..7aab61418c9126b4efc988d5fd8aed79899b0b24 100644
--- a/chrome/browser/resources/bluetooth_internals/adapter_broker.js
+++ b/chrome/browser/resources/bluetooth_internals/adapter_broker.js
@@ -27,6 +27,31 @@ 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 ConnectResult = interfaces.BluetoothAdapter.ConnectResult;
+ var errorString = Object.keys(ConnectResult).find(function(key) {
+ return ConnectResult[key] === 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
*/
« no previous file with comments | « chrome/browser/browser_resources.grd ('k') | chrome/browser/resources/bluetooth_internals/bluetooth_internals.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698