Chromium Code Reviews| Index: chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js |
| diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js b/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js |
| index ac50ff483ca46d4c0101dfd119f1d989d0f4458a..0878a54e8a37d0c7eb60091ea7e884d14a47769d 100644 |
| --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js |
| +++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js |
| @@ -73,11 +73,10 @@ Polymer({ |
| /** |
| * Set to the name of the dialog to show. This page uses a single |
| - * paper-dialog to host one of two dialog elements, 'addDevice' or |
| - * 'pairDevice'. This allows a seamless transition between adding and |
| - * pairing dialogs. Note: This property should be set before opening the |
| - * dialog, and setting the property will not itself cause the dialog to |
| - * open. |
| + * paper-dialog to host one of three dialog elements, 'addDevice', |
| + * 'pairDevice', or 'connectError'. This allows a seamless transition |
| + * between dialogs. Note: This property should be set before opening the |
| + * dialog and setting the property will not itself cause the dialog to open. |
| */ |
| dialogId: String, |
| @@ -93,6 +92,9 @@ Polymer({ |
| */ |
| pairingEvent: Object, |
| + /** The translated error message to show when a connect error occurs. */ |
| + errorMessage: String, |
| + |
| /** |
| * Interface for bluetooth calls. May be overriden by tests. |
| * @type {Bluetooth} |
| @@ -439,13 +441,32 @@ Polymer({ |
| } |
| this.bluetoothPrivate.connect(device.address, function(result) { |
| + var error; |
| if (chrome.runtime.lastError) { |
| - console.error( |
| - 'Error connecting: ' + device.address + |
| - chrome.runtime.lastError.message); |
| - // TODO(stevenjb): Show error message insead. |
| + error = chrome.runtime.lastError.message; |
| + } else { |
| + switch (result) { |
| + case chrome.bluetoothPrivate.ConnectResultType.ALREADY_CONNECTED: |
| + case chrome.bluetoothPrivate.ConnectResultType.AUTH_CANCELED: |
| + case chrome.bluetoothPrivate.ConnectResultType.IN_PROGRESS: |
| + case chrome.bluetoothPrivate.ConnectResultType.SUCCESS: |
| + break; |
| + default: |
| + error = result; |
| + } |
| + } |
|
Dan Beam
2016/07/16 00:31:56
nit: \n after each if
stevenjb
2016/07/16 01:17:46
Presuming you mean a blank line here and after 461
|
| + if (!error) { |
| this.closeDialog_(); |
| + return; |
| } |
| + var name = this.getDeviceName_(device); |
| + var id = 'bluetooth_connect_' + error; |
| + if (this.i18nExists(id)) |
| + this.errorMessage = this.i18n(id, name); |
| + else |
| + this.errorMessage = error; |
| + console.error('Error connecting to: ' + name + ': ' + this.errorMessage); |
|
Dan Beam
2016/07/16 00:31:56
nit: i still don't support leaving console messagi
stevenjb
2016/07/16 01:17:46
Moved the console.error inside the else clause, si
|
| + this.openDialog_('connectError'); |
| }.bind(this)); |
| }, |