diff options
author | jennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-01 22:15:30 +0000 |
---|---|---|
committer | jennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-01 22:15:30 +0000 |
commit | f65e79c357b8145e0950e7a68947d08ad02b8822 (patch) | |
tree | ff888769b5f50565108f1b456f0324ba07f30315 | |
parent | 6abb6024073141a2def6988e0f592257e867e140 (diff) | |
download | chromium_src-f65e79c357b8145e0950e7a68947d08ad02b8822.zip chromium_src-f65e79c357b8145e0950e7a68947d08ad02b8822.tar.gz chromium_src-f65e79c357b8145e0950e7a68947d08ad02b8822.tar.bz2 |
Fix the crashing issue of bluetooth pairing dialog closed from hosting dialog. Since I have added support for web dialog to fire window.onbeforeunload event when hosting dialog closes(crbug.com/172067), this bug is fixed by just hooking cleaning up code in window.onbeforeunload in js.
Do not display error message if user cancels/closes for the pairing dialog, which happens with pairing dialog from settings page, since BluetoothDevice callback code calling into BluetoothPairing.showMessage with ConnectError after the dialog is closed by the user.
BUG=172364
Review URL: https://codereview.chromium.org/12090105
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180197 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/chromeos/bluetooth_pair_device.js | 7 | ||||
-rw-r--r-- | chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.js | 24 |
2 files changed, 24 insertions, 7 deletions
diff --git a/chrome/browser/resources/chromeos/bluetooth_pair_device.js b/chrome/browser/resources/chromeos/bluetooth_pair_device.js index 9b20449..da2d72c 100644 --- a/chrome/browser/resources/chromeos/bluetooth_pair_device.js +++ b/chrome/browser/resources/chromeos/bluetooth_pair_device.js @@ -12,6 +12,13 @@ OptionsPage.closeOverlay = function() { }; /** + * Listener for the |beforeunload| event. + */ +window.onbeforeunload = function() { + OptionsPage.willClose(); +}; + +/** * DOMContentLoaded handler, sets up the page. */ function load() { diff --git a/chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.js b/chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.js index 25fae1d..294dd96 100644 --- a/chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.js +++ b/chrome/browser/resources/options/chromeos/bluetooth_pair_device_overlay.js @@ -18,6 +18,8 @@ cr.define('options', function() { REMOTE_PIN_CODE: 'bluetoothRemotePinCode', REMOTE_PASSKEY: 'bluetoothRemotePasskey', CONFIRM_PASSKEY: 'bluetoothConfirmPasskey', + CONNECT_FAILED: 'bluetoothConnectFailed', + CANCELED: 'bluetoothPairingCanceled', DISMISSED: 'bluetoothPairingDismissed', // pairing dismissed(succeeded or // canceled). }; @@ -79,8 +81,6 @@ cr.define('options', function() { OptionsPage.prototype.initializePage.call(this); var self = this; $('bluetooth-pair-device-cancel-button').onclick = function() { - chrome.send('updateBluetoothDevice', - [self.device_.address, 'cancel']); OptionsPage.closeOverlay(); }; $('bluetooth-pair-device-reject-button').onclick = function() { @@ -133,7 +133,9 @@ cr.define('options', function() { /** @override */ didClosePage: function() { - if (this.device_.pairing != PAIRING.DISMISSED) { + if (this.device_.pairing != PAIRING.DISMISSED && + this.device_.pairing != PAIRING.CONNECT_FAILED) { + this.device_.pairing = PAIRING.CANCELED; chrome.send('updateBluetoothDevice', [this.device_.address, 'cancel']); } @@ -339,10 +341,18 @@ cr.define('options', function() { * string: address} data Data for constructing the message. */ BluetoothPairing.showMessage = function(data) { - var name = ''; - if (data.address.length > 0) { - name = data.address; - var list = $('bluetooth-paired-devices-list'); + var name = data.address; + if (name.length == 0) + return; + var dialog = BluetoothPairing.getInstance(); + if (name == dialog.device_.address && + dialog.device_.pairing == PAIRING.CANCELED) { + // Do not show any error message after cancelation of the pairing. + return; + } + + var list = $('bluetooth-paired-devices-list'); + if (list) { var index = list.find(name); if (index == undefined) { list = $('bluetooth-unpaired-devices-list'); |