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

Side by Side Diff: chrome/browser/resources/chromeos/login/oobe_screen_hid_detection.js

Issue 252503002: Base version of HID detection OOBE screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Logic bug-fix. Progress dots hidden. Style improved. BT names support. Created 6 years, 8 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
OLDNEW
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',
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).
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
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
95 /**
96 * Sets state for keyboard-block.
97 * @param {data} dict with parameters.
98 */
99 setKeyboardDeviceState: function(data) {
100 if (data === undefined || !('state' in data))
101 return;
102 var state = data['state'];
103 this.setDeviceBlockState_('hid-keyboard-block', state);
104 if (state == 'paired')
105 $('hid-keyboard-label-paired').textContent = data['keyboard-label'];
106 else if (state == 'pairing') {
107 $('hid-keyboard-label-pairing').textContent = data['keyboard-label'];
108 if (data['pairing-state'] == this.PAIRING.REMOTE_PIN_CODE) {
109 // Remove pincode pictures if exist.
110 var pincodeBlock = $('hid-keyboard-pincode');
111 while (pincodeBlock.firstChild.id != 'hid-keyboard-pincode-enter')
112 pincodeBlock.removeChild(pincodeBlock.firstChild);
113 for (var i = 0, len = data['pincode'].length; i < len; i++) {
114 var pincodeSymbol = this.ownerDocument.createElement('div');
115 pincodeSymbol.textContent = data['pincode'][i];
116 pincodeSymbol.classList.add('bluetooth-keyboard-button');
117 $('hid-keyboard-pincode').insertBefore(
118 pincodeSymbol, $('hid-keyboard-pincode-enter'));
119 }
120 }
121 }
122 },
123
124
125 /**
45 * Event handler that is invoked just before the screen in shown. 126 * Event handler that is invoked just before the screen in shown.
46 * @param {Object} data Screen init payload. 127 * @param {Object} data Screen init payload.
47 */ 128 */
48 onBeforeShow: function(data) { 129 onBeforeShow: function(data) {
49 $('hid-continue-button').disabled = true; 130 $('hid-continue-button').disabled = true;
131 this.setDeviceBlockState_('hid-mouse-block', 'searching');
132 this.setDeviceBlockState_('hid-keyboard-block', 'searching');
133 },
134
135 addBluetoothDevice: function(device) {
136 // One device can be in the process of pairing. If found, display
137 // the Bluetooth pairing overlay.
138 if (device.pairing)
139 this.showPairingLayout(device);
140 },
141
142 /**
143 * Displays the pairing overlay.
144 * @param {Object} device Description of the Bluetooth device.
145 */
146 showPairingLayout: function(device) {
147 BluetoothPairing.getInstance().update(device);
148 OptionsPage.showPageByName('bluetoothPairing', false);
50 }, 149 },
51 }; 150 };
52 }); 151 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698