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

Unified Diff: chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js

Issue 2146553005: MD Settings: Bluetooth: Add error dialog and messages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_602538_bluetooth_fixes_0
Patch Set: Feedback Created 4 years, 5 months 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/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 ddc3a0852723f758e5f74b33a24b21ed9a8d4c1a..b4e35a45fd4096cdd753be104abad3aa71537a2d 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,35 @@ 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;
+ }
+ }
+
+ 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('Unexpected error connecting to: ' + name + ': ' + error);
}
+ this.openDialog_('connectError');
}.bind(this));
},

Powered by Google App Engine
This is Rietveld 408576698