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 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: 0, class: 'hidden'}, | |
| 149 {state: 1, class: 'default'}, | |
| 150 {state: 2, class: 'signin'}, | |
| 151 {state: 3, class: 'failed'} | |
|
xiyuan
2017/03/10 17:51:10
nit: Can replace the numbers with the state const
xiaoyinh(OOO Sep 11-29)
2017/03/10 21:55:58
Done.
| |
| 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; | |
| 1898 if (this.isPinShown()) | |
| 1899 bubbleAnchor = (this.getElementsByClassName('auth-container'))[0]; | |
| 1900 $('bubble').showContentForElement( | |
| 1901 bubbleAnchor, attachment, bubbleContent, BUBBLE_OFFSET, | |
| 1902 BUBBLE_PADDING, true); | |
| 1903 }, | |
| 1904 | |
| 1905 /** | |
| 1906 * Handles mouseout event on fingerprint icon. | |
| 1907 * @param {Event} e MouseOut event. | |
| 1908 */ | |
| 1909 handleFingerprintIconMouseOut_: function(e) { | |
| 1910 if(this.isPinShown()) { | |
| 1911 $('bubble').hideForElement( | |
| 1912 (this.getElementsByClassName('auth-container'))[0]); | |
|
xiyuan
2017/03/10 17:51:10
nit: wrap the bubbleAnchor logic into a helper and
xiaoyinh(OOO Sep 11-29)
2017/03/10 21:55:58
Done.
| |
| 1913 } else { | |
| 1914 $('bubble').hideForElement(this); | |
| 1915 } | |
| 1916 this.passwordElement.placeholder = loadTimeData.getString( | |
| 1917 this.isPinShown() ? 'pinKeyboardPlaceholderPinPassword' : | |
| 1918 'passwordHint'); | |
| 1919 }, | |
| 1920 | |
| 1921 /** | |
| 1825 * Handles a keydown event on remove user confirmation button. | 1922 * Handles a keydown event on remove user confirmation button. |
| 1826 * @param {Event} e KeyDown event. | 1923 * @param {Event} e KeyDown event. |
| 1827 */ | 1924 */ |
| 1828 handleRemoveUserConfirmationKeyDown_: function(e) { | 1925 handleRemoveUserConfirmationKeyDown_: function(e) { |
| 1829 if (!this.isActionBoxMenuActive) | 1926 if (!this.isActionBoxMenuActive) |
| 1830 return; | 1927 return; |
| 1831 | 1928 |
| 1832 // Only handle pressing 'Enter' or 'Space', and let all other events | 1929 // Only handle pressing 'Enter' or 'Space', and let all other events |
| 1833 // bubble to the action box menu. | 1930 // bubble to the action box menu. |
| 1834 if (e.key == 'Enter' || e.key == ' ') { | 1931 if (e.key == 'Enter' || e.key == ' ') { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1892 */ | 1989 */ |
| 1893 handlePodMouseDown_: function(e) { | 1990 handlePodMouseDown_: function(e) { |
| 1894 this.userClickAuthAllowed_ = this.parentNode.isFocused(this); | 1991 this.userClickAuthAllowed_ = this.parentNode.isFocused(this); |
| 1895 }, | 1992 }, |
| 1896 | 1993 |
| 1897 /** | 1994 /** |
| 1898 * Called when the input of the password element changes. Updates the submit | 1995 * Called when the input of the password element changes. Updates the submit |
| 1899 * button color and state and hides the error popup bubble. | 1996 * button color and state and hides the error popup bubble. |
| 1900 */ | 1997 */ |
| 1901 updateInput_: function() { | 1998 updateInput_: function() { |
| 1902 if (this.submitButton) | 1999 if (this.submitButton) { |
| 1903 this.submitButton.disabled = this.passwordElement.value.length <= 0; | 2000 this.submitButton.disabled = this.passwordElement.value.length == 0; |
| 2001 if (this.isFingerprintIconShown()) { | |
| 2002 this.submitButton.hidden = this.passwordElement.value.length == 0; | |
| 2003 } else { | |
| 2004 this.submitButton.hidden = false; | |
| 2005 } | |
| 2006 } | |
| 1904 this.showError = false; | 2007 this.showError = false; |
| 1905 $('bubble').hide(); | 2008 $('bubble').hide(); |
| 1906 }, | 2009 }, |
| 1907 | 2010 |
| 1908 /** | 2011 /** |
| 1909 * Handles input event on the password element. | 2012 * Handles input event on the password element. |
| 1910 * @param {Event} e Input event. | 2013 * @param {Event} e Input event. |
| 1911 */ | 2014 */ |
| 1912 handleInputChanged_: function(e) { | 2015 handleInputChanged_: function(e) { |
| 1913 this.updateInput_(); | 2016 this.updateInput_(); |
| (...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2994 pod.customIconElement.setAriaLabel(ariaLabel); | 3097 pod.customIconElement.setAriaLabel(ariaLabel); |
| 2995 else | 3098 else |
| 2996 console.warn('No ARIA label for user pod custom icon.'); | 3099 console.warn('No ARIA label for user pod custom icon.'); |
| 2997 | 3100 |
| 2998 pod.customIconElement.show(); | 3101 pod.customIconElement.show(); |
| 2999 | 3102 |
| 3000 // This has to be called after |show| in case the tooltip should be shown | 3103 // This has to be called after |show| in case the tooltip should be shown |
| 3001 // immediatelly. | 3104 // immediatelly. |
| 3002 pod.customIconElement.setTooltip( | 3105 pod.customIconElement.setTooltip( |
| 3003 icon.tooltip || {text: '', autoshow: false}); | 3106 icon.tooltip || {text: '', autoshow: false}); |
| 3107 | |
| 3108 // Hide fingerprint icon when custom icon is shown. | |
| 3109 this.setUserPodFingerprintIcon(username, FINGERPRINT_STATES.HIDDEN); | |
| 3004 }, | 3110 }, |
| 3005 | 3111 |
| 3006 /** | 3112 /** |
| 3007 * Hard-locks user pod for the user. If user pod is hard-locked, it can be | 3113 * 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 | 3114 * only unlocked using password, and the authentication type cannot be |
| 3009 * changed. | 3115 * changed. |
| 3010 * @param {!string} username The user's username. | 3116 * @param {!string} username The user's username. |
| 3011 * @private | 3117 * @private |
| 3012 */ | 3118 */ |
| 3013 hardlockUserPod_: function(username) { | 3119 hardlockUserPod_: function(username) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 3030 */ | 3136 */ |
| 3031 hideUserPodCustomIcon: function(username) { | 3137 hideUserPodCustomIcon: function(username) { |
| 3032 var pod = this.getPodWithUsername_(username); | 3138 var pod = this.getPodWithUsername_(username); |
| 3033 if (pod == null) { | 3139 if (pod == null) { |
| 3034 console.error('Unable to hide user pod button: user pod not found.'); | 3140 console.error('Unable to hide user pod button: user pod not found.'); |
| 3035 return; | 3141 return; |
| 3036 } | 3142 } |
| 3037 | 3143 |
| 3038 // TODO(tengs): Allow option for a fading transition. | 3144 // TODO(tengs): Allow option for a fading transition. |
| 3039 pod.customIconElement.hide(); | 3145 pod.customIconElement.hide(); |
| 3146 | |
| 3147 // Show fingerprint icon if applicable. | |
| 3148 this.setUserPodFingerprintIcon(username, FINGERPRINT_STATES.DEFAULT); | |
| 3040 }, | 3149 }, |
| 3041 | 3150 |
| 3042 /** | 3151 /** |
| 3152 * Set a fingerprint icon in the user pod of |username|. | |
| 3153 * @param {string} username Username of the selected user | |
| 3154 * @param {number} state Fingerprint unlock state | |
| 3155 */ | |
| 3156 setUserPodFingerprintIcon: function(username, state) { | |
| 3157 var pod = this.getPodWithUsername_(username); | |
| 3158 if (pod == null) { | |
| 3159 console.error( | |
| 3160 'Unable to set user pod fingerprint icon: user pod not found.'); | |
| 3161 return; | |
| 3162 } | |
| 3163 pod.fingerprintAuthenticated_ = false; | |
| 3164 if (!pod.fingerprintIconElement) | |
| 3165 return; | |
| 3166 if (!pod.user.allowFingerprint || state == FINGERPRINT_STATES.HIDDEN || | |
| 3167 !pod.customIconElement.hidden) { | |
| 3168 pod.fingerprintIconElement.hidden = true; | |
| 3169 pod.submitButton.hidden = false; | |
| 3170 return; | |
| 3171 } | |
| 3172 | |
| 3173 FINGERPRINT_STATES_MAPPING.forEach(function(icon) { | |
| 3174 pod.fingerprintIconElement.classList.toggle( | |
| 3175 icon.class, state == icon.state); | |
| 3176 }); | |
| 3177 pod.fingerprintIconElement.setAttribute( | |
| 3178 'aria-label', loadTimeData.getString('fingerprintIconMessage')); | |
|
xiyuan
2017/03/10 17:51:10
The aria-label seems to be a const. Why not put it
xiaoyinh(OOO Sep 11-29)
2017/03/10 21:55:58
Done.
| |
| 3179 pod.fingerprintIconElement.hidden = false; | |
| 3180 pod.submitButton.hidden = pod.passwordElement.value.length == 0; | |
| 3181 this.updatePasswordField_(pod, state); | |
| 3182 if (state == FINGERPRINT_STATES.DEFAULT) | |
| 3183 return; | |
| 3184 | |
| 3185 pod.fingerprintAuthenticated_ = true; | |
| 3186 this.setActivatedPod(pod); | |
| 3187 if (state == FINGERPRINT_STATES.FAILED) { | |
| 3188 /** @const */ var RESET_ICON_TIMEOUT_MS = 500; | |
| 3189 setTimeout( | |
| 3190 this.resetIconAndPasswordField_.bind(this, pod), | |
| 3191 RESET_ICON_TIMEOUT_MS); | |
| 3192 } | |
| 3193 }, | |
| 3194 | |
| 3195 /** | |
| 3196 * Reset the fingerprint icon and password field. | |
| 3197 * @param {UserPod} pod Pod to reset. | |
| 3198 */ | |
| 3199 resetIconAndPasswordField_:function(pod) { | |
|
jdufault
2017/03/09 21:11:25
nit: space after ':'
xiaoyinh(OOO Sep 11-29)
2017/03/10 21:55:58
Done.
| |
| 3200 if (!pod.fingerprintIconElement) | |
| 3201 return; | |
| 3202 this.setUserPodFingerprintIcon( | |
| 3203 pod.user.username, FINGERPRINT_STATES.DEFAULT); | |
| 3204 }, | |
| 3205 | |
| 3206 /** | |
| 3207 * Remove the fingerprint icon in the user pod. | |
| 3208 * @param {string} username Username of the selected user | |
| 3209 */ | |
| 3210 removeUserPodFingerprintIcon: function(username) { | |
| 3211 var pod = this.getPodWithUsername_(username); | |
| 3212 if (pod == null) { | |
| 3213 console.error( | |
| 3214 'Unable to remove user pod fingerprint icon: user pod not found.'); | |
|
jdufault
2017/03/09 21:11:25
You might be able to get the console.error on one
xiaoyinh(OOO Sep 11-29)
2017/03/10 21:55:58
Done.
| |
| 3215 return; | |
| 3216 } | |
| 3217 this.resetIconAndPasswordField_(pod); | |
| 3218 if (pod.fingerprintIconElement) { | |
| 3219 pod.fingerprintIconElement.parentNode.removeChild( | |
| 3220 pod.fingerprintIconElement); | |
| 3221 } | |
| 3222 pod.submitButton.hidden = false; | |
| 3223 }, | |
| 3224 | |
| 3225 /** | |
| 3226 * Updates the password field in the user pod. | |
| 3227 * @param {UserPod} pod Pod to update. | |
| 3228 * @param {number} state Fingerprint unlock state | |
| 3229 */ | |
| 3230 updatePasswordField_: function(pod, state) { | |
| 3231 FINGERPRINT_STATES_MAPPING.forEach(function(item) { | |
| 3232 pod.passwordElement.classList.toggle(item.class, state == item.state); | |
| 3233 }); | |
| 3234 var placeholderStr = loadTimeData.getString( | |
| 3235 pod.isPinShown() ? 'pinKeyboardPlaceholderPinPassword' : | |
| 3236 'passwordHint'); | |
| 3237 if (state == FINGERPRINT_STATES.SIGNIN) { | |
| 3238 placeholderStr = loadTimeData.getString('fingerprintSigningin'); | |
| 3239 } else if (state == FINGERPRINT_STATES.FAILED) { | |
| 3240 placeholderStr = loadTimeData.getString('fingerprintSigninFailed'); | |
| 3241 } | |
| 3242 pod.passwordElement.placeholder = placeholderStr; | |
| 3243 }, | |
| 3244 | |
| 3245 /** | |
| 3043 * Sets the authentication type used to authenticate the user. | 3246 * Sets the authentication type used to authenticate the user. |
| 3044 * @param {string} username Username of selected user | 3247 * @param {string} username Username of selected user |
| 3045 * @param {number} authType Authentication type, must be one of the | 3248 * @param {number} authType Authentication type, must be one of the |
| 3046 * values listed in AUTH_TYPE enum. | 3249 * values listed in AUTH_TYPE enum. |
| 3047 * @param {string} value The initial value to use for authentication. | 3250 * @param {string} value The initial value to use for authentication. |
| 3048 */ | 3251 */ |
| 3049 setAuthType: function(username, authType, value) { | 3252 setAuthType: function(username, authType, value) { |
| 3050 var pod = this.getPodWithUsername_(username); | 3253 var pod = this.getPodWithUsername_(username); |
| 3051 if (pod == null) { | 3254 if (pod == null) { |
| 3052 console.error('Unable to set auth type: user pod not found.'); | 3255 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; | 3504 this.insideFocusPod_ = true; |
| 3302 | 3505 |
| 3303 for (var i = 0, pod; pod = this.pods[i]; ++i) { | 3506 for (var i = 0, pod; pod = this.pods[i]; ++i) { |
| 3304 if (!this.alwaysFocusSinglePod) { | 3507 if (!this.alwaysFocusSinglePod) { |
| 3305 pod.isActionBoxMenuActive = false; | 3508 pod.isActionBoxMenuActive = false; |
| 3306 } | 3509 } |
| 3307 if (pod != podToFocus) { | 3510 if (pod != podToFocus) { |
| 3308 pod.isActionBoxMenuHovered = false; | 3511 pod.isActionBoxMenuHovered = false; |
| 3309 pod.classList.remove('focused'); | 3512 pod.classList.remove('focused'); |
| 3310 pod.setPinVisibility(false); | 3513 pod.setPinVisibility(false); |
| 3514 this.setUserPodFingerprintIcon( | |
| 3515 pod.user.username, FINGERPRINT_STATES.HIDDEN); | |
| 3311 // On Desktop, the faded style is not set correctly, so we should | 3516 // 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. | 3517 // manually fade out non-focused pods if there is a focused pod. |
| 3313 if (pod.user.isDesktopUser && podToFocus) | 3518 if (pod.user.isDesktopUser && podToFocus) |
| 3314 pod.classList.add('faded'); | 3519 pod.classList.add('faded'); |
| 3315 else | 3520 else |
| 3316 pod.classList.remove('faded'); | 3521 pod.classList.remove('faded'); |
| 3317 pod.reset(false); | 3522 pod.reset(false); |
| 3318 } | 3523 } |
| 3319 } | 3524 } |
| 3320 | 3525 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 3340 // is false, it doesn't focus on the password input box by default. | 3545 // is false, it doesn't focus on the password input box by default. |
| 3341 podToFocus.focus(); | 3546 podToFocus.focus(); |
| 3342 } | 3547 } |
| 3343 | 3548 |
| 3344 // focusPod() automatically loads wallpaper | 3549 // focusPod() automatically loads wallpaper |
| 3345 if (!podToFocus.user.isApp) | 3550 if (!podToFocus.user.isApp) |
| 3346 chrome.send('focusPod', [podToFocus.user.username]); | 3551 chrome.send('focusPod', [podToFocus.user.username]); |
| 3347 this.firstShown_ = false; | 3552 this.firstShown_ = false; |
| 3348 this.lastFocusedPod_ = podToFocus; | 3553 this.lastFocusedPod_ = podToFocus; |
| 3349 this.scrollFocusedPodIntoView(); | 3554 this.scrollFocusedPodIntoView(); |
| 3555 this.setUserPodFingerprintIcon( | |
| 3556 podToFocus.user.username, FINGERPRINT_STATES.DEFAULT); | |
| 3350 } else { | 3557 } else { |
| 3351 chrome.send('noPodFocused'); | 3558 chrome.send('noPodFocused'); |
| 3352 } | 3559 } |
| 3353 this.insideFocusPod_ = false; | 3560 this.insideFocusPod_ = false; |
| 3354 }, | 3561 }, |
| 3355 | 3562 |
| 3356 /** | 3563 /** |
| 3357 * Resets wallpaper to the last active user's wallpaper, if any. | 3564 * Resets wallpaper to the last active user's wallpaper, if any. |
| 3358 */ | 3565 */ |
| 3359 loadLastWallpaper: function() { | 3566 loadLastWallpaper: function() { |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3731 if (pod && pod.multiProfilesPolicyApplied) { | 3938 if (pod && pod.multiProfilesPolicyApplied) { |
| 3732 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3939 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3733 } | 3940 } |
| 3734 } | 3941 } |
| 3735 }; | 3942 }; |
| 3736 | 3943 |
| 3737 return { | 3944 return { |
| 3738 PodRow: PodRow | 3945 PodRow: PodRow |
| 3739 }; | 3946 }; |
| 3740 }); | 3947 }); |
| OLD | NEW |