| 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..f038c9618f5802137289099433f77a2abbfd8c98 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,27 @@
|
|
|
| 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',
|
| + REMOTE_PIN_CODE: 'bluetoothRemotePinCode',
|
| + REMOTE_PASSKEY: 'bluetoothRemotePasskey',
|
| + CONNECT_FAILED: 'bluetoothConnectFailed',
|
| + CANCELED: 'bluetoothPairingCanceled',
|
| + // Pairing dismissed (succeeded or canceled).
|
| + DISMISSED: 'bluetoothPairingDismissed'
|
| + },
|
| +
|
| /**
|
| * Button to move to usual OOBE flow after detection.
|
| * @private
|
| @@ -42,11 +63,107 @@ 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) {
|
| + if (state == 'update')
|
| + return;
|
| + 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);
|
| + },
|
| +
|
| + /**
|
| + * Sets state for pincode key elements.
|
| + * @param {entered} int, number of typed keys of pincode, -1 if keys press
|
| + * detection is not supported by device.
|
| + */
|
| + setPincodeKeysState_: function(entered) {
|
| + var pincodeLength = 7; // including enter-key
|
| + for (var i = 0; i < pincodeLength; i++) {
|
| + var pincodeSymbol = $('hid-keyboard-pincode-sym-' + (i + 1));
|
| + pincodeSymbol.classList.remove('key-typed');
|
| + pincodeSymbol.classList.remove('key-untyped');
|
| + pincodeSymbol.classList.remove('key-next');
|
| + if (i < entered)
|
| + pincodeSymbol.classList.add('key-typed');
|
| + else if (i == entered)
|
| + pincodeSymbol.classList.add('key-next');
|
| + else if (entered != -1)
|
| + pincodeSymbol.classList.add('key-untyped');
|
| + }
|
| + },
|
| +
|
| + /**
|
| + * Sets state for keyboard-block.
|
| + * @param {data} dict with parameters.
|
| + */
|
| + setKeyboardDeviceState: function(data) {
|
| + if (data === undefined || !('state' in data))
|
| + return;
|
| + var state = data['state'];
|
| + this.setDeviceBlockState_('hid-keyboard-block', state);
|
| + if (state == 'paired')
|
| + $('hid-keyboard-label-paired').textContent = data['keyboard-label'];
|
| + else if (state == 'pairing') {
|
| + $('hid-keyboard-label-pairing').textContent = data['keyboard-label'];
|
| + if (data['pairing-state'] == this.PAIRING.REMOTE_PIN_CODE ||
|
| + data['pairing-state'] == this.PAIRING.REMOTE_PASSKEY) {
|
| + this.setPincodeKeysState_(-1);
|
| + for (var i = 0, len = data['pincode'].length; i < len; i++) {
|
| + var pincodeSymbol = $('hid-keyboard-pincode-sym-' + (i + 1));
|
| + pincodeSymbol.textContent = data['pincode'][i];
|
| + }
|
| + }
|
| + } else if (state == 'update') {
|
| + if ('keysEntered' in data) {
|
| + this.setPincodeKeysState_(data['keysEntered']);
|
| + }
|
| + }
|
| + },
|
| +
|
| + /**
|
| * 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
|
| + // 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);
|
| },
|
| };
|
| });
|
|
|