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

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: Passkey support added. Improved BT-connection logic. Created 6 years, 7 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 REMOTE_PIN_CODE: 'bluetoothRemotePinCode',
25 REMOTE_PASSKEY: 'bluetoothRemotePasskey',
26 CONNECT_FAILED: 'bluetoothConnectFailed',
27 CANCELED: 'bluetoothPairingCanceled',
28 // Pairing dismissed (succeeded or canceled).
29 DISMISSED: 'bluetoothPairingDismissed'
30 },
31
11 /** 32 /**
12 * Button to move to usual OOBE flow after detection. 33 * Button to move to usual OOBE flow after detection.
13 * @private 34 * @private
14 */ 35 */
15 continueButton_: null, 36 continueButton_: null,
16 37
17 /** 38 /**
18 * Buttons in oobe wizard's button strip. 39 * Buttons in oobe wizard's button strip.
19 * @type {array} Array of Buttons. 40 * @type {array} Array of Buttons.
20 */ 41 */
(...skipping 14 matching lines...) Expand all
35 }, 56 },
36 57
37 /** 58 /**
38 * Returns a control which should receive an initial focus. 59 * Returns a control which should receive an initial focus.
39 */ 60 */
40 get defaultControl() { 61 get defaultControl() {
41 return this.continueButton_; 62 return this.continueButton_;
42 }, 63 },
43 64
44 /** 65 /**
66 * Sets a device-block css class to reflect device state of searching,
67 * connected, pairing or paired (for BT devices).
68 * @param {blockId} id one of 'hid-mouse-block' or 'hid-keyboard-block'.
69 * @param {state} one of 'searching', 'connected', 'pairing', 'paired'.
70 * @private
71 */
72 setDeviceBlockState_: function(blockId, state) {
73 var deviceBlock = $(blockId);
74 var states = ['searching', 'connected', 'pairing', 'paired'];
75 for (var i = 0; i < states.length; ++i) {
76 if (states[i] != state)
77 deviceBlock.classList.remove(states[i]);
78 }
79 deviceBlock.classList.add(state);
80 },
81
82 /**
83 * Sets state for mouse-block.
84 * @param {state} one of 'searching', 'connected', 'paired'.
85 */
86 setPointingDeviceState: function(state) {
87 if (state === undefined)
88 return;
89 this.setDeviceBlockState_('hid-mouse-block', state);
90 },
91
92 /**
93 * Sets state for keyboard-block.
94 * @param {data} dict with parameters.
95 */
96 setKeyboardDeviceState: function(data) {
97 if (data === undefined || !('state' in data))
98 return;
99 var state = data['state'];
100 this.setDeviceBlockState_('hid-keyboard-block', state);
101 if (state == 'paired')
102 $('hid-keyboard-label-paired').textContent = data['keyboard-label'];
103 else if (state == 'pairing') {
104 $('hid-keyboard-label-pairing').textContent = data['keyboard-label'];
105 if (data['pairing-state'] == this.PAIRING.REMOTE_PIN_CODE ||
106 data['pairing-state'] == this.PAIRING.REMOTE_PASSKEY) {
107 for (var i = 0, len = data['pincode'].length; i < len; i++) {
108 var pincodeSymbol = $('hid-keyboard-pincode-sym-' + (i + 1));
109 pincodeSymbol.textContent = data['pincode'][i];
110 }
111 }
112 }
113 },
114
115
116 /**
45 * Event handler that is invoked just before the screen in shown. 117 * Event handler that is invoked just before the screen in shown.
46 * @param {Object} data Screen init payload. 118 * @param {Object} data Screen init payload.
47 */ 119 */
48 onBeforeShow: function(data) { 120 onBeforeShow: function(data) {
49 $('hid-continue-button').disabled = true; 121 $('hid-continue-button').disabled = true;
122 this.setDeviceBlockState_('hid-mouse-block', 'searching');
123 this.setDeviceBlockState_('hid-keyboard-block', 'searching');
124 },
125
126 addBluetoothDevice: function(device) {
127 // One device can be in the process of pairing. If found, display
128 // the Bluetooth pairing overlay.
129 if (device.pairing)
130 this.showPairingLayout(device);
131 },
132
133 /**
134 * Displays the pairing overlay.
135 * @param {Object} device Description of the Bluetooth device.
136 */
137 showPairingLayout: function(device) {
138 BluetoothPairing.getInstance().update(device);
139 OptionsPage.showPageByName('bluetoothPairing', false);
50 }, 140 },
51 }; 141 };
52 }); 142 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698