Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 User pod row implementation. | 6 * @fileoverview User pod row implementation. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 cr.define('login', function() { | 9 cr.define('login', function() { |
| 10 /** | 10 /** |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 695 __proto__: HTMLDivElement.prototype, | 695 __proto__: HTMLDivElement.prototype, |
| 696 | 696 |
| 697 /** | 697 /** |
| 698 * Whether click on the pod can issue a user click auth attempt. The | 698 * Whether click on the pod can issue a user click auth attempt. The |
| 699 * attempt can be issued iff the pod was focused when the click | 699 * attempt can be issued iff the pod was focused when the click |
| 700 * started (i.e. on mouse down event). | 700 * started (i.e. on mouse down event). |
| 701 * @type {boolean} | 701 * @type {boolean} |
| 702 * @private | 702 * @private |
| 703 */ | 703 */ |
| 704 userClickAuthAllowed_: false, | 704 userClickAuthAllowed_: false, |
| 705 pinKeyboardShown_: false, | |
|
jdufault
2016/07/08 21:04:09
Add docs.
sammiequon
2016/07/11 17:35:35
Done.
| |
| 705 | 706 |
| 706 /** @override */ | 707 /** @override */ |
| 707 decorate: function() { | 708 decorate: function() { |
| 708 this.tabIndex = UserPodTabOrder.POD_INPUT; | 709 this.tabIndex = UserPodTabOrder.POD_INPUT; |
| 709 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT; | 710 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT; |
| 710 | 711 |
| 711 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this)); | 712 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this)); |
| 712 this.addEventListener('click', this.handleClickOnPod_.bind(this)); | 713 this.addEventListener('click', this.handleClickOnPod_.bind(this)); |
| 713 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this)); | 714 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this)); |
| 714 | 715 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1130 | 1131 |
| 1131 setPinVisibility: function(visible) { | 1132 setPinVisibility: function(visible) { |
| 1132 var elements = [this, this.authElement, this.imageElement, | 1133 var elements = [this, this.authElement, this.imageElement, |
| 1133 this.signInElement, this.pinContainer]; | 1134 this.signInElement, this.pinContainer]; |
| 1134 | 1135 |
| 1135 for (var idx = 0; idx < elements.length; idx++) { | 1136 for (var idx = 0; idx < elements.length; idx++) { |
| 1136 var currentElement = elements[idx]; | 1137 var currentElement = elements[idx]; |
| 1137 currentElement.classList.toggle('pin-enabled', visible); | 1138 currentElement.classList.toggle('pin-enabled', visible); |
| 1138 currentElement.classList.toggle('pin-disabled', !visible); | 1139 currentElement.classList.toggle('pin-disabled', !visible); |
| 1139 } | 1140 } |
| 1141 this.pinKeyboardShown_ = visible; | |
|
jdufault
2016/07/08 21:04:09
Can this just be a DOM query so we have less cache
sammiequon
2016/07/11 17:35:35
Done.
| |
| 1140 }, | 1142 }, |
| 1141 | 1143 |
| 1142 setUserPodIconType: function(userTypeClass) { | 1144 setUserPodIconType: function(userTypeClass) { |
| 1143 this.userTypeIconAreaElement.classList.add(userTypeClass); | 1145 this.userTypeIconAreaElement.classList.add(userTypeClass); |
| 1144 this.userTypeIconAreaElement.hidden = false; | 1146 this.userTypeIconAreaElement.hidden = false; |
| 1145 }, | 1147 }, |
| 1146 | 1148 |
| 1147 /** | 1149 /** |
| 1148 * The user that this pod represents. | 1150 * The user that this pod represents. |
| 1149 * @type {!Object} | 1151 * @type {!Object} |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1167 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); | 1169 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); |
| 1168 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed; | 1170 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed; |
| 1169 }, | 1171 }, |
| 1170 | 1172 |
| 1171 /** | 1173 /** |
| 1172 * Gets main input element. | 1174 * Gets main input element. |
| 1173 * @type {(HTMLButtonElement|HTMLInputElement)} | 1175 * @type {(HTMLButtonElement|HTMLInputElement)} |
| 1174 */ | 1176 */ |
| 1175 get mainInput() { | 1177 get mainInput() { |
| 1176 if (this.isAuthTypePassword) { | 1178 if (this.isAuthTypePassword) { |
| 1179 if (this.pinKeyboardShown_) | |
| 1180 return this.pinKeyboard.inputElement; | |
| 1177 return this.passwordElement; | 1181 return this.passwordElement; |
| 1178 } else if (this.isAuthTypeOnlineSignIn) { | 1182 } else if (this.isAuthTypeOnlineSignIn) { |
| 1179 return this; | 1183 return this; |
| 1180 } else if (this.isAuthTypeUserClick) { | 1184 } else if (this.isAuthTypeUserClick) { |
| 1181 return this.passwordLabelElement; | 1185 return this.passwordLabelElement; |
| 1182 } | 1186 } |
| 1183 }, | 1187 }, |
| 1184 | 1188 |
| 1185 /** | 1189 /** |
| 1186 * Whether action box button is in active state. | 1190 * Whether action box button is in active state. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1333 * @return {boolean} True if activated successfully. | 1337 * @return {boolean} True if activated successfully. |
| 1334 */ | 1338 */ |
| 1335 activate: function(e) { | 1339 activate: function(e) { |
| 1336 if (this.isAuthTypeOnlineSignIn) { | 1340 if (this.isAuthTypeOnlineSignIn) { |
| 1337 this.showSigninUI(); | 1341 this.showSigninUI(); |
| 1338 } else if (this.isAuthTypeUserClick) { | 1342 } else if (this.isAuthTypeUserClick) { |
| 1339 Oobe.disableSigninUI(); | 1343 Oobe.disableSigninUI(); |
| 1340 this.classList.toggle('signing-in', true); | 1344 this.classList.toggle('signing-in', true); |
| 1341 chrome.send('attemptUnlock', [this.user.username]); | 1345 chrome.send('attemptUnlock', [this.user.username]); |
| 1342 } else if (this.isAuthTypePassword) { | 1346 } else if (this.isAuthTypePassword) { |
| 1343 if (!this.passwordElement.value) | 1347 if (!this.passwordElement.value && !this.pinKeyboard.inputElement.value) |
| 1344 return false; | 1348 return false; |
| 1345 Oobe.disableSigninUI(); | 1349 Oobe.disableSigninUI(); |
| 1346 chrome.send('authenticateUser', | 1350 chrome.send('authenticateUser', |
| 1347 [this.user.username, this.passwordElement.value]); | 1351 [this.user.username, this.passwordElement.value]); |
| 1348 } else { | 1352 } else { |
| 1349 console.error('Activating user pod with invalid authentication type: ' + | 1353 console.error('Activating user pod with invalid authentication type: ' + |
| 1350 this.authType); | 1354 this.authType); |
| 1351 } | 1355 } |
| 1352 | 1356 |
| 1353 return true; | 1357 return true; |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1796 if (this.parentNode.disabled) | 1800 if (this.parentNode.disabled) |
| 1797 return; | 1801 return; |
| 1798 | 1802 |
| 1799 if (!this.isActionBoxMenuActive) { | 1803 if (!this.isActionBoxMenuActive) { |
| 1800 if (this.isAuthTypeOnlineSignIn) { | 1804 if (this.isAuthTypeOnlineSignIn) { |
| 1801 this.showSigninUI(); | 1805 this.showSigninUI(); |
| 1802 } else if (this.isAuthTypeUserClick && this.userClickAuthAllowed_) { | 1806 } else if (this.isAuthTypeUserClick && this.userClickAuthAllowed_) { |
| 1803 // Note that this.userClickAuthAllowed_ is set in mouse down event | 1807 // Note that this.userClickAuthAllowed_ is set in mouse down event |
| 1804 // handler. | 1808 // handler. |
| 1805 this.parentNode.setActivatedPod(this); | 1809 this.parentNode.setActivatedPod(this); |
| 1810 } else if (e.target == this.pinKeyboard.submitButton) { | |
| 1811 this.parentNode.setActivatedPod(this); | |
|
jdufault
2016/07/08 21:04:09
What's this for?
sammiequon
2016/07/11 17:35:35
The error bubble looks for the current activated p
jdufault
2016/07/11 18:19:53
Please add a comment describing this.
| |
| 1806 } | 1812 } |
| 1807 | 1813 |
| 1808 if (this.multiProfilesPolicyApplied) | 1814 if (this.multiProfilesPolicyApplied) |
| 1809 this.userTypeBubbleElement.classList.add('bubble-shown'); | 1815 this.userTypeBubbleElement.classList.add('bubble-shown'); |
| 1810 | 1816 |
| 1811 // Prevent default so that we don't trigger 'focus' event and | 1817 // Prevent default so that we don't trigger 'focus' event and |
| 1812 // stop propagation so that the 'click' event does not bubble | 1818 // stop propagation so that the 'click' event does not bubble |
| 1813 // up and accidentally closes the bubble tooltip. | 1819 // up and accidentally closes the bubble tooltip. |
| 1814 stopEventPropagation(e); | 1820 stopEventPropagation(e); |
| 1815 } | 1821 } |
| (...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3392 else | 3398 else |
| 3393 this.focusPod(this.firstElementChild); | 3399 this.focusPod(this.firstElementChild); |
| 3394 | 3400 |
| 3395 e.stopPropagation(); | 3401 e.stopPropagation(); |
| 3396 } | 3402 } |
| 3397 break; | 3403 break; |
| 3398 case 'Enter': | 3404 case 'Enter': |
| 3399 if (this.focusedPod_) { | 3405 if (this.focusedPod_) { |
| 3400 var targetTag = e.target.tagName; | 3406 var targetTag = e.target.tagName; |
| 3401 if (e.target == this.focusedPod_.passwordElement || | 3407 if (e.target == this.focusedPod_.passwordElement || |
| 3408 e.target == this.focusedPod_.pinKeyboard.inputElement || | |
| 3402 (targetTag != 'INPUT' && | 3409 (targetTag != 'INPUT' && |
| 3403 targetTag != 'BUTTON' && | 3410 targetTag != 'BUTTON' && |
| 3404 targetTag != 'A')) { | 3411 targetTag != 'A')) { |
| 3405 this.setActivatedPod(this.focusedPod_, e); | 3412 this.setActivatedPod(this.focusedPod_, e); |
| 3406 e.stopPropagation(); | 3413 e.stopPropagation(); |
| 3407 } | 3414 } |
| 3408 } | 3415 } |
| 3409 break; | 3416 break; |
| 3410 case 'Escape': | 3417 case 'Escape': |
| 3411 if (!this.alwaysFocusSinglePod) | 3418 if (!this.alwaysFocusSinglePod) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3497 if (pod && pod.multiProfilesPolicyApplied) { | 3504 if (pod && pod.multiProfilesPolicyApplied) { |
| 3498 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3505 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3499 } | 3506 } |
| 3500 } | 3507 } |
| 3501 }; | 3508 }; |
| 3502 | 3509 |
| 3503 return { | 3510 return { |
| 3504 PodRow: PodRow | 3511 PodRow: PodRow |
| 3505 }; | 3512 }; |
| 3506 }); | 3513 }); |
| OLD | NEW |