Chromium Code Reviews| Index: chrome/browser/resources/chromeos/login/oobe_screen_hid_detection.js |
| diff --git a/chrome/browser/resources/chromeos/login/oobe_screen_hid_detection.js b/chrome/browser/resources/chromeos/login/oobe_screen_hid_detection.js |
| index 165dae7fa7c50c99fdddd466c14ea85c1e4fcb16..8c2117b3d17b1703063d3b3a82896c02d96a6975 100644 |
| --- a/chrome/browser/resources/chromeos/login/oobe_screen_hid_detection.js |
| +++ b/chrome/browser/resources/chromeos/login/oobe_screen_hid_detection.js |
| @@ -8,6 +8,30 @@ |
| login.createScreen('HIDDetectionScreen', 'hid-detection', function() { |
| return { |
| + EXTERNAL_API: [ |
| + 'setPointingDeviceState', |
| + 'setKeyboardDeviceState', |
| + ], |
| + |
| + /** |
| + * Enumeration of possible states during pairing. The value associated with |
| + * each state maps to a localized string in the global variable |
| + * |loadTimeData|. |
| + * @enum {string} |
| + */ |
| + PAIRING: { |
| + STARTUP: 'bluetoothStartConnecting', |
|
ygorshenin1
2014/04/25 15:05:08
nit: 2 spaces indent.
merkulova
2014/04/25 16:24:28
Done.
|
| + ENTER_PIN_CODE: 'bluetoothEnterPinCode', |
| + ENTER_PASSKEY: 'bluetoothEnterPasskey', |
| + REMOTE_PIN_CODE: 'bluetoothRemotePinCode', |
| + REMOTE_PASSKEY: 'bluetoothRemotePasskey', |
| + CONFIRM_PASSKEY: 'bluetoothConfirmPasskey', |
| + CONNECT_FAILED: 'bluetoothConnectFailed', |
| + CANCELED: 'bluetoothPairingCanceled', |
| + // Pairing dismissed(succeeded or canceled). |
|
ygorshenin1
2014/04/25 15:05:08
nit: a space before (.
merkulova
2014/04/25 16:24:28
Done.
|
| + DISMISSED: 'bluetoothPairingDismissed' |
| + }, |
| + |
| /** |
| * Button to move to usual OOBE flow after detection. |
| * @private |
| @@ -42,11 +66,88 @@ login.createScreen('HIDDetectionScreen', 'hid-detection', function() { |
| }, |
| /** |
| + * Sets a device-block css class to reflect device state of searching, |
| + * connected, pairing or paired (for BT devices). |
| + * @param {blockId} id one of 'hid-mouse-block' or 'hid-keyboard-block'. |
| + * @param {state} one of 'searching', 'connected', 'pairing', 'paired'. |
| + * @private |
| + */ |
| + setDeviceBlockState_: function(blockId, state) { |
| + var deviceBlock = $(blockId); |
| + var states = ['searching', 'connected', 'pairing', 'paired']; |
| + for (var i = 0; i < states.length; ++i) { |
| + if (states[i] != state) |
| + deviceBlock.classList.remove(states[i]); |
| + } |
| + deviceBlock.classList.add(state); |
| + }, |
| + |
| + /** |
| + * Sets state for mouse-block. |
| + * @param {state} one of 'searching', 'connected', 'paired'. |
| + */ |
| + setPointingDeviceState: function(state) { |
| + if (state === undefined) |
| + return; |
| + this.setDeviceBlockState_('hid-mouse-block', state); |
| + }, |
| + |
|
ygorshenin1
2014/04/25 15:05:08
Add a comment to setKeyboardDeviceState().
merkulova
2014/04/25 16:24:28
Done.
|
| + setKeyboardDeviceState: function(data) { |
|
ygorshenin1
2014/04/25 15:05:08
After discussion: could you please add a field 'st
merkulova
2014/04/25 16:24:28
Done.
|
| + if (data === undefined) |
| + return; |
| + if ('searching' in data) { |
| + this.setDeviceBlockState_('hid-keyboard-block', 'searching'); |
| + } else if ('connected' in data) { |
| + this.setDeviceBlockState_('hid-keyboard-block', 'connected'); |
| + } else if ('paired' in data) { |
| + this.setDeviceBlockState_('hid-keyboard-block', 'paired'); |
| + $('hid-keyboard-label-paired').textContent = data['keyboard-label']; |
| + } else if ('pairing' in data) { |
| + this.setDeviceBlockState_('hid-keyboard-block', 'pairing'); |
| + $('hid-keyboard-label-pairing').textContent = data['keyboard-label']; |
| + if (data['pairing'] == this.PAIRING.REMOTE_PIN_CODE) { |
| + // remove pincode pictures if exist. |
|
ygorshenin1
2014/04/25 15:05:08
nit: when your comment is a complete expression (w
merkulova
2014/04/25 16:24:28
Done.
|
| + var pincodeBlock = $('hid-keyboard-pincode'); |
| + while (pincodeBlock.firstChild.id != 'hid-keyboard-pincode-enter') { |
| + pincodeBlock.removeChild(pincodeBlock.firstChild); |
| + } |
|
ygorshenin1
2014/04/25 15:05:08
nit: curly braces are not needed here.
merkulova
2014/04/25 16:24:28
Done.
|
| + for (var i = 0, len = data['pincode'].length; i < len; i++) { |
| + var pincodeSymbol = this.ownerDocument.createElement('div'); |
| + pincodeSymbol.textContent = data['pincode'][i]; |
| + pincodeSymbol.classList.add('bluetooth-keyboard-button'); |
| + $('hid-keyboard-pincode').insertBefore( |
| + pincodeSymbol, $('hid-keyboard-pincode-enter')); |
| + } |
| + } |
| + } |
| + }, |
| + |
| + |
| + /** |
| * Event handler that is invoked just before the screen in shown. |
| * @param {Object} data Screen init payload. |
| */ |
| onBeforeShow: function(data) { |
| $('hid-continue-button').disabled = true; |
| + this.setDeviceBlockState_('hid-mouse-block', 'searching'); |
| + this.setDeviceBlockState_('hid-keyboard-block', 'searching'); |
| + }, |
| + |
| + addBluetoothDevice: function(device) { |
| + // One device can be in the process of pairing. If found, display |
|
ygorshenin1
2014/04/25 15:05:08
Incorrect indentation.
merkulova
2014/04/25 16:24:28
Done.
|
| + // the Bluetooth pairing overlay. |
| + if (device.pairing) |
| + this.showPairingLayout(device); |
| }, |
| + |
| + /** |
| + * Displays the pairing overlay. |
| + * @param {Object} device Description of the Bluetooth device. |
| + */ |
| + showPairingLayout: function(device) { |
| + BluetoothPairing.getInstance().update(device); |
| + OptionsPage.showPageByName('bluetoothPairing', false); |
| + }, |
| + |
|
ygorshenin1
2014/04/25 15:05:08
nit: delete a blank line.
merkulova
2014/04/25 16:24:28
Done.
|
| }; |
| }); |