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 fe2167d80141459dfd65a757856a545aed7d1530..c6d0e866dea22afd93eb29d18e63d1e5d328a83c 100644 |
--- a/chrome/browser/resources/bluetooth_internals/bluetooth_internals.js |
+++ b/chrome/browser/resources/bluetooth_internals/bluetooth_internals.js |
@@ -68,44 +68,52 @@ cr.define('bluetooth_internals', function() { |
devices.updateConnectionStatus( |
address, device_collection.ConnectionStatus.CONNECTING); |
- adapterBroker.connectToDevice(address).then(function(deviceProxy) { |
- var deviceInfo = devices.getByAddress(address); |
- if (!deviceInfo) { |
- // Device no longer in list, so drop the connection. |
- deviceProxy.disconnect(); |
- return; |
- } |
- |
- deviceAddressToProxy.set(address, deviceProxy); |
- devices.updateConnectionStatus( |
- address, device_collection.ConnectionStatus.CONNECTED); |
- Snackbar.show(deviceInfo.name_for_display + ': Connected', |
- SnackbarType.SUCCESS); |
- |
- // Fetch services asynchronously. |
- return deviceProxy.getServices(); |
- }).then(function(response) { |
- if (!response) return; |
- |
- var deviceInfo = devices.getByAddress(address); |
- deviceInfo.services = response.services; |
- devices.addOrUpdate(deviceInfo); |
- }).catch(function(error) { |
- // If a connection error occurs while fetching the services, the proxy |
- // reference must be removed. |
- var proxy = deviceAddressToProxy.get(address); |
- if (proxy) { |
- proxy.disconnect(); |
- deviceAddressToProxy.delete(address); |
- } |
- |
- devices.updateConnectionStatus( |
- address, device_collection.ConnectionStatus.DISCONNECTED); |
- |
- var deviceInfo = devices.getByAddress(address); |
- Snackbar.show(deviceInfo.name_for_display + ': ' + error.message, |
- SnackbarType.ERROR, 'Retry', function() { handleInspect(event); }); |
- }); |
+ adapterBroker.connectToDevice(address) |
+ .then(function(deviceProxy) { |
+ var deviceInfo = devices.getByAddress(address); |
+ if (!deviceInfo) { |
+ // Device no longer in list, so drop the connection. |
+ deviceProxy.disconnect(); |
+ return; |
+ } |
+ |
+ deviceAddressToProxy.set(address, deviceProxy); |
+ devices.updateConnectionStatus( |
+ address, device_collection.ConnectionStatus.CONNECTED); |
+ Snackbar.show( |
+ deviceInfo.name_for_display + ': Connected', |
+ SnackbarType.SUCCESS); |
+ |
+ // Fetch services asynchronously. |
+ return deviceProxy.getServices(); |
+ }) |
+ .then(function(response) { |
+ if (!response) |
+ return; |
+ |
+ var deviceInfo = devices.getByAddress(address); |
+ deviceInfo.services = response.services; |
+ devices.addOrUpdate(deviceInfo); |
+ }) |
+ .catch(function(error) { |
+ // If a connection error occurs while fetching the services, the proxy |
+ // reference must be removed. |
+ var proxy = deviceAddressToProxy.get(address); |
+ if (proxy) { |
+ proxy.disconnect(); |
+ deviceAddressToProxy.delete(address); |
+ } |
+ |
+ devices.updateConnectionStatus( |
+ address, device_collection.ConnectionStatus.DISCONNECTED); |
+ |
+ var deviceInfo = devices.getByAddress(address); |
+ Snackbar.show( |
+ deviceInfo.name_for_display + ': ' + error.message, |
+ SnackbarType.ERROR, 'Retry', function() { |
+ handleInspect(event); |
+ }); |
+ }); |
} |
function setupDeviceSystem(response) { |
@@ -128,7 +136,9 @@ cr.define('bluetooth_internals', function() { |
function setupPages() { |
sidebarObj = new window.sidebar.Sidebar($('sidebar')); |
- $('menu-btn').addEventListener('click', function() { sidebarObj.open(); }); |
+ $('menu-btn').addEventListener('click', function() { |
+ sidebarObj.open(); |
+ }); |
PageManager.addObserver(sidebarObj); |
PageManager.addObserver(new PageObserver()); |
@@ -152,20 +162,26 @@ cr.define('bluetooth_internals', function() { |
setupPages(); |
adapter_broker.getAdapterBroker() |
- .then(function(broker) { adapterBroker = broker; }) |
- .then(function() { return adapterBroker.getInfo(); }) |
- .then(function(response) { console.log('adapter', response.info); }) |
- .then(function() { return adapterBroker.getDevices(); }) |
- .then(setupDeviceSystem) |
- .catch(function(error) { |
- Snackbar.show(error.message, SnackbarType.ERROR); |
- console.error(error); |
- }); |
+ .then(function(broker) { |
+ adapterBroker = broker; |
+ }) |
+ .then(function() { |
+ return adapterBroker.getInfo(); |
+ }) |
+ .then(function(response) { |
+ console.log('adapter', response.info); |
+ }) |
+ .then(function() { |
+ return adapterBroker.getDevices(); |
+ }) |
+ .then(setupDeviceSystem) |
+ .catch(function(error) { |
+ Snackbar.show(error.message, SnackbarType.ERROR); |
+ console.error(error); |
+ }); |
} |
- return { |
- initializeViews: initializeViews |
- }; |
+ return {initializeViews: initializeViews}; |
}); |
document.addEventListener( |