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

Unified Diff: chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js

Issue 9701012: Fix pincode versus passkey issues for Bluetooth pairing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove extra blank line. Created 8 years, 9 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
« no previous file with comments | « chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js
diff --git a/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js b/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js
index f1590ac1984e2119a28bfcb10bda15aa7e44055a..014583eb292077c7e2cbdfdabce9f66a6e352eea 100644
--- a/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js
+++ b/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js
@@ -30,6 +30,7 @@ cr.define('options', function() {
*/
var ELEMENTS = ['bluetooth-pairing-passkey-display',
'bluetooth-pairing-passkey-entry',
+ 'bluetooth-pairing-pincode-entry',
'bluetooth-pair-device-connect-button',
'bluetooth-pair-device-cancel-button',
'bluetooth-pair-device-accept-button',
@@ -85,10 +86,12 @@ cr.define('options', function() {
$('bluetooth-pair-device-connect-button').onclick = function() {
var args = [self.device_.address, 'connect'];
var passkey = self.device_.passkey;
- if (!passkey && !$('bluetooth-pairing-passkey-entry').hidden)
- passkey = $('bluetooth-passkey').value;
if (passkey)
args.push(String(passkey));
+ else if (!$('bluetooth-pairing-passkey-entry').hidden)
+ args.push($('bluetooth-passkey').value);
+ else if (!$('bluetooth-pairing-pincode-entry').hidden)
+ args.push($('bluetooth-pincode').value);
chrome.send('updateBluetoothDevice', args);
OptionsPage.closeOverlay();
};
@@ -101,8 +104,21 @@ cr.define('options', function() {
OptionsPage.closeOverlay();
};
$('bluetooth-passkey').oninput = function() {
+ var inputField = $('bluetooth-passkey');
+ var value = inputField.value;
+ // Note that using <input type="number"> is insufficient to restrict
+ // the input as it allows negative numbers and does not limit the
+ // number of charactes typed even if a range is set. Furthermore,
+ // it sometimes produces strange repaint artifacts.
+ var filtered = value.replace(/[^0-9]/g, '');
+ if (filtered != value)
+ inputField.value = filtered;
$('bluetooth-pair-device-connect-button').disabled =
- $('bluetooth-passkey').value.length == 0;
+ inputField.value.length == 0;
+ }
+ $('bluetooth-pincode').oninput = function() {
+ $('bluetooth-pair-device-connect-button').disabled =
+ $('bluetooth-pincode').value.length == 0;
}
},
@@ -151,20 +167,24 @@ cr.define('options', function() {
'bluetooth-pair-device-cancel-button']);
} else if (this.device_.pairing == PAIRING.ENTER_PIN_CODE) {
// Prompting the user to enter a PIN code.
- this.displayElements_(['bluetooth-pairing-passkey-entry',
+ this.displayElements_(['bluetooth-pairing-pincode-entry',
'bluetooth-pair-device-connect-button',
'bluetooth-pair-device-cancel-button']);
+ $('bluetooth-pincode').value = '';
} else if (this.device_.pairing == PAIRING.ENTER_PASSKEY) {
// Prompting the user to enter a passkey.
this.displayElements_(['bluetooth-pairing-passkey-entry',
'bluetooth-pair-device-connect-button',
'bluetooth-pair-device-cancel-button']);
+ $('bluetooth-passkey').value = '';
} else {
// Displaying an error message.
this.displayElements_(['bluetooth-pair-device-dismiss-button']);
}
- $('bluetooth-pair-device-connect-button').disabled =
- $('bluetooth-passkey').value.length == 0;
+ // User is required to enter a passkey or pincode before the connect
+ // button can be enabled. The 'oninput' methods for the input fields
+ // determine when the connect button becomes active.
+ $('bluetooth-pair-device-connect-button').disabled = true;
},
/**
« no previous file with comments | « chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698