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

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

Issue 2600983003: ChromeOS MD-OOBE: Add HID detection screen. (Closed)
Patch Set: Fix build Created 3 years, 11 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview Polymer element for displaying material design HID detection
7 * screen.
8 */
9
10 {
11 var PINCODE_LENGTH = 6;
stevenjb 2016/12/28 20:47:04 I don't think the { does anything, i.e. I don't th
Alexander Alekseev 2016/12/28 22:56:23 Done.
12
13 Polymer({
14 is: 'oobe-hid-detection-md',
15
16 properties: {
17 /**
18 * "Continue" button is disabled until HID devices are paired.
19 */
stevenjb 2016/12/28 20:47:04 nit: All of these comments that fit can be a singl
Alexander Alekseev 2016/12/28 22:56:22 Done.
20 continueButtonDisabled: {
21 type: Boolean,
22 value: true,
23 },
24
25 /**
26 * This is the displaed text for keyboard "Pairing" state.
stevenjb 2016/12/28 20:47:04 displayed
Alexander Alekseev 2016/12/28 22:56:23 Done.
27 */
28 keyboardPairingLabel: String,
29
30 /**
31 * This is the displaed text for keyboard "Paired" state.
stevenjb 2016/12/28 20:47:04 displayed
Alexander Alekseev 2016/12/28 22:56:22 Done.
32 */
33 keyboardPairedLabel: String,
34
35 /**
36 * Current state in mouse pairing process.
37 */
38 mouseState: String,
stevenjb 2016/12/28 20:47:04 This appears to be internal? If so, append _ to th
Alexander Alekseev 2016/12/28 22:56:22 Done.
39
40 /**
41 * Current state in keyboard pairing process.
42 */
43 keyboardState: String,
44
45 /**
46 * Controls visibility of keyboard pincode.
47 */
48 keyboardPincodeVisible: Boolean,
49
50 /**
51 * Reference to OOBE screen object.
52 * @type {!OobeTypes.Screen}
53 */
54 screen: Object,
55 },
56
57 /**
58 * Displayed keyboard pincode.
59 */
60 keyboardPincode_: String,
61
62 /**
63 * Helper function to update keyboard/mouse state.
64 * @private
65 */
66 calculateState_: function(state, newState) {
stevenjb 2016/12/28 20:47:04 Add @param for state, newState.
Alexander Alekseev 2016/12/28 22:56:23 Done.
67 if (newState === undefined)
68 return state;
69
70 if (newState == this.screen.CONNECTION.UPDATE)
71 return state;
72
73 return newState;
74 },
75
76 /**
77 * Helper function to calculate visibility of 'connected' icons.
78 * @private
79 */
80 tickIsVisible_: function(state) {
stevenjb 2016/12/28 20:47:04 @param for all functions
Alexander Alekseev 2016/12/28 22:56:22 Done.
81 return (state == this.screen.CONNECTION.USB) ||
82 (state == this.screen.CONNECTION.CONNECTED) ||
83 (state == this.screen.CONNECTION.PAIRED);
84 },
85
86 /**
87 * Helper function to update keyboard/mouse state.
88 * @private
89 */
90 notEq_: function(string1, string2) { return string1 != string2; },
91
92 /**
93 * Sets current state in keyboard pairing process.
94 */
95 setMouseState: function(state) {
96 this.mouseState = this.calculateState_(this.mouseState, state);
97 },
98
99 /**
100 * Updates visibility of keyboard pincode.
101 * @private
102 */
103 updateKeyboardPincodeVisible_: function(state) {
104 this.keyboardPincodeVisible = this.keyboardPincode_ &&
105 (this.keyboardState == this.screen.CONNECTION.PAIRING);
106 },
107
108 /**
109 * Sets current state in keyboard pairing process.
110 */
111 setKeyboardState: function(state) {
112 this.keyboardState = this.calculateState_(this.keyboardState, state);
113 console.error(
114 'keyboardState=' + this.keyboardState + ' (came state ' + state +
115 ')');
stevenjb 2016/12/28 20:47:04 Remove debugging logs.
Alexander Alekseev 2016/12/28 22:56:23 Done.
116 this.updateKeyboardPincodeVisible_();
117 },
118
119 /**
120 * Sets displayed keyboard pin.
121 */
122 setPincodeState: function(pincode, entered, expected, label) {
123 this.keyboardPincode_ = pincode;
124 if (!pincode) {
125 this.updateKeyboardPincodeVisible_();
126 return;
127 }
128
129 if (pincode.length != PINCODE_LENGTH)
130 console.error('Wrong pincode length');
131
132 // Pincode keys plus Enter key.
133 for (var i = 0; i < (PINCODE_LENGTH + 1); i++) {
stevenjb 2016/12/28 20:47:04 nit: in cros specific UI we can use 'let' which sc
Alexander Alekseev 2016/12/28 22:56:22 Done.
134 var pincodeSymbol = this.$['hid-keyboard-pincode-sym-' + (i + 1)];
135 pincodeSymbol.classList.toggle('key-typed', i < entered && expected);
136 pincodeSymbol.classList.toggle('key-untyped', i > entered && expected);
137 pincodeSymbol.classList.toggle('key-next', i == entered && expected);
138 if (i < PINCODE_LENGTH)
139 pincodeSymbol.textContent = pincode[i] ? pincode[i] : '';
140 }
141
142 var wasVisible = this.keyboardPincodeVisible;
143 this.updateKeyboardPincodeVisible_();
144 if (this.keyboardPincodeVisible && !wasVisible) {
145 announceAccessibleMessage(
146 label + ' ' + pincode + ' ' +
147 loadTimeData.getString('hidDetectionBTEnterKey'));
148 }
149 },
150
151 /**
152 * This is 'on-tap' event handler for 'Continue' button.
153 */
154 onHIDContinue_: function(event) {
155 chrome.send('HIDDetectionOnContinue');
156 event.stopPropagation();
157 },
158 });
159 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698