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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options', function() { 5 cr.define('options', function() {
6 /** @const */ var OptionsPage = options.OptionsPage; 6 /** @const */ var OptionsPage = options.OptionsPage;
7 7
8 /** 8 /**
9 * Enumeration of possible states during pairing. The value associated with 9 * Enumeration of possible states during pairing. The value associated with
10 * each state maps to a localized string in the global variable 10 * each state maps to a localized string in the global variable
(...skipping 12 matching lines...) Expand all
23 ERROR_CONNECTION_FAILED: 'bluetoothErrorConnectionFailed' 23 ERROR_CONNECTION_FAILED: 'bluetoothErrorConnectionFailed'
24 }; 24 };
25 25
26 /** 26 /**
27 * List of IDs for conditionally visible elements in the dialog. 27 * List of IDs for conditionally visible elements in the dialog.
28 * @type {Array.<String>} 28 * @type {Array.<String>}
29 * @const 29 * @const
30 */ 30 */
31 var ELEMENTS = ['bluetooth-pairing-passkey-display', 31 var ELEMENTS = ['bluetooth-pairing-passkey-display',
32 'bluetooth-pairing-passkey-entry', 32 'bluetooth-pairing-passkey-entry',
33 'bluetooth-pairing-pincode-entry',
33 'bluetooth-pair-device-connect-button', 34 'bluetooth-pair-device-connect-button',
34 'bluetooth-pair-device-cancel-button', 35 'bluetooth-pair-device-cancel-button',
35 'bluetooth-pair-device-accept-button', 36 'bluetooth-pair-device-accept-button',
36 'bluetooth-pair-device-reject-button', 37 'bluetooth-pair-device-reject-button',
37 'bluetooth-pair-device-dismiss-button']; 38 'bluetooth-pair-device-dismiss-button'];
38 39
39 40
40 /** 41 /**
41 * Encapsulated handling of the Bluetooth device pairing page. 42 * Encapsulated handling of the Bluetooth device pairing page.
42 * @constructor 43 * @constructor
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 OptionsPage.closeOverlay(); 79 OptionsPage.closeOverlay();
79 }; 80 };
80 $('bluetooth-pair-device-reject-button').onclick = function() { 81 $('bluetooth-pair-device-reject-button').onclick = function() {
81 chrome.send('updateBluetoothDevice', 82 chrome.send('updateBluetoothDevice',
82 [self.device_.address, 'reject']); 83 [self.device_.address, 'reject']);
83 OptionsPage.closeOverlay(); 84 OptionsPage.closeOverlay();
84 }; 85 };
85 $('bluetooth-pair-device-connect-button').onclick = function() { 86 $('bluetooth-pair-device-connect-button').onclick = function() {
86 var args = [self.device_.address, 'connect']; 87 var args = [self.device_.address, 'connect'];
87 var passkey = self.device_.passkey; 88 var passkey = self.device_.passkey;
88 if (!passkey && !$('bluetooth-pairing-passkey-entry').hidden)
89 passkey = $('bluetooth-passkey').value;
90 if (passkey) 89 if (passkey)
91 args.push(String(passkey)); 90 args.push(String(passkey));
91 else if (!$('bluetooth-pairing-passkey-entry').hidden)
92 args.push($('bluetooth-passkey').value);
93 else if (!$('bluetooth-pairing-pincode-entry').hidden)
94 args.push($('bluetooth-pincode').value);
92 chrome.send('updateBluetoothDevice', args); 95 chrome.send('updateBluetoothDevice', args);
93 OptionsPage.closeOverlay(); 96 OptionsPage.closeOverlay();
94 }; 97 };
95 $('bluetooth-pair-device-accept-button').onclick = function() { 98 $('bluetooth-pair-device-accept-button').onclick = function() {
96 chrome.send('updateBluetoothDevice', 99 chrome.send('updateBluetoothDevice',
97 [self.device_.address, 'accept']); 100 [self.device_.address, 'accept']);
98 OptionsPage.closeOverlay(); 101 OptionsPage.closeOverlay();
99 }; 102 };
100 $('bluetooth-pair-device-dismiss-button').onclick = function() { 103 $('bluetooth-pair-device-dismiss-button').onclick = function() {
101 OptionsPage.closeOverlay(); 104 OptionsPage.closeOverlay();
102 }; 105 };
103 $('bluetooth-passkey').oninput = function() { 106 $('bluetooth-passkey').oninput = function() {
107 var inputField = $('bluetooth-passkey');
108 var value = inputField.value;
109 // Note that using <input type="number"> is insufficient to restrict
110 // the input as it allows negative numbers and does not limit the
111 // number of charactes typed even if a range is set. Furthermore,
112 // it sometimes produces strange repaint artifacts.
113 var filtered = value.replace(/[^0-9]/g, '');
114 if (filtered != value)
115 inputField.value = filtered;
104 $('bluetooth-pair-device-connect-button').disabled = 116 $('bluetooth-pair-device-connect-button').disabled =
105 $('bluetooth-passkey').value.length == 0; 117 inputField.value.length == 0;
118 }
119 $('bluetooth-pincode').oninput = function() {
120 $('bluetooth-pair-device-connect-button').disabled =
121 $('bluetooth-pincode').value.length == 0;
106 } 122 }
107 }, 123 },
108 124
109 /** 125 /**
110 * Override to prevent showing the overlay if the Bluetooth device details 126 * Override to prevent showing the overlay if the Bluetooth device details
111 * have not been specified. Prevents showing an empty dialog if the user 127 * have not been specified. Prevents showing an empty dialog if the user
112 * quits and restarts Chrome while in the process of pairing with a device. 128 * quits and restarts Chrome while in the process of pairing with a device.
113 * @return {boolean} True if the overlay can be displayed. 129 * @return {boolean} True if the overlay can be displayed.
114 */ 130 */
115 canShowPage: function() { 131 canShowPage: function() {
(...skipping 28 matching lines...) Expand all
144 // Remote entering a passkey. 160 // Remote entering a passkey.
145 this.displayElements_(['bluetooth-pairing-passkey-display', 161 this.displayElements_(['bluetooth-pairing-passkey-display',
146 'bluetooth-pair-device-cancel-button']); 162 'bluetooth-pair-device-cancel-button']);
147 } 163 }
148 } else if (this.device_.pincode) { 164 } else if (this.device_.pincode) {
149 this.updatePinCode_(); 165 this.updatePinCode_();
150 this.displayElements_(['bluetooth-pairing-passkey-display', 166 this.displayElements_(['bluetooth-pairing-passkey-display',
151 'bluetooth-pair-device-cancel-button']); 167 'bluetooth-pair-device-cancel-button']);
152 } else if (this.device_.pairing == PAIRING.ENTER_PIN_CODE) { 168 } else if (this.device_.pairing == PAIRING.ENTER_PIN_CODE) {
153 // Prompting the user to enter a PIN code. 169 // Prompting the user to enter a PIN code.
154 this.displayElements_(['bluetooth-pairing-passkey-entry', 170 this.displayElements_(['bluetooth-pairing-pincode-entry',
155 'bluetooth-pair-device-connect-button', 171 'bluetooth-pair-device-connect-button',
156 'bluetooth-pair-device-cancel-button']); 172 'bluetooth-pair-device-cancel-button']);
173 $('bluetooth-pincode').value = '';
157 } else if (this.device_.pairing == PAIRING.ENTER_PASSKEY) { 174 } else if (this.device_.pairing == PAIRING.ENTER_PASSKEY) {
158 // Prompting the user to enter a passkey. 175 // Prompting the user to enter a passkey.
159 this.displayElements_(['bluetooth-pairing-passkey-entry', 176 this.displayElements_(['bluetooth-pairing-passkey-entry',
160 'bluetooth-pair-device-connect-button', 177 'bluetooth-pair-device-connect-button',
161 'bluetooth-pair-device-cancel-button']); 178 'bluetooth-pair-device-cancel-button']);
179 $('bluetooth-passkey').value = '';
162 } else { 180 } else {
163 // Displaying an error message. 181 // Displaying an error message.
164 this.displayElements_(['bluetooth-pair-device-dismiss-button']); 182 this.displayElements_(['bluetooth-pair-device-dismiss-button']);
165 } 183 }
166 $('bluetooth-pair-device-connect-button').disabled = 184 // User is required to enter a passkey or pincode before the connect
167 $('bluetooth-passkey').value.length == 0; 185 // button can be enabled. The 'oninput' methods for the input fields
186 // determine when the connect button becomes active.
187 $('bluetooth-pair-device-connect-button').disabled = true;
168 }, 188 },
169 189
170 /** 190 /**
171 * Updates the visibility of elements in the dialog. 191 * Updates the visibility of elements in the dialog.
172 * @param {Array.<string>} list List of conditionally visible elements that 192 * @param {Array.<string>} list List of conditionally visible elements that
173 * are to be made visible. 193 * are to be made visible.
174 * @private 194 * @private
175 */ 195 */
176 displayElements_: function(list) { 196 displayElements_: function(list) {
177 var enabled = {}; 197 var enabled = {};
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 BluetoothPairing.showDialog = function(device) { 285 BluetoothPairing.showDialog = function(device) {
266 BluetoothPairing.getInstance().update(device); 286 BluetoothPairing.getInstance().update(device);
267 OptionsPage.navigateToPage('bluetoothPairing'); 287 OptionsPage.navigateToPage('bluetoothPairing');
268 }; 288 };
269 289
270 // Export 290 // Export
271 return { 291 return {
272 BluetoothPairing: BluetoothPairing 292 BluetoothPairing: BluetoothPairing
273 }; 293 };
274 }); 294 });
OLDNEW
« 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