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

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

Issue 2944703004: Run clang-format on .js files in c/b/r/chromeos (Closed)
Patch Set: Created 3 years, 6 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';
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 * @private 42 * @private
43 */ 43 */
44 continueButton_: null, 44 continueButton_: null,
45 45
46 /** @override */ 46 /** @override */
47 decorate: function() { 47 decorate: function() {
48 var self = this; 48 var self = this;
49 49
50 $('oobe-hid-detection-md').screen = this; 50 $('oobe-hid-detection-md').screen = this;
51 51
52 this.context.addObserver(CONTEXT_KEY_MOUSE_STATE, function(stateId) {
53 if (stateId === undefined)
54 return;
55 self.setDeviceBlockState_('hid-mouse-block', stateId);
56 $('oobe-hid-detection-md').setMouseState(stateId);
57 });
58 this.context.addObserver(CONTEXT_KEY_KEYBOARD_STATE, function(stateId) {
59 self.updatePincodeKeysState_();
60 if (stateId === undefined)
61 return;
62 self.setDeviceBlockState_('hid-keyboard-block', stateId);
63 $('oobe-hid-detection-md').setKeyboardState(stateId);
64 if (stateId == self.CONNECTION.PAIRED) {
65 var label = self.context.get(CONTEXT_KEY_KEYBOARD_LABEL, '');
66 $('hid-keyboard-label-paired').textContent = label;
67 $('oobe-hid-detection-md').keyboardPairedLabel = label;
68 } else if (stateId == self.CONNECTION.PAIRING) {
69 var label = self.context.get(CONTEXT_KEY_KEYBOARD_LABEL, '');
70 $('hid-keyboard-label-pairing').textContent = label;
71 $('oobe-hid-detection-md').keyboardPairingLabel = label;
72 }
73 });
52 this.context.addObserver( 74 this.context.addObserver(
53 CONTEXT_KEY_MOUSE_STATE, 75 CONTEXT_KEY_KEYBOARD_PINCODE,
54 function(stateId) { 76 this.updatePincodeKeysState_.bind(this));
55 if (stateId === undefined)
56 return;
57 self.setDeviceBlockState_('hid-mouse-block', stateId);
58 $('oobe-hid-detection-md').setMouseState(stateId);
59 }
60 );
61 this.context.addObserver( 77 this.context.addObserver(
62 CONTEXT_KEY_KEYBOARD_STATE, 78 CONTEXT_KEY_KEYBOARD_ENTERED_PART_EXPECTED,
63 function(stateId) { 79 this.updatePincodeKeysState_.bind(this));
64 self.updatePincodeKeysState_();
65 if (stateId === undefined)
66 return;
67 self.setDeviceBlockState_('hid-keyboard-block', stateId);
68 $('oobe-hid-detection-md').setKeyboardState(stateId);
69 if (stateId == self.CONNECTION.PAIRED) {
70 var label = self.context.get(CONTEXT_KEY_KEYBOARD_LABEL, '');
71 $('hid-keyboard-label-paired').textContent = label;
72 $('oobe-hid-detection-md').keyboardPairedLabel = label;
73 } else if (stateId == self.CONNECTION.PAIRING) {
74 var label = self.context.get(CONTEXT_KEY_KEYBOARD_LABEL, '');
75 $('hid-keyboard-label-pairing').textContent = label;
76 $('oobe-hid-detection-md').keyboardPairingLabel = label;
77 }
78 }
79 );
80 this.context.addObserver( 80 this.context.addObserver(
81 CONTEXT_KEY_KEYBOARD_PINCODE, 81 CONTEXT_KEY_KEYBOARD_ENTERED_PART_PINCODE,
82 this.updatePincodeKeysState_.bind(this)); 82 this.updatePincodeKeysState_.bind(this));
83 this.context.addObserver( 83 this.context.addObserver(
84 CONTEXT_KEY_KEYBOARD_ENTERED_PART_EXPECTED, 84 CONTEXT_KEY_CONTINUE_BUTTON_ENABLED, function(enabled) {
85 this.updatePincodeKeysState_.bind(this)); 85 $('hid-continue-button').disabled = !enabled;
86 this.context.addObserver( 86 $('oobe-hid-detection-md').continueButtonDisabled = !enabled;
87 CONTEXT_KEY_KEYBOARD_ENTERED_PART_PINCODE, 87 });
88 this.updatePincodeKeysState_.bind(this));
89 this.context.addObserver(
90 CONTEXT_KEY_CONTINUE_BUTTON_ENABLED,
91 function(enabled) {
92 $('hid-continue-button').disabled = !enabled;
93 $('oobe-hid-detection-md').continueButtonDisabled = !enabled;
94 }
95 );
96 }, 88 },
97 89
98 /** 90 /**
99 * Buttons in oobe wizard's button strip. 91 * Buttons in oobe wizard's button strip.
100 * @type {array} Array of Buttons. 92 * @type {array} Array of Buttons.
101 */ 93 */
102 get buttons() { 94 get buttons() {
103 var buttons = []; 95 var buttons = [];
104 var continueButton = this.ownerDocument.createElement('button'); 96 var continueButton = this.ownerDocument.createElement('button');
105 continueButton.id = 'hid-continue-button'; 97 continueButton.id = 'hid-continue-button';
106 continueButton.textContent = loadTimeData.getString( 98 continueButton.textContent =
107 'hidDetectionContinue'); 99 loadTimeData.getString('hidDetectionContinue');
108 continueButton.addEventListener('click', function(e) { 100 continueButton.addEventListener('click', function(e) {
109 chrome.send('HIDDetectionOnContinue'); 101 chrome.send('HIDDetectionOnContinue');
110 e.stopPropagation(); 102 e.stopPropagation();
111 }); 103 });
112 buttons.push(continueButton); 104 buttons.push(continueButton);
113 105
114 return buttons; 106 return buttons;
115 }, 107 },
116 108
117 /** 109 /**
118 * Returns a control which should receive an initial focus. 110 * Returns a control which should receive an initial focus.
119 */ 111 */
120 get defaultControl() { return $('hid-continue-button'); }, 112 get defaultControl() {
113 return $('hid-continue-button');
114 },
121 115
122 /** 116 /**
123 * Sets a device-block css class to reflect device state of searching, usb, 117 * Sets a device-block css class to reflect device state of searching, usb,
124 * connected, pairing or paired (for BT devices). 118 * connected, pairing or paired (for BT devices).
125 * @param {blockId} id one of keys of this.BLOCK dict. 119 * @param {blockId} id one of keys of this.BLOCK dict.
126 * @param {state} one of keys of this.CONNECTION dict. 120 * @param {state} one of keys of this.CONNECTION dict.
127 * @private 121 * @private
128 */ 122 */
129 setDeviceBlockState_: function(blockId, state) { 123 setDeviceBlockState_: function(blockId, state) {
130 if (state == 'update') 124 if (state == 'update')
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 187 }
194 }, 188 },
195 189
196 /** 190 /**
197 * Event handler that is invoked just before the screen in shown. 191 * Event handler that is invoked just before the screen in shown.
198 * @param {Object} data Screen init payload. 192 * @param {Object} data Screen init payload.
199 */ 193 */
200 onBeforeShow: function(data) { 194 onBeforeShow: function(data) {
201 this.setMDMode_(); 195 this.setMDMode_();
202 this.setDeviceBlockState_('hid-mouse-block', this.CONNECTION.SEARCHING); 196 this.setDeviceBlockState_('hid-mouse-block', this.CONNECTION.SEARCHING);
203 this.setDeviceBlockState_('hid-keyboard-block', 197 this.setDeviceBlockState_(
204 this.CONNECTION.SEARCHING); 198 'hid-keyboard-block', this.CONNECTION.SEARCHING);
205 $('oobe-hid-detection-md').setMouseState(this.CONNECTION.SEARCHING); 199 $('oobe-hid-detection-md').setMouseState(this.CONNECTION.SEARCHING);
206 $('oobe-hid-detection-md').setKeyboardState(this.CONNECTION.SEARCHING); 200 $('oobe-hid-detection-md').setKeyboardState(this.CONNECTION.SEARCHING);
207 }, 201 },
208 202
209 /** 203 /**
210 * This method takes care of switching to material-design OOBE. 204 * This method takes care of switching to material-design OOBE.
211 * @private 205 * @private
212 */ 206 */
213 setMDMode_: function() { 207 setMDMode_: function() {
214 var useMDOobe = (loadTimeData.getString('newOobeUI') == 'on'); 208 var useMDOobe = (loadTimeData.getString('newOobeUI') == 'on');
215 $('oobe-hid-detection-md').hidden = !useMDOobe; 209 $('oobe-hid-detection-md').hidden = !useMDOobe;
216 $('oobe-hid-detection').hidden = useMDOobe; 210 $('oobe-hid-detection').hidden = useMDOobe;
217 }, 211 },
218 }; 212 };
219 }); 213 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698