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

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

Issue 770563003: HID fix for device info check. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dicts used. Created 5 years, 12 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
(...skipping 11 matching lines...) Expand all
22 PAIRING: { 22 PAIRING: {
23 STARTUP: 'bluetoothStartConnecting', 23 STARTUP: 'bluetoothStartConnecting',
24 REMOTE_PIN_CODE: 'bluetoothRemotePinCode', 24 REMOTE_PIN_CODE: 'bluetoothRemotePinCode',
25 REMOTE_PASSKEY: 'bluetoothRemotePasskey', 25 REMOTE_PASSKEY: 'bluetoothRemotePasskey',
26 CONNECT_FAILED: 'bluetoothConnectFailed', 26 CONNECT_FAILED: 'bluetoothConnectFailed',
27 CANCELED: 'bluetoothPairingCanceled', 27 CANCELED: 'bluetoothPairingCanceled',
28 // Pairing dismissed (succeeded or canceled). 28 // Pairing dismissed (succeeded or canceled).
29 DISMISSED: 'bluetoothPairingDismissed' 29 DISMISSED: 'bluetoothPairingDismissed'
30 }, 30 },
31 31
32 // Enumeration of possible connection states of a device.
33 CONNECTION: {
34 SEARCHING: 'searching',
35 CONNECTED: 'connected',
36 PAIRING: 'pairing',
37 PAIRED: 'paired',
38 // Special info state.
39 UPDATE: 'update'
40 },
41
42 // Possible ids of device blocks.
43 BLOCK: {
44 MOUSE: 'hid-mouse-block',
45 KEYBOARD: 'hid-keyboard-block'
46 },
47
32 /** 48 /**
33 * Button to move to usual OOBE flow after detection. 49 * Button to move to usual OOBE flow after detection.
34 * @private 50 * @private
35 */ 51 */
36 continueButton_: null, 52 continueButton_: null,
37 53
38 /** 54 /**
39 * Buttons in oobe wizard's button strip. 55 * Buttons in oobe wizard's button strip.
40 * @type {array} Array of Buttons. 56 * @type {array} Array of Buttons.
41 */ 57 */
(...skipping 16 matching lines...) Expand all
58 /** 74 /**
59 * Returns a control which should receive an initial focus. 75 * Returns a control which should receive an initial focus.
60 */ 76 */
61 get defaultControl() { 77 get defaultControl() {
62 return this.continueButton_; 78 return this.continueButton_;
63 }, 79 },
64 80
65 /** 81 /**
66 * Sets a device-block css class to reflect device state of searching, 82 * Sets a device-block css class to reflect device state of searching,
67 * connected, pairing or paired (for BT devices). 83 * connected, pairing or paired (for BT devices).
68 * @param {blockId} id one of 'hid-mouse-block' or 'hid-keyboard-block'. 84 * @param {blockId} id one of keys of this.BLOCK dict.
69 * @param {state} one of 'searching', 'connected', 'pairing', 'paired', 85 * @param {state} one of keys of this.CONNECTION dict.
70 * @private 86 * @private
71 */ 87 */
72 setDeviceBlockState_: function(blockId, state) { 88 setDeviceBlockState_: function(blockId, state) {
73 if (state == 'update') 89 if (state == 'update')
74 return; 90 return;
75 var deviceBlock = $(blockId); 91 var deviceBlock = $(blockId);
76 var states = ['searching', 'connected', 'pairing', 'paired']; 92 for (var stateCase in this.CONNECTION) {
77 for (var i = 0; i < states.length; ++i) { 93 if (stateCase != state)
78 if (states[i] != state) 94 deviceBlock.classList.remove(stateCase);
Denis Kuznetsov (DE-MUC) 2015/02/05 13:26:17 You can use .toggle(name, value) here.
79 deviceBlock.classList.remove(states[i]);
80 } 95 }
81 deviceBlock.classList.add(state); 96 deviceBlock.classList.add(state);
97
98 // 'Continue' button available iff at least one device is connected,
99 if ((blockId in this.BLOCK) &&
100 (state == this.CONNECTION.CONNECTED ||
101 state == this.CONNECTION.PAIRED)) {
102 $('hid-continue-button').disabled = false;
103 } else {
104 $('hid-continue-button').disabled = true;
105 }
82 }, 106 },
83 107
84 /** 108 /**
85 * Sets state for mouse-block. 109 * Sets state for mouse-block.
86 * @param {state} one of 'searching', 'connected', 'paired'. 110 * @param {state} one of keys of this.CONNECTION dict.
87 */ 111 */
88 setPointingDeviceState: function(state) { 112 setPointingDeviceState: function(state) {
89 if (state === undefined) 113 if (state === undefined)
90 return; 114 return;
91 this.setDeviceBlockState_('hid-mouse-block', state); 115 this.setDeviceBlockState_(this.BLOCK.MOUSE, state);
92 }, 116 },
93 117
94 /** 118 /**
95 * Sets state for pincode key elements. 119 * Sets state for pincode key elements.
96 * @param {entered} int, number of typed keys of pincode, -1 if keys press 120 * @param {entered} int, number of typed keys of pincode, -1 if keys press
97 * detection is not supported by device. 121 * detection is not supported by device.
98 */ 122 */
99 setPincodeKeysState_: function(entered) { 123 setPincodeKeysState_: function(entered) {
100 var pincodeLength = 7; // including enter-key 124 var pincodeLength = 7; // including enter-key
101 for (var i = 0; i < pincodeLength; i++) { 125 for (var i = 0; i < pincodeLength; i++) {
(...skipping 11 matching lines...) Expand all
113 }, 137 },
114 138
115 /** 139 /**
116 * Sets state for keyboard-block. 140 * Sets state for keyboard-block.
117 * @param {data} dict with parameters. 141 * @param {data} dict with parameters.
118 */ 142 */
119 setKeyboardDeviceState: function(data) { 143 setKeyboardDeviceState: function(data) {
120 if (data === undefined || !('state' in data)) 144 if (data === undefined || !('state' in data))
121 return; 145 return;
122 var state = data['state']; 146 var state = data['state'];
123 this.setDeviceBlockState_('hid-keyboard-block', state); 147 this.setDeviceBlockState_(this.BLOCK.KEYBOARD, state);
124 if (state == 'paired') 148 if (state == this.CONNECTION.PAIRED)
125 $('hid-keyboard-label-paired').textContent = data['keyboard-label']; 149 $('hid-keyboard-label-paired').textContent = data['keyboard-label'];
126 else if (state == 'pairing') { 150 else if (state == this.CONNECTION.PAIRING) {
127 $('hid-keyboard-label-pairing').textContent = data['keyboard-label']; 151 $('hid-keyboard-label-pairing').textContent = data['keyboard-label'];
128 if (data['pairing-state'] == this.PAIRING.REMOTE_PIN_CODE || 152 if (data['pairing-state'] == this.PAIRING.REMOTE_PIN_CODE ||
129 data['pairing-state'] == this.PAIRING.REMOTE_PASSKEY) { 153 data['pairing-state'] == this.PAIRING.REMOTE_PASSKEY) {
130 this.setPincodeKeysState_(-1); 154 this.setPincodeKeysState_(-1);
131 for (var i = 0, len = data['pincode'].length; i < len; i++) { 155 for (var i = 0, len = data['pincode'].length; i < len; i++) {
132 var pincodeSymbol = $('hid-keyboard-pincode-sym-' + (i + 1)); 156 var pincodeSymbol = $('hid-keyboard-pincode-sym-' + (i + 1));
133 pincodeSymbol.textContent = data['pincode'][i]; 157 pincodeSymbol.textContent = data['pincode'][i];
134 } 158 }
135 announceAccessibleMessage( 159 announceAccessibleMessage(
136 data['keyboard-label'] + ' ' + data['pincode'] + ' ' + 160 data['keyboard-label'] + ' ' + data['pincode'] + ' ' +
137 loadTimeData.getString('hidDetectionBTEnterKey')); 161 loadTimeData.getString('hidDetectionBTEnterKey'));
138 } 162 }
139 } else if (state == 'update') { 163 } else if (state == this.CONNECTION.UPDATE) {
140 if ('keysEntered' in data) { 164 if ('keysEntered' in data) {
141 this.setPincodeKeysState_(data['keysEntered']); 165 this.setPincodeKeysState_(data['keysEntered']);
142 } 166 }
143 } 167 }
144 }, 168 },
145
146 /**
147 * Event handler that is invoked just before the screen in shown.
148 * @param {Object} data Screen init payload.
149 */
150 onBeforeShow: function(data) {
151 $('hid-continue-button').disabled = true;
152 this.setDeviceBlockState_('hid-mouse-block', 'searching');
153 this.setDeviceBlockState_('hid-keyboard-block', 'searching');
154 },
155 }; 169 };
156 }); 170 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698