Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
| 6 * @fileoverview Oobe HID detection screen implementation. | 6 * @fileoverview Oobe HID detection screen implementation. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 login.createScreen('HIDDetectionScreen', 'hid-detection', function() { | 9 login.createScreen('HIDDetectionScreen', 'hid-detection', function() { |
| 10 return { | 10 return { |
| 11 EXTERNAL_API: [ | |
| 12 'setPointingDeviceState', | |
| 13 'setKeyboardDeviceState', | |
| 14 ], | |
| 15 | |
| 16 /** | |
| 17 * Enumeration of possible states during pairing. The value associated with | |
| 18 * each state maps to a localized string in the global variable | |
| 19 * |loadTimeData|. | |
| 20 * @enum {string} | |
| 21 */ | |
| 22 PAIRING: { | |
| 23 STARTUP: 'bluetoothStartConnecting', | |
|
ygorshenin1
2014/04/25 15:05:08
nit: 2 spaces indent.
merkulova
2014/04/25 16:24:28
Done.
| |
| 24 ENTER_PIN_CODE: 'bluetoothEnterPinCode', | |
| 25 ENTER_PASSKEY: 'bluetoothEnterPasskey', | |
| 26 REMOTE_PIN_CODE: 'bluetoothRemotePinCode', | |
| 27 REMOTE_PASSKEY: 'bluetoothRemotePasskey', | |
| 28 CONFIRM_PASSKEY: 'bluetoothConfirmPasskey', | |
| 29 CONNECT_FAILED: 'bluetoothConnectFailed', | |
| 30 CANCELED: 'bluetoothPairingCanceled', | |
| 31 // Pairing dismissed(succeeded or canceled). | |
|
ygorshenin1
2014/04/25 15:05:08
nit: a space before (.
merkulova
2014/04/25 16:24:28
Done.
| |
| 32 DISMISSED: 'bluetoothPairingDismissed' | |
| 33 }, | |
| 34 | |
| 11 /** | 35 /** |
| 12 * Button to move to usual OOBE flow after detection. | 36 * Button to move to usual OOBE flow after detection. |
| 13 * @private | 37 * @private |
| 14 */ | 38 */ |
| 15 continueButton_: null, | 39 continueButton_: null, |
| 16 | 40 |
| 17 /** | 41 /** |
| 18 * Buttons in oobe wizard's button strip. | 42 * Buttons in oobe wizard's button strip. |
| 19 * @type {array} Array of Buttons. | 43 * @type {array} Array of Buttons. |
| 20 */ | 44 */ |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 35 }, | 59 }, |
| 36 | 60 |
| 37 /** | 61 /** |
| 38 * Returns a control which should receive an initial focus. | 62 * Returns a control which should receive an initial focus. |
| 39 */ | 63 */ |
| 40 get defaultControl() { | 64 get defaultControl() { |
| 41 return this.continueButton_; | 65 return this.continueButton_; |
| 42 }, | 66 }, |
| 43 | 67 |
| 44 /** | 68 /** |
| 69 * Sets a device-block css class to reflect device state of searching, | |
| 70 * connected, pairing or paired (for BT devices). | |
| 71 * @param {blockId} id one of 'hid-mouse-block' or 'hid-keyboard-block'. | |
| 72 * @param {state} one of 'searching', 'connected', 'pairing', 'paired'. | |
| 73 * @private | |
| 74 */ | |
| 75 setDeviceBlockState_: function(blockId, state) { | |
| 76 var deviceBlock = $(blockId); | |
| 77 var states = ['searching', 'connected', 'pairing', 'paired']; | |
| 78 for (var i = 0; i < states.length; ++i) { | |
| 79 if (states[i] != state) | |
| 80 deviceBlock.classList.remove(states[i]); | |
| 81 } | |
| 82 deviceBlock.classList.add(state); | |
| 83 }, | |
| 84 | |
| 85 /** | |
| 86 * Sets state for mouse-block. | |
| 87 * @param {state} one of 'searching', 'connected', 'paired'. | |
| 88 */ | |
| 89 setPointingDeviceState: function(state) { | |
| 90 if (state === undefined) | |
| 91 return; | |
| 92 this.setDeviceBlockState_('hid-mouse-block', state); | |
| 93 }, | |
| 94 | |
|
ygorshenin1
2014/04/25 15:05:08
Add a comment to setKeyboardDeviceState().
merkulova
2014/04/25 16:24:28
Done.
| |
| 95 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.
| |
| 96 if (data === undefined) | |
| 97 return; | |
| 98 if ('searching' in data) { | |
| 99 this.setDeviceBlockState_('hid-keyboard-block', 'searching'); | |
| 100 } else if ('connected' in data) { | |
| 101 this.setDeviceBlockState_('hid-keyboard-block', 'connected'); | |
| 102 } else if ('paired' in data) { | |
| 103 this.setDeviceBlockState_('hid-keyboard-block', 'paired'); | |
| 104 $('hid-keyboard-label-paired').textContent = data['keyboard-label']; | |
| 105 } else if ('pairing' in data) { | |
| 106 this.setDeviceBlockState_('hid-keyboard-block', 'pairing'); | |
| 107 $('hid-keyboard-label-pairing').textContent = data['keyboard-label']; | |
| 108 if (data['pairing'] == this.PAIRING.REMOTE_PIN_CODE) { | |
| 109 // 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.
| |
| 110 var pincodeBlock = $('hid-keyboard-pincode'); | |
| 111 while (pincodeBlock.firstChild.id != 'hid-keyboard-pincode-enter') { | |
| 112 pincodeBlock.removeChild(pincodeBlock.firstChild); | |
| 113 } | |
|
ygorshenin1
2014/04/25 15:05:08
nit: curly braces are not needed here.
merkulova
2014/04/25 16:24:28
Done.
| |
| 114 for (var i = 0, len = data['pincode'].length; i < len; i++) { | |
| 115 var pincodeSymbol = this.ownerDocument.createElement('div'); | |
| 116 pincodeSymbol.textContent = data['pincode'][i]; | |
| 117 pincodeSymbol.classList.add('bluetooth-keyboard-button'); | |
| 118 $('hid-keyboard-pincode').insertBefore( | |
| 119 pincodeSymbol, $('hid-keyboard-pincode-enter')); | |
| 120 } | |
| 121 } | |
| 122 } | |
| 123 }, | |
| 124 | |
| 125 | |
| 126 /** | |
| 45 * Event handler that is invoked just before the screen in shown. | 127 * Event handler that is invoked just before the screen in shown. |
| 46 * @param {Object} data Screen init payload. | 128 * @param {Object} data Screen init payload. |
| 47 */ | 129 */ |
| 48 onBeforeShow: function(data) { | 130 onBeforeShow: function(data) { |
| 49 $('hid-continue-button').disabled = true; | 131 $('hid-continue-button').disabled = true; |
| 132 this.setDeviceBlockState_('hid-mouse-block', 'searching'); | |
| 133 this.setDeviceBlockState_('hid-keyboard-block', 'searching'); | |
| 50 }, | 134 }, |
| 135 | |
| 136 addBluetoothDevice: function(device) { | |
| 137 // 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.
| |
| 138 // the Bluetooth pairing overlay. | |
| 139 if (device.pairing) | |
| 140 this.showPairingLayout(device); | |
| 141 }, | |
| 142 | |
| 143 /** | |
| 144 * Displays the pairing overlay. | |
| 145 * @param {Object} device Description of the Bluetooth device. | |
| 146 */ | |
| 147 showPairingLayout: function(device) { | |
| 148 BluetoothPairing.getInstance().update(device); | |
| 149 OptionsPage.showPageByName('bluetoothPairing', false); | |
| 150 }, | |
| 151 | |
|
ygorshenin1
2014/04/25 15:05:08
nit: delete a blank line.
merkulova
2014/04/25 16:24:28
Done.
| |
| 51 }; | 152 }; |
| 52 }); | 153 }); |
| OLD | NEW |