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

Side by Side Diff: ui/login/account_picker/user_pod_row.js

Issue 2131823004: Dialog message saying PIN is incorrect positioned correctly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fixed patch set 3 errors. Created 4 years, 5 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 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
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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 1123
1139 setPinVisibility: function(visible) { 1124 setPinVisibility: function(visible) {
1140 var elements = [this, this.authElement, this.imagePaneElement, 1125 var elements = [this, this.authElement, this.imagePaneElement,
1141 this.imageElement, this.pinContainer]; 1126 this.imageElement, this.pinContainer];
1142 1127
1143 for (var idx = 0; idx < elements.length; idx++) { 1128 for (var idx = 0; idx < elements.length; idx++) {
1144 var currentElement = elements[idx]; 1129 var currentElement = elements[idx];
1145 currentElement.classList.toggle('pin-enabled', visible); 1130 currentElement.classList.toggle('pin-enabled', visible);
1146 currentElement.classList.toggle('pin-disabled', !visible); 1131 currentElement.classList.toggle('pin-disabled', !visible);
1147 } 1132 }
1148
1149 // Set the focus to the input element after showing/hiding pin keyboard. 1133 // Set the focus to the input element after showing/hiding pin keyboard.
jdufault 2016/07/11 22:35:08 Revert change.
sammiequon 2016/07/11 23:13:24 Done.
1150 if (visible) 1134 if (visible)
1151 this.pinKeyboard.focus(); 1135 this.pinKeyboard.focus();
1152 else 1136 else
1153 this.mainInput.focus(); 1137 this.mainInput.focus();
1154 }, 1138 },
1155 1139
1156 setUserPodIconType: function(userTypeClass) { 1140 setUserPodIconType: function(userTypeClass) {
1157 this.userTypeIconAreaElement.classList.add(userTypeClass); 1141 this.userTypeIconAreaElement.classList.add(userTypeClass);
1158 this.userTypeIconAreaElement.hidden = false; 1142 this.userTypeIconAreaElement.hidden = false;
1159 }, 1143 },
(...skipping 21 matching lines...) Expand all
1181 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); 1165 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING);
1182 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed; 1166 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed;
1183 }, 1167 },
1184 1168
1185 /** 1169 /**
1186 * Gets main input element. 1170 * Gets main input element.
1187 * @type {(HTMLButtonElement|HTMLInputElement)} 1171 * @type {(HTMLButtonElement|HTMLInputElement)}
1188 */ 1172 */
1189 get mainInput() { 1173 get mainInput() {
1190 if (this.isAuthTypePassword) { 1174 if (this.isAuthTypePassword) {
1175 if (this.pinContainer.classList.contains('pin-enabled')) {
1176 return this.pinKeyboard.inputElement;
1177 }
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
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 &&
1345 !this.pinKeyboard.inputElement.value)
1358 return false; 1346 return false;
1359 Oobe.disableSigninUI(); 1347 Oobe.disableSigninUI();
1360 chrome.send('authenticateUser', 1348 if (this.passwordElement.value) {
1361 [this.user.username, this.passwordElement.value]); 1349 chrome.send('authenticateUser',
1350 [this.user.username, this.passwordElement.value]);
jdufault 2016/07/11 22:35:08 Does this work? var password = this.passwordEle
sammiequon 2016/07/11 23:13:24 Done.
1351 } else if (this.pinKeyboard.inputElement &&
1352 this.pinKeyboard.inputElement.value) {
1353 chrome.send('authenticateUser',
1354 [this.user.username,
1355 this.pinKeyboard.inputElement.value]);
1356 }
1362 } else { 1357 } else {
1363 console.error('Activating user pod with invalid authentication type: ' + 1358 console.error('Activating user pod with invalid authentication type: ' +
1364 this.authType); 1359 this.authType);
1365 } 1360 }
1366 1361
1367 return true; 1362 return true;
1368 }, 1363 },
1369 1364
1370 showSupervisedUserSigninWarning: function() { 1365 showSupervisedUserSigninWarning: function() {
1371 // Legacy supervised user token has been invalidated. 1366 // Legacy supervised user token has been invalidated.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 this.parentNode.showSigninUI(this.user.emailAddress); 1408 this.parentNode.showSigninUI(this.user.emailAddress);
1414 } 1409 }
1415 }, 1410 },
1416 1411
1417 /** 1412 /**
1418 * Resets the input field and updates the tab order of pod controls. 1413 * Resets the input field and updates the tab order of pod controls.
1419 * @param {boolean} takeFocus If true, input field takes focus. 1414 * @param {boolean} takeFocus If true, input field takes focus.
1420 */ 1415 */
1421 reset: function(takeFocus) { 1416 reset: function(takeFocus) {
1422 this.passwordElement.value = ''; 1417 this.passwordElement.value = '';
1418 if (this.pinKeyboard.inputElement)
1419 this.pinKeyboard.clear();
jdufault 2016/07/11 22:35:08 this.pinKeyboard.value = '' should work. Remove cl
sammiequon 2016/07/11 23:13:24 Done. PinKeyboard still exists if the user is ent
jdufault 2016/07/11 23:31:40 Remove the if statement then?
sammiequon 2016/07/11 23:54:43 Done.
1423 this.classList.toggle('signing-in', false); 1420 this.classList.toggle('signing-in', false);
1424 if (takeFocus) { 1421 if (takeFocus) {
1425 if (!this.multiProfilesPolicyApplied) 1422 if (!this.multiProfilesPolicyApplied)
1426 this.focusInput(); // This will set a custom tab order. 1423 this.focusInput(); // This will set a custom tab order.
1427 } 1424 }
1428 else 1425 else
1429 this.resetTabOrder(); 1426 this.resetTabOrder();
1430 }, 1427 },
1431 1428
1432 /** 1429 /**
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 if (this.parentNode.disabled) 1807 if (this.parentNode.disabled)
1811 return; 1808 return;
1812 1809
1813 if (!this.isActionBoxMenuActive) { 1810 if (!this.isActionBoxMenuActive) {
1814 if (this.isAuthTypeOnlineSignIn) { 1811 if (this.isAuthTypeOnlineSignIn) {
1815 this.showSigninUI(); 1812 this.showSigninUI();
1816 } else if (this.isAuthTypeUserClick && this.userClickAuthAllowed_) { 1813 } else if (this.isAuthTypeUserClick && this.userClickAuthAllowed_) {
1817 // Note that this.userClickAuthAllowed_ is set in mouse down event 1814 // Note that this.userClickAuthAllowed_ is set in mouse down event
1818 // handler. 1815 // handler.
1819 this.parentNode.setActivatedPod(this); 1816 this.parentNode.setActivatedPod(this);
1817 } else if (this.pinKeyboard.submitButton &&
jdufault 2016/07/11 22:35:08 Can the if be if (this.pinKeyboard && e.target
sammiequon 2016/07/11 23:13:24 For this we need to check when the click is coming
1818 e.target == this.pinKeyboard.submitButton) {
1819 // Sets the pod as activated if the submit button is clicked so that
1820 // it simulates what the enter button does for the password/pin.
1821 this.parentNode.setActivatedPod(this);
1820 } 1822 }
1821 1823
1822 if (this.multiProfilesPolicyApplied) 1824 if (this.multiProfilesPolicyApplied)
1823 this.userTypeBubbleElement.classList.add('bubble-shown'); 1825 this.userTypeBubbleElement.classList.add('bubble-shown');
1824 1826
1825 // Prevent default so that we don't trigger 'focus' event and 1827 // Prevent default so that we don't trigger 'focus' event and
1826 // stop propagation so that the 'click' event does not bubble 1828 // stop propagation so that the 'click' event does not bubble
1827 // up and accidentally closes the bubble tooltip. 1829 // up and accidentally closes the bubble tooltip.
1828 stopEventPropagation(e); 1830 stopEventPropagation(e);
1829 } 1831 }
(...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after
3406 else 3408 else
3407 this.focusPod(this.firstElementChild); 3409 this.focusPod(this.firstElementChild);
3408 3410
3409 e.stopPropagation(); 3411 e.stopPropagation();
3410 } 3412 }
3411 break; 3413 break;
3412 case 'Enter': 3414 case 'Enter':
3413 if (this.focusedPod_) { 3415 if (this.focusedPod_) {
3414 var targetTag = e.target.tagName; 3416 var targetTag = e.target.tagName;
3415 if (e.target == this.focusedPod_.passwordElement || 3417 if (e.target == this.focusedPod_.passwordElement ||
3418 e.target == this.focusedPod_.pinKeyboard.inputElement ||
jdufault 2016/07/11 22:35:08 Is there a way to avoid exposing the inputElement
sammiequon 2016/07/11 23:13:24 We need the input element to be passed to the show
3416 (targetTag != 'INPUT' && 3419 (targetTag != 'INPUT' &&
3417 targetTag != 'BUTTON' && 3420 targetTag != 'BUTTON' &&
3418 targetTag != 'A')) { 3421 targetTag != 'A')) {
3419 this.setActivatedPod(this.focusedPod_, e); 3422 this.setActivatedPod(this.focusedPod_, e);
3420 e.stopPropagation(); 3423 e.stopPropagation();
3421 } 3424 }
3422 } 3425 }
3423 break; 3426 break;
3424 case 'Escape': 3427 case 'Escape':
3425 if (!this.alwaysFocusSinglePod) 3428 if (!this.alwaysFocusSinglePod)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
3511 if (pod && pod.multiProfilesPolicyApplied) { 3514 if (pod && pod.multiProfilesPolicyApplied) {
3512 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3515 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3513 } 3516 }
3514 } 3517 }
3515 }; 3518 };
3516 3519
3517 return { 3520 return {
3518 PodRow: PodRow 3521 PodRow: PodRow
3519 }; 3522 };
3520 }); 3523 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698