| Index: chrome/browser/resources/bluetooth_internals/bluetooth_internals.js | 
| diff --git a/chrome/browser/resources/bluetooth_internals/bluetooth_internals.js b/chrome/browser/resources/bluetooth_internals/bluetooth_internals.js | 
| index 4057293273bc1ddaa7726553896bef63b21fd86d..5059c3ece81068daacbf4feaf00a18ca5a0af98a 100644 | 
| --- a/chrome/browser/resources/bluetooth_internals/bluetooth_internals.js | 
| +++ b/chrome/browser/resources/bluetooth_internals/bluetooth_internals.js | 
| @@ -8,6 +8,10 @@ | 
| */ | 
|  | 
| cr.define('bluetooth_internals', function() { | 
| + | 
| +  /** @type {!Map<string, !interfaces.BluetoothDevice.Device.proxyClass>} */ | 
| +  var deviceAddressToProxy = new Map(); | 
| + | 
| function initializeViews() { | 
| var adapterBroker = null; | 
| adapter_broker.getAdapterBroker() | 
| @@ -32,6 +36,49 @@ cr.define('bluetooth_internals', function() { | 
| devices /* this */); | 
|  | 
| var deviceTable = new device_table.DeviceTable(); | 
| + | 
| +        deviceTable.addEventListener('inspectpressed', function(event) { | 
| +          // TODO(crbug.com/663470): Move connection logic to DeviceDetailsView | 
| +          // when it's added in chrome://bluetooth-internals. | 
| +          var address = event.detail.address; | 
| +          var proxy = deviceAddressToProxy.get(address); | 
| + | 
| +          if (proxy) { | 
| +            // Device is already connected, so disconnect. | 
| +            proxy.disconnect(); | 
| +            deviceAddressToProxy.delete(address); | 
| +            devices.updateConnectionStatus( | 
| +                address, device_collection.ConnectionStatus.DISCONNECTED); | 
| +            return; | 
| +          } | 
| + | 
| +          devices.updateConnectionStatus( | 
| +              address, device_collection.ConnectionStatus.CONNECTING); | 
| +          adapterBroker.connectToDevice(address).then(function(deviceProxy) { | 
| +            if (!devices.getByAddress(address)) { | 
| +              // Device no longer in list, so drop the connection. | 
| +              deviceProxy.disconnect(); | 
| +              return; | 
| +            } | 
| + | 
| +            deviceAddressToProxy.set(address, deviceProxy); | 
| +            devices.updateConnectionStatus( | 
| +                address, device_collection.ConnectionStatus.CONNECTED); | 
| + | 
| +            // Fetch services asynchronously. | 
| +            return deviceProxy.getServices(); | 
| +          }).then(function(response) { | 
| +            var deviceInfo = devices.getByAddress(address); | 
| +            deviceInfo.services = response.services; | 
| +            devices.addOrUpdate(deviceInfo); | 
| +          }).catch(function(error) { | 
| +            devices.updateConnectionStatus( | 
| +                address, | 
| +                device_collection.ConnectionStatus.DISCONNECTED, | 
| +                error); | 
| +          }); | 
| +        }); | 
| + | 
| deviceTable.setDevices(devices); | 
| document.body.appendChild(deviceTable); | 
| }) | 
|  |