| 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 var password = this.passwordElement.value || this.pinKeyboard.value; |
| 1345 if (!password) |
| 1358 return false; | 1346 return false; |
| 1359 Oobe.disableSigninUI(); | 1347 Oobe.disableSigninUI(); |
| 1360 chrome.send('authenticateUser', | 1348 chrome.send('authenticateUser', [this.user.username, password]); |
| 1361 [this.user.username, this.passwordElement.value]); | |
| 1362 } else { | 1349 } else { |
| 1363 console.error('Activating user pod with invalid authentication type: ' + | 1350 console.error('Activating user pod with invalid authentication type: ' + |
| 1364 this.authType); | 1351 this.authType); |
| 1365 } | 1352 } |
| 1366 | 1353 |
| 1367 return true; | 1354 return true; |
| 1368 }, | 1355 }, |
| 1369 | 1356 |
| 1370 showSupervisedUserSigninWarning: function() { | 1357 showSupervisedUserSigninWarning: function() { |
| 1371 // Legacy supervised user token has been invalidated. | 1358 // 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); | 1400 this.parentNode.showSigninUI(this.user.emailAddress); |
| 1414 } | 1401 } |
| 1415 }, | 1402 }, |
| 1416 | 1403 |
| 1417 /** | 1404 /** |
| 1418 * Resets the input field and updates the tab order of pod controls. | 1405 * Resets the input field and updates the tab order of pod controls. |
| 1419 * @param {boolean} takeFocus If true, input field takes focus. | 1406 * @param {boolean} takeFocus If true, input field takes focus. |
| 1420 */ | 1407 */ |
| 1421 reset: function(takeFocus) { | 1408 reset: function(takeFocus) { |
| 1422 this.passwordElement.value = ''; | 1409 this.passwordElement.value = ''; |
| 1410 this.pinKeyboard.value = ''; |
| 1423 this.classList.toggle('signing-in', false); | 1411 this.classList.toggle('signing-in', false); |
| 1424 if (takeFocus) { | 1412 if (takeFocus) { |
| 1425 if (!this.multiProfilesPolicyApplied) | 1413 if (!this.multiProfilesPolicyApplied) |
| 1426 this.focusInput(); // This will set a custom tab order. | 1414 this.focusInput(); // This will set a custom tab order. |
| 1427 } | 1415 } |
| 1428 else | 1416 else |
| 1429 this.resetTabOrder(); | 1417 this.resetTabOrder(); |
| 1430 }, | 1418 }, |
| 1431 | 1419 |
| 1432 /** | 1420 /** |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 if (this.parentNode.disabled) | 1798 if (this.parentNode.disabled) |
| 1811 return; | 1799 return; |
| 1812 | 1800 |
| 1813 if (!this.isActionBoxMenuActive) { | 1801 if (!this.isActionBoxMenuActive) { |
| 1814 if (this.isAuthTypeOnlineSignIn) { | 1802 if (this.isAuthTypeOnlineSignIn) { |
| 1815 this.showSigninUI(); | 1803 this.showSigninUI(); |
| 1816 } else if (this.isAuthTypeUserClick && this.userClickAuthAllowed_) { | 1804 } else if (this.isAuthTypeUserClick && this.userClickAuthAllowed_) { |
| 1817 // Note that this.userClickAuthAllowed_ is set in mouse down event | 1805 // Note that this.userClickAuthAllowed_ is set in mouse down event |
| 1818 // handler. | 1806 // handler. |
| 1819 this.parentNode.setActivatedPod(this); | 1807 this.parentNode.setActivatedPod(this); |
| 1808 } else if (this.pinKeyboard.submitButton && |
| 1809 e.target == this.pinKeyboard.submitButton) { |
| 1810 // Sets the pod as activated if the submit button is clicked so that |
| 1811 // it simulates what the enter button does for the password/pin. |
| 1812 this.parentNode.setActivatedPod(this); |
| 1820 } | 1813 } |
| 1821 | 1814 |
| 1822 if (this.multiProfilesPolicyApplied) | 1815 if (this.multiProfilesPolicyApplied) |
| 1823 this.userTypeBubbleElement.classList.add('bubble-shown'); | 1816 this.userTypeBubbleElement.classList.add('bubble-shown'); |
| 1824 | 1817 |
| 1825 // Prevent default so that we don't trigger 'focus' event and | 1818 // Prevent default so that we don't trigger 'focus' event and |
| 1826 // stop propagation so that the 'click' event does not bubble | 1819 // stop propagation so that the 'click' event does not bubble |
| 1827 // up and accidentally closes the bubble tooltip. | 1820 // up and accidentally closes the bubble tooltip. |
| 1828 stopEventPropagation(e); | 1821 stopEventPropagation(e); |
| 1829 } | 1822 } |
| (...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3406 else | 3399 else |
| 3407 this.focusPod(this.firstElementChild); | 3400 this.focusPod(this.firstElementChild); |
| 3408 | 3401 |
| 3409 e.stopPropagation(); | 3402 e.stopPropagation(); |
| 3410 } | 3403 } |
| 3411 break; | 3404 break; |
| 3412 case 'Enter': | 3405 case 'Enter': |
| 3413 if (this.focusedPod_) { | 3406 if (this.focusedPod_) { |
| 3414 var targetTag = e.target.tagName; | 3407 var targetTag = e.target.tagName; |
| 3415 if (e.target == this.focusedPod_.passwordElement || | 3408 if (e.target == this.focusedPod_.passwordElement || |
| 3409 e.target == this.focusedPod_.pinKeyboard.inputElement || |
| 3416 (targetTag != 'INPUT' && | 3410 (targetTag != 'INPUT' && |
| 3417 targetTag != 'BUTTON' && | 3411 targetTag != 'BUTTON' && |
| 3418 targetTag != 'A')) { | 3412 targetTag != 'A')) { |
| 3419 this.setActivatedPod(this.focusedPod_, e); | 3413 this.setActivatedPod(this.focusedPod_, e); |
| 3420 e.stopPropagation(); | 3414 e.stopPropagation(); |
| 3421 } | 3415 } |
| 3422 } | 3416 } |
| 3423 break; | 3417 break; |
| 3424 case 'Escape': | 3418 case 'Escape': |
| 3425 if (!this.alwaysFocusSinglePod) | 3419 if (!this.alwaysFocusSinglePod) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3511 if (pod && pod.multiProfilesPolicyApplied) { | 3505 if (pod && pod.multiProfilesPolicyApplied) { |
| 3512 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3506 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3513 } | 3507 } |
| 3514 } | 3508 } |
| 3515 }; | 3509 }; |
| 3516 | 3510 |
| 3517 return { | 3511 return { |
| 3518 PodRow: PodRow | 3512 PodRow: PodRow |
| 3519 }; | 3513 }; |
| 3520 }); | 3514 }); |
| OLD | NEW |