| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 */ | 118 */ |
| 119 var AUTH_TYPE_NAMES = { | 119 var AUTH_TYPE_NAMES = { |
| 120 0: 'offlinePassword', | 120 0: 'offlinePassword', |
| 121 1: 'onlineSignIn', | 121 1: 'onlineSignIn', |
| 122 2: 'numericPin', | 122 2: 'numericPin', |
| 123 3: 'userClick', | 123 3: 'userClick', |
| 124 4: 'expandThenUserClick', | 124 4: 'expandThenUserClick', |
| 125 5: 'forceOfflinePassword' | 125 5: 'forceOfflinePassword' |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 /** |
| 129 * Supported fingerprint unlock states. |
| 130 * @enum {number} |
| 131 * @const |
| 132 */ |
| 133 var FINGERPRINT_STATES = { |
| 134 HIDDEN: 0, |
| 135 DEFAULT: 1, |
| 136 SIGNIN: 2, |
| 137 FAILED: 3, |
| 138 }; |
| 139 |
| 140 /** |
| 141 * The fingerprint states to classes mapping. |
| 142 * {@code state} properties indicate current fingerprint unlock state. |
| 143 * {@code class} properties are CSS classes used to set the icons' background |
| 144 * and password placeholder color. |
| 145 * @const {Array<{type: !number, class: !string}>} |
| 146 */ |
| 147 var FINGERPRINT_STATES_MAPPING = [ |
| 148 {state: FINGERPRINT_STATES.HIDDEN, class: 'hidden'}, |
| 149 {state: FINGERPRINT_STATES.DEFAULT, class: 'default'}, |
| 150 {state: FINGERPRINT_STATES.SIGNIN, class: 'signin'}, |
| 151 {state: FINGERPRINT_STATES.FAILED, class: 'failed'} |
| 152 ]; |
| 153 |
| 128 // Focus and tab order are organized as follows: | 154 // Focus and tab order are organized as follows: |
| 129 // | 155 // |
| 130 // (1) all user pods have tab index 1 so they are traversed first; | 156 // (1) all user pods have tab index 1 so they are traversed first; |
| 131 // (2) when a user pod is activated, its tab index is set to -1 and its | 157 // (2) when a user pod is activated, its tab index is set to -1 and its |
| 132 // main input field gets focus and tab index 1; | 158 // main input field gets focus and tab index 1; |
| 133 // (3) if user pod custom icon is interactive, it has tab index 2 so it | 159 // (3) if user pod custom icon is interactive, it has tab index 2 so it |
| 134 // follows the input. | 160 // follows the input. |
| 135 // (4) buttons on the header bar have tab index 3 so they follow the custom | 161 // (4) buttons on the header bar have tab index 3 so they follow the custom |
| 136 // icon, or user pod if custom icon is not interactive; | 162 // icon, or user pod if custom icon is not interactive; |
| 137 // (5) Action box buttons have tab index 4 and follow header bar buttons; | 163 // (5) Action box buttons have tab index 4 and follow header bar buttons; |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 | 730 |
| 705 /** | 731 /** |
| 706 * Whether click on the pod can issue a user click auth attempt. The | 732 * Whether click on the pod can issue a user click auth attempt. The |
| 707 * attempt can be issued iff the pod was focused when the click | 733 * attempt can be issued iff the pod was focused when the click |
| 708 * started (i.e. on mouse down event). | 734 * started (i.e. on mouse down event). |
| 709 * @type {boolean} | 735 * @type {boolean} |
| 710 * @private | 736 * @private |
| 711 */ | 737 */ |
| 712 userClickAuthAllowed_: false, | 738 userClickAuthAllowed_: false, |
| 713 | 739 |
| 740 /** |
| 741 * Whether the user has recently authenticated with fingerprint. |
| 742 * @type {boolean} |
| 743 * @private |
| 744 */ |
| 745 fingerprintAuthenticated_: false, |
| 746 |
| 714 /** @override */ | 747 /** @override */ |
| 715 decorate: function() { | 748 decorate: function() { |
| 716 this.tabIndex = UserPodTabOrder.POD_INPUT; | 749 this.tabIndex = UserPodTabOrder.POD_INPUT; |
| 717 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT; | 750 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT; |
| 718 | 751 |
| 719 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this)); | 752 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this)); |
| 720 this.addEventListener('click', this.handleClickOnPod_.bind(this)); | 753 this.addEventListener('click', this.handleClickOnPod_.bind(this)); |
| 721 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this)); | 754 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this)); |
| 722 | 755 |
| 723 if (this.pinKeyboard) { | 756 if (this.pinKeyboard) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 743 this.handleRemoveCommandClick_.bind(this)); | 776 this.handleRemoveCommandClick_.bind(this)); |
| 744 this.actionBoxMenuRemoveElement.addEventListener('keydown', | 777 this.actionBoxMenuRemoveElement.addEventListener('keydown', |
| 745 this.handleRemoveCommandKeyDown_.bind(this)); | 778 this.handleRemoveCommandKeyDown_.bind(this)); |
| 746 this.actionBoxMenuRemoveElement.addEventListener('blur', | 779 this.actionBoxMenuRemoveElement.addEventListener('blur', |
| 747 this.handleRemoveCommandBlur_.bind(this)); | 780 this.handleRemoveCommandBlur_.bind(this)); |
| 748 this.actionBoxRemoveUserWarningButtonElement.addEventListener('click', | 781 this.actionBoxRemoveUserWarningButtonElement.addEventListener('click', |
| 749 this.handleRemoveUserConfirmationClick_.bind(this)); | 782 this.handleRemoveUserConfirmationClick_.bind(this)); |
| 750 this.actionBoxRemoveUserWarningButtonElement.addEventListener('keydown', | 783 this.actionBoxRemoveUserWarningButtonElement.addEventListener('keydown', |
| 751 this.handleRemoveUserConfirmationKeyDown_.bind(this)); | 784 this.handleRemoveUserConfirmationKeyDown_.bind(this)); |
| 752 | 785 |
| 786 if (this.fingerprintIconElement) { |
| 787 this.fingerprintIconElement.addEventListener( |
| 788 'mouseover', this.handleFingerprintIconMouseOver_.bind(this)); |
| 789 this.fingerprintIconElement.addEventListener( |
| 790 'mouseout', this.handleFingerprintIconMouseOut_.bind(this)); |
| 791 this.fingerprintIconElement.addEventListener( |
| 792 'mousedown', stopEventPropagation); |
| 793 } |
| 794 |
| 753 var customIcon = this.customIconElement; | 795 var customIcon = this.customIconElement; |
| 754 customIcon.parentNode.replaceChild(new UserPodCustomIcon(), customIcon); | 796 customIcon.parentNode.replaceChild(new UserPodCustomIcon(), customIcon); |
| 755 }, | 797 }, |
| 756 | 798 |
| 757 /** | 799 /** |
| 758 * Initializes the pod after its properties set and added to a pod row. | 800 * Initializes the pod after its properties set and added to a pod row. |
| 759 */ | 801 */ |
| 760 initialize: function() { | 802 initialize: function() { |
| 761 this.passwordElement.addEventListener('keydown', | 803 this.passwordElement.addEventListener('keydown', |
| 762 this.parentNode.handleKeyDown.bind(this.parentNode)); | 804 this.parentNode.handleKeyDown.bind(this.parentNode)); |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 'Passwords': | 1131 'Passwords': |
| 1090 this.querySelector('.action-box-remove-user-warning-passwords'), | 1132 this.querySelector('.action-box-remove-user-warning-passwords'), |
| 1091 'Bookmarks': | 1133 'Bookmarks': |
| 1092 this.querySelector('.action-box-remove-user-warning-bookmarks'), | 1134 this.querySelector('.action-box-remove-user-warning-bookmarks'), |
| 1093 'Settings': | 1135 'Settings': |
| 1094 this.querySelector('.action-box-remove-user-warning-settings') | 1136 this.querySelector('.action-box-remove-user-warning-settings') |
| 1095 } | 1137 } |
| 1096 }, | 1138 }, |
| 1097 | 1139 |
| 1098 /** | 1140 /** |
| 1141 * Gets the fingerprint icon area. |
| 1142 * @type {!HTMLDivElement} |
| 1143 */ |
| 1144 get fingerprintIconElement() { |
| 1145 return this.querySelector('.fingerprint-icon-container'); |
| 1146 }, |
| 1147 |
| 1148 /** |
| 1099 * Updates the user pod element. | 1149 * Updates the user pod element. |
| 1100 */ | 1150 */ |
| 1101 update: function() { | 1151 update: function() { |
| 1102 this.imageElement.src = 'chrome://userimage/' + this.user.username + | 1152 this.imageElement.src = 'chrome://userimage/' + this.user.username + |
| 1103 '?id=' + UserPod.userImageSalt_[this.user.username]; | 1153 '?id=' + UserPod.userImageSalt_[this.user.username]; |
| 1104 | 1154 |
| 1105 this.nameElement.textContent = this.user_.displayName; | 1155 this.nameElement.textContent = this.user_.displayName; |
| 1106 this.reauthNameHintElement.textContent = this.user_.displayName; | 1156 this.reauthNameHintElement.textContent = this.user_.displayName; |
| 1107 this.classList.toggle('signed-in', this.user_.signedIn); | 1157 this.classList.toggle('signed-in', this.user_.signedIn); |
| 1108 | 1158 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 | 1259 |
| 1210 isPinShown: function() { | 1260 isPinShown: function() { |
| 1211 return this.classList.contains('pin-enabled'); | 1261 return this.classList.contains('pin-enabled'); |
| 1212 }, | 1262 }, |
| 1213 | 1263 |
| 1214 setUserPodIconType: function(userTypeClass) { | 1264 setUserPodIconType: function(userTypeClass) { |
| 1215 this.userTypeIconAreaElement.classList.add(userTypeClass); | 1265 this.userTypeIconAreaElement.classList.add(userTypeClass); |
| 1216 this.userTypeIconAreaElement.hidden = false; | 1266 this.userTypeIconAreaElement.hidden = false; |
| 1217 }, | 1267 }, |
| 1218 | 1268 |
| 1269 isFingerprintIconShown: function() { |
| 1270 return this.fingerprintIconElement && !this.fingerprintIconElement.hidden; |
| 1271 }, |
| 1272 |
| 1219 /** | 1273 /** |
| 1220 * The user that this pod represents. | 1274 * The user that this pod represents. |
| 1221 * @type {!Object} | 1275 * @type {!Object} |
| 1222 */ | 1276 */ |
| 1223 user_: undefined, | 1277 user_: undefined, |
| 1224 get user() { | 1278 get user() { |
| 1225 return this.user_; | 1279 return this.user_; |
| 1226 }, | 1280 }, |
| 1227 set user(userDict) { | 1281 set user(userDict) { |
| 1228 this.user_ = userDict; | 1282 this.user_ = userDict; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 * @return {boolean} True if activated successfully. | 1459 * @return {boolean} True if activated successfully. |
| 1406 */ | 1460 */ |
| 1407 activate: function(e) { | 1461 activate: function(e) { |
| 1408 if (this.isAuthTypeOnlineSignIn) { | 1462 if (this.isAuthTypeOnlineSignIn) { |
| 1409 this.showSigninUI(); | 1463 this.showSigninUI(); |
| 1410 } else if (this.isAuthTypeUserClick) { | 1464 } else if (this.isAuthTypeUserClick) { |
| 1411 Oobe.disableSigninUI(); | 1465 Oobe.disableSigninUI(); |
| 1412 this.classList.toggle('signing-in', true); | 1466 this.classList.toggle('signing-in', true); |
| 1413 chrome.send('attemptUnlock', [this.user.username]); | 1467 chrome.send('attemptUnlock', [this.user.username]); |
| 1414 } else if (this.isAuthTypePassword) { | 1468 } else if (this.isAuthTypePassword) { |
| 1469 if (this.fingerprintAuthenticated_) { |
| 1470 this.fingerprintAuthenticated_ = false; |
| 1471 return true; |
| 1472 } |
| 1415 var pinValue = this.pinKeyboard ? this.pinKeyboard.value : ''; | 1473 var pinValue = this.pinKeyboard ? this.pinKeyboard.value : ''; |
| 1416 var password = this.passwordElement.value || pinValue; | 1474 var password = this.passwordElement.value || pinValue; |
| 1417 if (!password) | 1475 if (!password) |
| 1418 return false; | 1476 return false; |
| 1419 Oobe.disableSigninUI(); | 1477 Oobe.disableSigninUI(); |
| 1420 chrome.send('authenticateUser', [this.user.username, password, | 1478 chrome.send('authenticateUser', [this.user.username, password, |
| 1421 this.isPinShown()]); | 1479 this.isPinShown()]); |
| 1422 } else { | 1480 } else { |
| 1423 console.error('Activating user pod with invalid authentication type: ' + | 1481 console.error('Activating user pod with invalid authentication type: ' + |
| 1424 this.authType); | 1482 this.authType); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1815 */ | 1873 */ |
| 1816 handleRemoveUserConfirmationClick_: function(e) { | 1874 handleRemoveUserConfirmationClick_: function(e) { |
| 1817 if (this.isActionBoxMenuActive) { | 1875 if (this.isActionBoxMenuActive) { |
| 1818 this.isActionBoxMenuActive = false; | 1876 this.isActionBoxMenuActive = false; |
| 1819 this.removeUser(this.user); | 1877 this.removeUser(this.user); |
| 1820 e.stopPropagation(); | 1878 e.stopPropagation(); |
| 1821 } | 1879 } |
| 1822 }, | 1880 }, |
| 1823 | 1881 |
| 1824 /** | 1882 /** |
| 1883 * Handles mouseover event on fingerprint icon. |
| 1884 * @param {Event} e MouseOver event. |
| 1885 */ |
| 1886 handleFingerprintIconMouseOver_: function(e) { |
| 1887 var bubbleContent = document.createElement('div'); |
| 1888 bubbleContent.textContent = |
| 1889 loadTimeData.getString('fingerprintIconMessage'); |
| 1890 this.passwordElement.placeholder = |
| 1891 loadTimeData.getString('fingerprintHint'); |
| 1892 |
| 1893 /** @const */ var BUBBLE_OFFSET = 25; |
| 1894 /** @const */ var BUBBLE_PADDING = -8; |
| 1895 var attachment = this.isPinShown() ? cr.ui.Bubble.Attachment.RIGHT : |
| 1896 cr.ui.Bubble.Attachment.BOTTOM; |
| 1897 var bubbleAnchor = this.getBubbleAnchorForFingerprintIcon_(); |
| 1898 $('bubble').showContentForElement( |
| 1899 bubbleAnchor, attachment, bubbleContent, BUBBLE_OFFSET, |
| 1900 BUBBLE_PADDING, true); |
| 1901 }, |
| 1902 |
| 1903 /** |
| 1904 * Handles mouseout event on fingerprint icon. |
| 1905 * @param {Event} e MouseOut event. |
| 1906 */ |
| 1907 handleFingerprintIconMouseOut_: function(e) { |
| 1908 var bubbleAnchor = this.getBubbleAnchorForFingerprintIcon_(); |
| 1909 $('bubble').hideForElement(bubbleAnchor); |
| 1910 this.passwordElement.placeholder = loadTimeData.getString( |
| 1911 this.isPinShown() ? 'pinKeyboardPlaceholderPinPassword' : |
| 1912 'passwordHint'); |
| 1913 }, |
| 1914 |
| 1915 /** |
| 1916 * Returns bubble anchor of the fingerprint icon. |
| 1917 * @return {!HTMLElement} Anchor element of the bubble. |
| 1918 */ |
| 1919 getBubbleAnchorForFingerprintIcon_: function() { |
| 1920 var bubbleAnchor = this; |
| 1921 if (this.isPinShown()) |
| 1922 bubbleAnchor = (this.getElementsByClassName('auth-container'))[0]; |
| 1923 return bubbleAnchor; |
| 1924 }, |
| 1925 |
| 1926 /** |
| 1825 * Handles a keydown event on remove user confirmation button. | 1927 * Handles a keydown event on remove user confirmation button. |
| 1826 * @param {Event} e KeyDown event. | 1928 * @param {Event} e KeyDown event. |
| 1827 */ | 1929 */ |
| 1828 handleRemoveUserConfirmationKeyDown_: function(e) { | 1930 handleRemoveUserConfirmationKeyDown_: function(e) { |
| 1829 if (!this.isActionBoxMenuActive) | 1931 if (!this.isActionBoxMenuActive) |
| 1830 return; | 1932 return; |
| 1831 | 1933 |
| 1832 // Only handle pressing 'Enter' or 'Space', and let all other events | 1934 // Only handle pressing 'Enter' or 'Space', and let all other events |
| 1833 // bubble to the action box menu. | 1935 // bubble to the action box menu. |
| 1834 if (e.key == 'Enter' || e.key == ' ') { | 1936 if (e.key == 'Enter' || e.key == ' ') { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 */ | 1994 */ |
| 1893 handlePodMouseDown_: function(e) { | 1995 handlePodMouseDown_: function(e) { |
| 1894 this.userClickAuthAllowed_ = this.parentNode.isFocused(this); | 1996 this.userClickAuthAllowed_ = this.parentNode.isFocused(this); |
| 1895 }, | 1997 }, |
| 1896 | 1998 |
| 1897 /** | 1999 /** |
| 1898 * Called when the input of the password element changes. Updates the submit | 2000 * Called when the input of the password element changes. Updates the submit |
| 1899 * button color and state and hides the error popup bubble. | 2001 * button color and state and hides the error popup bubble. |
| 1900 */ | 2002 */ |
| 1901 updateInput_: function() { | 2003 updateInput_: function() { |
| 1902 if (this.submitButton) | 2004 if (this.submitButton) { |
| 1903 this.submitButton.disabled = this.passwordElement.value.length <= 0; | 2005 this.submitButton.disabled = this.passwordElement.value.length == 0; |
| 2006 if (this.isFingerprintIconShown()) { |
| 2007 this.submitButton.hidden = this.passwordElement.value.length == 0; |
| 2008 } else { |
| 2009 this.submitButton.hidden = false; |
| 2010 } |
| 2011 } |
| 1904 this.showError = false; | 2012 this.showError = false; |
| 1905 $('bubble').hide(); | 2013 $('bubble').hide(); |
| 1906 }, | 2014 }, |
| 1907 | 2015 |
| 1908 /** | 2016 /** |
| 1909 * Handles input event on the password element. | 2017 * Handles input event on the password element. |
| 1910 * @param {Event} e Input event. | 2018 * @param {Event} e Input event. |
| 1911 */ | 2019 */ |
| 1912 handleInputChanged_: function(e) { | 2020 handleInputChanged_: function(e) { |
| 1913 this.updateInput_(); | 2021 this.updateInput_(); |
| (...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2994 pod.customIconElement.setAriaLabel(ariaLabel); | 3102 pod.customIconElement.setAriaLabel(ariaLabel); |
| 2995 else | 3103 else |
| 2996 console.warn('No ARIA label for user pod custom icon.'); | 3104 console.warn('No ARIA label for user pod custom icon.'); |
| 2997 | 3105 |
| 2998 pod.customIconElement.show(); | 3106 pod.customIconElement.show(); |
| 2999 | 3107 |
| 3000 // This has to be called after |show| in case the tooltip should be shown | 3108 // This has to be called after |show| in case the tooltip should be shown |
| 3001 // immediatelly. | 3109 // immediatelly. |
| 3002 pod.customIconElement.setTooltip( | 3110 pod.customIconElement.setTooltip( |
| 3003 icon.tooltip || {text: '', autoshow: false}); | 3111 icon.tooltip || {text: '', autoshow: false}); |
| 3112 |
| 3113 // Hide fingerprint icon when custom icon is shown. |
| 3114 this.setUserPodFingerprintIcon(username, FINGERPRINT_STATES.HIDDEN); |
| 3004 }, | 3115 }, |
| 3005 | 3116 |
| 3006 /** | 3117 /** |
| 3007 * Hard-locks user pod for the user. If user pod is hard-locked, it can be | 3118 * Hard-locks user pod for the user. If user pod is hard-locked, it can be |
| 3008 * only unlocked using password, and the authentication type cannot be | 3119 * only unlocked using password, and the authentication type cannot be |
| 3009 * changed. | 3120 * changed. |
| 3010 * @param {!string} username The user's username. | 3121 * @param {!string} username The user's username. |
| 3011 * @private | 3122 * @private |
| 3012 */ | 3123 */ |
| 3013 hardlockUserPod_: function(username) { | 3124 hardlockUserPod_: function(username) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3030 */ | 3141 */ |
| 3031 hideUserPodCustomIcon: function(username) { | 3142 hideUserPodCustomIcon: function(username) { |
| 3032 var pod = this.getPodWithUsername_(username); | 3143 var pod = this.getPodWithUsername_(username); |
| 3033 if (pod == null) { | 3144 if (pod == null) { |
| 3034 console.error('Unable to hide user pod button: user pod not found.'); | 3145 console.error('Unable to hide user pod button: user pod not found.'); |
| 3035 return; | 3146 return; |
| 3036 } | 3147 } |
| 3037 | 3148 |
| 3038 // TODO(tengs): Allow option for a fading transition. | 3149 // TODO(tengs): Allow option for a fading transition. |
| 3039 pod.customIconElement.hide(); | 3150 pod.customIconElement.hide(); |
| 3151 |
| 3152 // Show fingerprint icon if applicable. |
| 3153 this.setUserPodFingerprintIcon(username, FINGERPRINT_STATES.DEFAULT); |
| 3040 }, | 3154 }, |
| 3041 | 3155 |
| 3042 /** | 3156 /** |
| 3157 * Set a fingerprint icon in the user pod of |username|. |
| 3158 * @param {string} username Username of the selected user |
| 3159 * @param {number} state Fingerprint unlock state |
| 3160 */ |
| 3161 setUserPodFingerprintIcon: function(username, state) { |
| 3162 var pod = this.getPodWithUsername_(username); |
| 3163 if (pod == null) { |
| 3164 console.error( |
| 3165 'Unable to set user pod fingerprint icon: user pod not found.'); |
| 3166 return; |
| 3167 } |
| 3168 pod.fingerprintAuthenticated_ = false; |
| 3169 if (!pod.fingerprintIconElement) |
| 3170 return; |
| 3171 if (!pod.user.allowFingerprint || state == FINGERPRINT_STATES.HIDDEN || |
| 3172 !pod.customIconElement.hidden) { |
| 3173 pod.fingerprintIconElement.hidden = true; |
| 3174 pod.submitButton.hidden = false; |
| 3175 return; |
| 3176 } |
| 3177 |
| 3178 FINGERPRINT_STATES_MAPPING.forEach(function(icon) { |
| 3179 pod.fingerprintIconElement.classList.toggle( |
| 3180 icon.class, state == icon.state); |
| 3181 }); |
| 3182 pod.fingerprintIconElement.hidden = false; |
| 3183 pod.submitButton.hidden = pod.passwordElement.value.length == 0; |
| 3184 this.updatePasswordField_(pod, state); |
| 3185 if (state == FINGERPRINT_STATES.DEFAULT) |
| 3186 return; |
| 3187 |
| 3188 pod.fingerprintAuthenticated_ = true; |
| 3189 this.setActivatedPod(pod); |
| 3190 if (state == FINGERPRINT_STATES.FAILED) { |
| 3191 /** @const */ var RESET_ICON_TIMEOUT_MS = 500; |
| 3192 setTimeout( |
| 3193 this.resetIconAndPasswordField_.bind(this, pod), |
| 3194 RESET_ICON_TIMEOUT_MS); |
| 3195 } |
| 3196 }, |
| 3197 |
| 3198 /** |
| 3199 * Reset the fingerprint icon and password field. |
| 3200 * @param {UserPod} pod Pod to reset. |
| 3201 */ |
| 3202 resetIconAndPasswordField_: function(pod) { |
| 3203 if (!pod.fingerprintIconElement) |
| 3204 return; |
| 3205 this.setUserPodFingerprintIcon( |
| 3206 pod.user.username, FINGERPRINT_STATES.DEFAULT); |
| 3207 }, |
| 3208 |
| 3209 /** |
| 3210 * Remove the fingerprint icon in the user pod. |
| 3211 * @param {string} username Username of the selected user |
| 3212 */ |
| 3213 removeUserPodFingerprintIcon: function(username) { |
| 3214 var pod = this.getPodWithUsername_(username); |
| 3215 if (pod == null) { |
| 3216 console.error('No user pod found (when removing fingerprint icon).'); |
| 3217 return; |
| 3218 } |
| 3219 this.resetIconAndPasswordField_(pod); |
| 3220 if (pod.fingerprintIconElement) { |
| 3221 pod.fingerprintIconElement.parentNode.removeChild( |
| 3222 pod.fingerprintIconElement); |
| 3223 } |
| 3224 pod.submitButton.hidden = false; |
| 3225 }, |
| 3226 |
| 3227 /** |
| 3228 * Updates the password field in the user pod. |
| 3229 * @param {UserPod} pod Pod to update. |
| 3230 * @param {number} state Fingerprint unlock state |
| 3231 */ |
| 3232 updatePasswordField_: function(pod, state) { |
| 3233 FINGERPRINT_STATES_MAPPING.forEach(function(item) { |
| 3234 pod.passwordElement.classList.toggle(item.class, state == item.state); |
| 3235 }); |
| 3236 var placeholderStr = loadTimeData.getString( |
| 3237 pod.isPinShown() ? 'pinKeyboardPlaceholderPinPassword' : |
| 3238 'passwordHint'); |
| 3239 if (state == FINGERPRINT_STATES.SIGNIN) { |
| 3240 placeholderStr = loadTimeData.getString('fingerprintSigningin'); |
| 3241 } else if (state == FINGERPRINT_STATES.FAILED) { |
| 3242 placeholderStr = loadTimeData.getString('fingerprintSigninFailed'); |
| 3243 } |
| 3244 pod.passwordElement.placeholder = placeholderStr; |
| 3245 }, |
| 3246 |
| 3247 /** |
| 3043 * Sets the authentication type used to authenticate the user. | 3248 * Sets the authentication type used to authenticate the user. |
| 3044 * @param {string} username Username of selected user | 3249 * @param {string} username Username of selected user |
| 3045 * @param {number} authType Authentication type, must be one of the | 3250 * @param {number} authType Authentication type, must be one of the |
| 3046 * values listed in AUTH_TYPE enum. | 3251 * values listed in AUTH_TYPE enum. |
| 3047 * @param {string} value The initial value to use for authentication. | 3252 * @param {string} value The initial value to use for authentication. |
| 3048 */ | 3253 */ |
| 3049 setAuthType: function(username, authType, value) { | 3254 setAuthType: function(username, authType, value) { |
| 3050 var pod = this.getPodWithUsername_(username); | 3255 var pod = this.getPodWithUsername_(username); |
| 3051 if (pod == null) { | 3256 if (pod == null) { |
| 3052 console.error('Unable to set auth type: user pod not found.'); | 3257 console.error('Unable to set auth type: user pod not found.'); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3301 this.insideFocusPod_ = true; | 3506 this.insideFocusPod_ = true; |
| 3302 | 3507 |
| 3303 for (var i = 0, pod; pod = this.pods[i]; ++i) { | 3508 for (var i = 0, pod; pod = this.pods[i]; ++i) { |
| 3304 if (!this.alwaysFocusSinglePod) { | 3509 if (!this.alwaysFocusSinglePod) { |
| 3305 pod.isActionBoxMenuActive = false; | 3510 pod.isActionBoxMenuActive = false; |
| 3306 } | 3511 } |
| 3307 if (pod != podToFocus) { | 3512 if (pod != podToFocus) { |
| 3308 pod.isActionBoxMenuHovered = false; | 3513 pod.isActionBoxMenuHovered = false; |
| 3309 pod.classList.remove('focused'); | 3514 pod.classList.remove('focused'); |
| 3310 pod.setPinVisibility(false); | 3515 pod.setPinVisibility(false); |
| 3516 this.setUserPodFingerprintIcon( |
| 3517 pod.user.username, FINGERPRINT_STATES.HIDDEN); |
| 3311 // On Desktop, the faded style is not set correctly, so we should | 3518 // On Desktop, the faded style is not set correctly, so we should |
| 3312 // manually fade out non-focused pods if there is a focused pod. | 3519 // manually fade out non-focused pods if there is a focused pod. |
| 3313 if (pod.user.isDesktopUser && podToFocus) | 3520 if (pod.user.isDesktopUser && podToFocus) |
| 3314 pod.classList.add('faded'); | 3521 pod.classList.add('faded'); |
| 3315 else | 3522 else |
| 3316 pod.classList.remove('faded'); | 3523 pod.classList.remove('faded'); |
| 3317 pod.reset(false); | 3524 pod.reset(false); |
| 3318 } | 3525 } |
| 3319 } | 3526 } |
| 3320 | 3527 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3340 // is false, it doesn't focus on the password input box by default. | 3547 // is false, it doesn't focus on the password input box by default. |
| 3341 podToFocus.focus(); | 3548 podToFocus.focus(); |
| 3342 } | 3549 } |
| 3343 | 3550 |
| 3344 // focusPod() automatically loads wallpaper | 3551 // focusPod() automatically loads wallpaper |
| 3345 if (!podToFocus.user.isApp) | 3552 if (!podToFocus.user.isApp) |
| 3346 chrome.send('focusPod', [podToFocus.user.username]); | 3553 chrome.send('focusPod', [podToFocus.user.username]); |
| 3347 this.firstShown_ = false; | 3554 this.firstShown_ = false; |
| 3348 this.lastFocusedPod_ = podToFocus; | 3555 this.lastFocusedPod_ = podToFocus; |
| 3349 this.scrollFocusedPodIntoView(); | 3556 this.scrollFocusedPodIntoView(); |
| 3557 this.setUserPodFingerprintIcon( |
| 3558 podToFocus.user.username, FINGERPRINT_STATES.DEFAULT); |
| 3350 } else { | 3559 } else { |
| 3351 chrome.send('noPodFocused'); | 3560 chrome.send('noPodFocused'); |
| 3352 } | 3561 } |
| 3353 this.insideFocusPod_ = false; | 3562 this.insideFocusPod_ = false; |
| 3354 }, | 3563 }, |
| 3355 | 3564 |
| 3356 /** | 3565 /** |
| 3357 * Resets wallpaper to the last active user's wallpaper, if any. | 3566 * Resets wallpaper to the last active user's wallpaper, if any. |
| 3358 */ | 3567 */ |
| 3359 loadLastWallpaper: function() { | 3568 loadLastWallpaper: function() { |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3731 if (pod && pod.multiProfilesPolicyApplied) { | 3940 if (pod && pod.multiProfilesPolicyApplied) { |
| 3732 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3941 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3733 } | 3942 } |
| 3734 } | 3943 } |
| 3735 }; | 3944 }; |
| 3736 | 3945 |
| 3737 return { | 3946 return { |
| 3738 PodRow: PodRow | 3947 PodRow: PodRow |
| 3739 }; | 3948 }; |
| 3740 }); | 3949 }); |
| OLD | NEW |