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

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

Issue 1243983002: Fixed Bluetooth keyboard pairing pincode visibility issue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed. Created 5 years, 5 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
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 var CONTEXT_KEY_KEYBOARD_STATE = 'keyboard-state'; 10 var CONTEXT_KEY_KEYBOARD_STATE = 'keyboard-state';
11 var CONTEXT_KEY_MOUSE_STATE = 'mouse-state'; 11 var CONTEXT_KEY_MOUSE_STATE = 'mouse-state';
12 var CONTEXT_KEY_KEYBOARD_PINCODE = 'keyboard-pincode'; 12 var CONTEXT_KEY_KEYBOARD_PINCODE = 'keyboard-pincode';
13 var CONTEXT_KEY_KEYBOARD_ENTERED_PART_EXPECTED = 'num-keys-entered-expected'; 13 var CONTEXT_KEY_KEYBOARD_ENTERED_PART_EXPECTED = 'num-keys-entered-expected';
14 var CONTEXT_KEY_KEYBOARD_ENTERED_PART_PINCODE = 'num-keys-entered-pincode'; 14 var CONTEXT_KEY_KEYBOARD_ENTERED_PART_PINCODE = 'num-keys-entered-pincode';
15 var CONTEXT_KEY_MOUSE_DEVICE_NAME = 'mouse-device-name'; 15 var CONTEXT_KEY_MOUSE_DEVICE_NAME = 'mouse-device-name';
16 var CONTEXT_KEY_KEYBOARD_DEVICE_NAME = 'keyboard-device-name'; 16 var CONTEXT_KEY_KEYBOARD_DEVICE_NAME = 'keyboard-device-name';
17 var CONTEXT_KEY_KEYBOARD_LABEL = 'keyboard-device-label'; 17 var CONTEXT_KEY_KEYBOARD_LABEL = 'keyboard-device-label';
18 var CONTEXT_KEY_CONTINUE_BUTTON_ENABLED = 'continue-button-enabled'; 18 var CONTEXT_KEY_CONTINUE_BUTTON_ENABLED = 'continue-button-enabled';
19 19
20 var PINCODE_LENGTH = 6;
21
20 return { 22 return {
21 23
22 /** 24 /**
23 * Enumeration of possible states during pairing. The value associated with 25 * Enumeration of possible states during pairing. The value associated with
24 * each state maps to a localized string in the global variable 26 * each state maps to a localized string in the global variable
25 * |loadTimeData|. 27 * |loadTimeData|.
26 * @enum {string} 28 * @enum {string}
27 */ 29 */
28 PAIRING: { 30 PAIRING: {
29 STARTUP: 'bluetoothStartConnecting', 31 STARTUP: 'bluetoothStartConnecting',
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 CONTEXT_KEY_MOUSE_STATE, 66 CONTEXT_KEY_MOUSE_STATE,
65 function(stateId) { 67 function(stateId) {
66 if (stateId === undefined) 68 if (stateId === undefined)
67 return; 69 return;
68 self.setDeviceBlockState_('hid-mouse-block', stateId); 70 self.setDeviceBlockState_('hid-mouse-block', stateId);
69 } 71 }
70 ); 72 );
71 this.context.addObserver( 73 this.context.addObserver(
72 CONTEXT_KEY_KEYBOARD_STATE, 74 CONTEXT_KEY_KEYBOARD_STATE,
73 function(stateId) { 75 function(stateId) {
76 self.updatePincodeKeysState_();
74 if (stateId === undefined) 77 if (stateId === undefined)
75 return; 78 return;
76 self.setDeviceBlockState_('hid-keyboard-block', stateId); 79 self.setDeviceBlockState_('hid-keyboard-block', stateId);
77 if (stateId == self.CONNECTION.PAIRED) { 80 if (stateId == self.CONNECTION.PAIRED) {
78 $('hid-keyboard-label-paired').textContent = self.context.get( 81 $('hid-keyboard-label-paired').textContent = self.context.get(
79 CONTEXT_KEY_KEYBOARD_LABEL, ''); 82 CONTEXT_KEY_KEYBOARD_LABEL, '');
80 } else if (stateId == self.CONNECTION.PAIRING) { 83 } else if (stateId == self.CONNECTION.PAIRING) {
81 $('hid-keyboard-label-pairing').textContent = self.context.get( 84 $('hid-keyboard-label-pairing').textContent = self.context.get(
82 CONTEXT_KEY_KEYBOARD_LABEL, ''); 85 CONTEXT_KEY_KEYBOARD_LABEL, '');
83 } else if (stateId == self.CONNECTION.CONNECTED) {
84 } 86 }
85 } 87 }
86 ); 88 );
87 this.context.addObserver( 89 this.context.addObserver(
88 CONTEXT_KEY_KEYBOARD_PINCODE, 90 CONTEXT_KEY_KEYBOARD_PINCODE,
89 function(pincode) { 91 this.updatePincodeKeysState_.bind(this));
90 self.setPincodeKeysState_();
91 if (!pincode) {
92 $('hid-keyboard-pincode').classList.remove('show-pincode');
93 return;
94 }
95 if (self.context.get(CONTEXT_KEY_KEYBOARD_STATE, '') !=
96 self.CONNECTION.PAIRING) {
97 return;
98 }
99 $('hid-keyboard-pincode').classList.add('show-pincode');
100 for (var i = 0, len = pincode.length; i < len; i++) {
101 var pincodeSymbol = $('hid-keyboard-pincode-sym-' + (i + 1));
102 pincodeSymbol.textContent = pincode[i];
103 }
104 announceAccessibleMessage(
105 self.context.get(CONTEXT_KEY_KEYBOARD_LABEL, '') + ' ' + pincode +
106 ' ' + loadTimeData.getString('hidDetectionBTEnterKey'));
107 }
108 );
109 this.context.addObserver( 92 this.context.addObserver(
110 CONTEXT_KEY_KEYBOARD_ENTERED_PART_EXPECTED, 93 CONTEXT_KEY_KEYBOARD_ENTERED_PART_EXPECTED,
111 function(entered_part_expected) { 94 this.updatePincodeKeysState_.bind(this));
112 if (self.context.get(CONTEXT_KEY_KEYBOARD_STATE, '') != 'pairing')
113 return;
114 self.setPincodeKeysState_();
115 }
116 );
117 this.context.addObserver( 95 this.context.addObserver(
118 CONTEXT_KEY_KEYBOARD_ENTERED_PART_PINCODE, 96 CONTEXT_KEY_KEYBOARD_ENTERED_PART_PINCODE,
119 function(entered_part) { 97 this.updatePincodeKeysState_.bind(this));
120 if (self.context.get(CONTEXT_KEY_KEYBOARD_STATE, '') !=
121 self.CONNECTION.PAIRING) {
122 return;
123 }
124 self.setPincodeKeysState_();
125 }
126 );
127 this.context.addObserver( 98 this.context.addObserver(
128 CONTEXT_KEY_CONTINUE_BUTTON_ENABLED, 99 CONTEXT_KEY_CONTINUE_BUTTON_ENABLED,
129 function(enabled) { 100 function(enabled) {
130 $('hid-continue-button').disabled = !enabled; 101 $('hid-continue-button').disabled = !enabled;
131 } 102 }
132 ); 103 );
133 }, 104 },
134 105
135 /** 106 /**
136 * Buttons in oobe wizard's button strip. 107 * Buttons in oobe wizard's button strip.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 * Sets state for mouse-block. 150 * Sets state for mouse-block.
180 * @param {state} one of keys of this.CONNECTION dict. 151 * @param {state} one of keys of this.CONNECTION dict.
181 */ 152 */
182 setPointingDeviceState: function(state) { 153 setPointingDeviceState: function(state) {
183 if (state === undefined) 154 if (state === undefined)
184 return; 155 return;
185 this.setDeviceBlockState_(this.BLOCK.MOUSE, state); 156 this.setDeviceBlockState_(this.BLOCK.MOUSE, state);
186 }, 157 },
187 158
188 /** 159 /**
189 * Sets state for pincode key elements. 160 * Updates state for pincode key elements based on context state.
190 */ 161 */
191 setPincodeKeysState_: function() { 162 updatePincodeKeysState_: function() {
163 var pincodeKeys = $('hid-keyboard-pincode');
164 var pincode = this.context.get(CONTEXT_KEY_KEYBOARD_PINCODE, '');
165 var state = this.context.get(CONTEXT_KEY_KEYBOARD_STATE, '');
166
167 if (!pincode || state !== this.CONNECTION.PAIRING) {
168 pincodeKeys.hidden = true;
169 return;
170 }
171
172 if (pincodeKeys.hidden) {
173 pincodeKeys.hidden = false;
174 announceAccessibleMessage(
175 this.context.get(CONTEXT_KEY_KEYBOARD_LABEL, '') + ' ' + pincode +
176 ' ' + loadTimeData.getString('hidDetectionBTEnterKey'));
177 }
178
192 var entered = this.context.get( 179 var entered = this.context.get(
193 CONTEXT_KEY_KEYBOARD_ENTERED_PART_PINCODE, 0); 180 CONTEXT_KEY_KEYBOARD_ENTERED_PART_PINCODE, 0);
181
194 // whether the functionality of getting num of entered keys is available. 182 // whether the functionality of getting num of entered keys is available.
195 var expected = this.context.get( 183 var expected = this.context.get(
196 CONTEXT_KEY_KEYBOARD_ENTERED_PART_EXPECTED, false); 184 CONTEXT_KEY_KEYBOARD_ENTERED_PART_EXPECTED, false);
197 var pincodeLength = 7; // including enter-key 185
198 for (var i = 0; i < pincodeLength; i++) { 186 if (pincode.length != PINCODE_LENGTH)
187 console.error('Wrong pincode length');
188
189 // Pincode keys plus Enter key.
190 for (var i = 0; i < (PINCODE_LENGTH + 1); i++) {
199 var pincodeSymbol = $('hid-keyboard-pincode-sym-' + (i + 1)); 191 var pincodeSymbol = $('hid-keyboard-pincode-sym-' + (i + 1));
200 pincodeSymbol.classList.toggle('key-typed', i < entered && expected); 192 pincodeSymbol.classList.toggle('key-typed', i < entered && expected);
201 pincodeSymbol.classList.toggle('key-untyped', i > entered && expected); 193 pincodeSymbol.classList.toggle('key-untyped', i > entered && expected);
202 pincodeSymbol.classList.toggle('key-next', i == entered && expected); 194 pincodeSymbol.classList.toggle('key-next', i == entered && expected);
195 if (i < PINCODE_LENGTH)
196 pincodeSymbol.textContent = pincode[i] ? pincode[i] : '';
203 } 197 }
204 }, 198 },
205 199
206 /* 200 /*
207 * Event handler that is invoked just before the screen in shown. 201 * Event handler that is invoked just before the screen in shown.
208 * @param {Object} data Screen init payload. 202 * @param {Object} data Screen init payload.
209 */ 203 */
210 onBeforeShow: function(data) { 204 onBeforeShow: function(data) {
211 this.setDeviceBlockState_('hid-mouse-block', this.CONNECTION.SEARCHING); 205 this.setDeviceBlockState_('hid-mouse-block', this.CONNECTION.SEARCHING);
212 this.setDeviceBlockState_('hid-keyboard-block', 206 this.setDeviceBlockState_('hid-keyboard-block',
213 this.CONNECTION.SEARCHING); 207 this.CONNECTION.SEARCHING);
214 }, 208 },
215 }; 209 };
216 }); 210 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698