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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 | 741 |
| 742 /** | 742 /** |
| 743 * Initializes the pod after its properties set and added to a pod row. | 743 * Initializes the pod after its properties set and added to a pod row. |
| 744 */ | 744 */ |
| 745 initialize: function() { | 745 initialize: function() { |
| 746 this.passwordElement.addEventListener('keydown', | 746 this.passwordElement.addEventListener('keydown', |
| 747 this.parentNode.handleKeyDown.bind(this.parentNode)); | 747 this.parentNode.handleKeyDown.bind(this.parentNode)); |
| 748 this.passwordElement.addEventListener('keypress', | 748 this.passwordElement.addEventListener('keypress', |
| 749 this.handlePasswordKeyPress_.bind(this)); | 749 this.handlePasswordKeyPress_.bind(this)); |
| 750 | 750 |
| 751 if (this.pinKeyboard) { | |
| 752 this.pinKeyboard.addEventListener('submit', | |
| 753 this.handlePinSubmitted_.bind(this)); | |
| 754 } | |
| 755 | |
| 756 this.imageElement.addEventListener('load', | 751 this.imageElement.addEventListener('load', |
| 757 this.parentNode.handlePodImageLoad.bind(this.parentNode, this)); | 752 this.parentNode.handlePodImageLoad.bind(this.parentNode, this)); |
| 758 | 753 |
| 759 var initialAuthType = this.user.initialAuthType || | 754 var initialAuthType = this.user.initialAuthType || |
| 760 AUTH_TYPE.OFFLINE_PASSWORD; | 755 AUTH_TYPE.OFFLINE_PASSWORD; |
| 761 this.setAuthType(initialAuthType, null); | 756 this.setAuthType(initialAuthType, null); |
| 762 | 757 |
| 763 this.userClickAuthAllowed_ = false; | 758 this.userClickAuthAllowed_ = false; |
| 764 }, | 759 }, |
| 765 | 760 |
| 766 /** | 761 /** |
| 767 * Resets tab order for pod elements to its initial state. | 762 * Resets tab order for pod elements to its initial state. |
| 768 */ | 763 */ |
| 769 resetTabOrder: function() { | 764 resetTabOrder: function() { |
| 770 // Note: the |mainInput| can be the pod itself. | 765 // Note: the |mainInput| can be the pod itself. |
| 771 this.mainInput.tabIndex = -1; | 766 this.mainInput.tabIndex = -1; |
| 772 this.tabIndex = UserPodTabOrder.POD_INPUT; | 767 this.tabIndex = UserPodTabOrder.POD_INPUT; |
| 773 }, | 768 }, |
| 774 | 769 |
| 775 /** | 770 /** |
| 776 * Handles the user hitting 'submit' on the PIN keyboard. | |
| 777 * @param {Event} e Submit event object. | |
| 778 * @private | |
| 779 */ | |
| 780 handlePinSubmitted_: function(e) { | |
| 781 var pin = e.detail.pin; | |
| 782 chrome.send('authenticateUser', [this.user.username, pin]); | |
| 783 }, | |
| 784 | |
| 785 /** | |
| 786 * Handles keypress event (i.e. any textual input) on password input. | 771 * Handles keypress event (i.e. any textual input) on password input. |
| 787 * @param {Event} e Keypress Event object. | 772 * @param {Event} e Keypress Event object. |
| 788 * @private | 773 * @private |
| 789 */ | 774 */ |
| 790 handlePasswordKeyPress_: function(e) { | 775 handlePasswordKeyPress_: function(e) { |
| 791 // When tabbing from the system tray a tab key press is received. Suppress | 776 // When tabbing from the system tray a tab key press is received. Suppress |
| 792 // this so as not to type a tab character into the password field. | 777 // this so as not to type a tab character into the password field. |
| 793 if (e.keyCode == 9) { | 778 if (e.keyCode == 9) { |
| 794 e.preventDefault(); | 779 e.preventDefault(); |
| 795 return; | 780 return; |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1181 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); | 1166 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); |
| 1182 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed; | 1167 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed; |
| 1183 }, | 1168 }, |
| 1184 | 1169 |
| 1185 /** | 1170 /** |
| 1186 * Gets main input element. | 1171 * Gets main input element. |
| 1187 * @type {(HTMLButtonElement|HTMLInputElement)} | 1172 * @type {(HTMLButtonElement|HTMLInputElement)} |
| 1188 */ | 1173 */ |
| 1189 get mainInput() { | 1174 get mainInput() { |
| 1190 if (this.isAuthTypePassword) { | 1175 if (this.isAuthTypePassword) { |
| 1176 if (this.pinContainer.classList.contains('pin-enabled')) | |
| 1177 return this.pinKeyboard.inputElement; | |
| 1191 return this.passwordElement; | 1178 return this.passwordElement; |
| 1192 } else if (this.isAuthTypeOnlineSignIn) { | 1179 } else if (this.isAuthTypeOnlineSignIn) { |
| 1193 return this; | 1180 return this; |
| 1194 } else if (this.isAuthTypeUserClick) { | 1181 } else if (this.isAuthTypeUserClick) { |
| 1195 return this.passwordLabelElement; | 1182 return this.passwordLabelElement; |
| 1196 } | 1183 } |
| 1197 }, | 1184 }, |
| 1198 | 1185 |
| 1199 /** | 1186 /** |
| 1200 * Whether action box button is in active state. | 1187 * Whether action box button is in active state. |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1347 * @return {boolean} True if activated successfully. | 1334 * @return {boolean} True if activated successfully. |
| 1348 */ | 1335 */ |
| 1349 activate: function(e) { | 1336 activate: function(e) { |
| 1350 if (this.isAuthTypeOnlineSignIn) { | 1337 if (this.isAuthTypeOnlineSignIn) { |
| 1351 this.showSigninUI(); | 1338 this.showSigninUI(); |
| 1352 } else if (this.isAuthTypeUserClick) { | 1339 } else if (this.isAuthTypeUserClick) { |
| 1353 Oobe.disableSigninUI(); | 1340 Oobe.disableSigninUI(); |
| 1354 this.classList.toggle('signing-in', true); | 1341 this.classList.toggle('signing-in', true); |
| 1355 chrome.send('attemptUnlock', [this.user.username]); | 1342 chrome.send('attemptUnlock', [this.user.username]); |
| 1356 } else if (this.isAuthTypePassword) { | 1343 } else if (this.isAuthTypePassword) { |
| 1357 if (!this.passwordElement.value) | 1344 if (!this.passwordElement.value && this.pinKeyboard.inputElement && |
|
jdufault
2016/07/12 00:16:25
Move the var password declaration above this, then
sammiequon
2016/07/12 16:12:28
Done.
| |
| 1345 !this.pinKeyboard.value) | |
| 1358 return false; | 1346 return false; |
| 1359 Oobe.disableSigninUI(); | 1347 Oobe.disableSigninUI(); |
| 1360 chrome.send('authenticateUser', | 1348 var password = this.passwordElement.value || this.pinKeyboard.value; |
| 1361 [this.user.username, this.passwordElement.value]); | 1349 chrome.send('authenticateUser', [this.user.username, password]); |
| 1362 } else { | 1350 } else { |
| 1363 console.error('Activating user pod with invalid authentication type: ' + | 1351 console.error('Activating user pod with invalid authentication type: ' + |
| 1364 this.authType); | 1352 this.authType); |
| 1365 } | 1353 } |
| 1366 | 1354 |
| 1367 return true; | 1355 return true; |
| 1368 }, | 1356 }, |
| 1369 | 1357 |
| 1370 showSupervisedUserSigninWarning: function() { | 1358 showSupervisedUserSigninWarning: function() { |
| 1371 // Legacy supervised user token has been invalidated. | 1359 // Legacy supervised user token has been invalidated. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1413 this.parentNode.showSigninUI(this.user.emailAddress); | 1401 this.parentNode.showSigninUI(this.user.emailAddress); |
| 1414 } | 1402 } |
| 1415 }, | 1403 }, |
| 1416 | 1404 |
| 1417 /** | 1405 /** |
| 1418 * Resets the input field and updates the tab order of pod controls. | 1406 * Resets the input field and updates the tab order of pod controls. |
| 1419 * @param {boolean} takeFocus If true, input field takes focus. | 1407 * @param {boolean} takeFocus If true, input field takes focus. |
| 1420 */ | 1408 */ |
| 1421 reset: function(takeFocus) { | 1409 reset: function(takeFocus) { |
| 1422 this.passwordElement.value = ''; | 1410 this.passwordElement.value = ''; |
| 1411 this.pinKeyboard.value = ''; | |
| 1423 this.classList.toggle('signing-in', false); | 1412 this.classList.toggle('signing-in', false); |
| 1424 if (takeFocus) { | 1413 if (takeFocus) { |
| 1425 if (!this.multiProfilesPolicyApplied) | 1414 if (!this.multiProfilesPolicyApplied) |
| 1426 this.focusInput(); // This will set a custom tab order. | 1415 this.focusInput(); // This will set a custom tab order. |
| 1427 } | 1416 } |
| 1428 else | 1417 else |
| 1429 this.resetTabOrder(); | 1418 this.resetTabOrder(); |
| 1430 }, | 1419 }, |
| 1431 | 1420 |
| 1432 /** | 1421 /** |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1810 if (this.parentNode.disabled) | 1799 if (this.parentNode.disabled) |
| 1811 return; | 1800 return; |
| 1812 | 1801 |
| 1813 if (!this.isActionBoxMenuActive) { | 1802 if (!this.isActionBoxMenuActive) { |
| 1814 if (this.isAuthTypeOnlineSignIn) { | 1803 if (this.isAuthTypeOnlineSignIn) { |
| 1815 this.showSigninUI(); | 1804 this.showSigninUI(); |
| 1816 } else if (this.isAuthTypeUserClick && this.userClickAuthAllowed_) { | 1805 } else if (this.isAuthTypeUserClick && this.userClickAuthAllowed_) { |
| 1817 // Note that this.userClickAuthAllowed_ is set in mouse down event | 1806 // Note that this.userClickAuthAllowed_ is set in mouse down event |
| 1818 // handler. | 1807 // handler. |
| 1819 this.parentNode.setActivatedPod(this); | 1808 this.parentNode.setActivatedPod(this); |
| 1809 } else if (this.pinKeyboard.submitButton && | |
| 1810 e.target == this.pinKeyboard.submitButton) { | |
| 1811 // Sets the pod as activated if the submit button is clicked so that | |
| 1812 // it simulates what the enter button does for the password/pin. | |
| 1813 this.parentNode.setActivatedPod(this); | |
| 1820 } | 1814 } |
| 1821 | 1815 |
| 1822 if (this.multiProfilesPolicyApplied) | 1816 if (this.multiProfilesPolicyApplied) |
| 1823 this.userTypeBubbleElement.classList.add('bubble-shown'); | 1817 this.userTypeBubbleElement.classList.add('bubble-shown'); |
| 1824 | 1818 |
| 1825 // Prevent default so that we don't trigger 'focus' event and | 1819 // Prevent default so that we don't trigger 'focus' event and |
| 1826 // stop propagation so that the 'click' event does not bubble | 1820 // stop propagation so that the 'click' event does not bubble |
| 1827 // up and accidentally closes the bubble tooltip. | 1821 // up and accidentally closes the bubble tooltip. |
| 1828 stopEventPropagation(e); | 1822 stopEventPropagation(e); |
| 1829 } | 1823 } |
| (...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3406 else | 3400 else |
| 3407 this.focusPod(this.firstElementChild); | 3401 this.focusPod(this.firstElementChild); |
| 3408 | 3402 |
| 3409 e.stopPropagation(); | 3403 e.stopPropagation(); |
| 3410 } | 3404 } |
| 3411 break; | 3405 break; |
| 3412 case 'Enter': | 3406 case 'Enter': |
| 3413 if (this.focusedPod_) { | 3407 if (this.focusedPod_) { |
| 3414 var targetTag = e.target.tagName; | 3408 var targetTag = e.target.tagName; |
| 3415 if (e.target == this.focusedPod_.passwordElement || | 3409 if (e.target == this.focusedPod_.passwordElement || |
| 3410 e.target == this.focusedPod_.pinKeyboard.inputElement || | |
| 3416 (targetTag != 'INPUT' && | 3411 (targetTag != 'INPUT' && |
| 3417 targetTag != 'BUTTON' && | 3412 targetTag != 'BUTTON' && |
| 3418 targetTag != 'A')) { | 3413 targetTag != 'A')) { |
| 3419 this.setActivatedPod(this.focusedPod_, e); | 3414 this.setActivatedPod(this.focusedPod_, e); |
| 3420 e.stopPropagation(); | 3415 e.stopPropagation(); |
| 3421 } | 3416 } |
| 3422 } | 3417 } |
| 3423 break; | 3418 break; |
| 3424 case 'Escape': | 3419 case 'Escape': |
| 3425 if (!this.alwaysFocusSinglePod) | 3420 if (!this.alwaysFocusSinglePod) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3511 if (pod && pod.multiProfilesPolicyApplied) { | 3506 if (pod && pod.multiProfilesPolicyApplied) { |
| 3512 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3507 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3513 } | 3508 } |
| 3514 } | 3509 } |
| 3515 }; | 3510 }; |
| 3516 | 3511 |
| 3517 return { | 3512 return { |
| 3518 PodRow: PodRow | 3513 PodRow: PodRow |
| 3519 }; | 3514 }; |
| 3520 }); | 3515 }); |
| OLD | NEW |