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

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

Issue 2733953008: Add fingerprint UI in user pod (Closed)
Patch Set: consolidate strings Created 3 years, 9 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 DEFAULT: 0,
135 FINGERPRINT_SIGNIN: 1,
136 FINGERPRINT_FAILED: 2,
137 };
138
139 /**
140 * The fingerprint states to classes mapping.
141 * {@code state} properties indicate current fingerprint unlock state.
142 * {@code class} properties are CSS classes used to set the icons' background
143 * and password placeholder color.
144 * @const {Array<{type: !number, class: !string}>}
145 */
146 var FINGERPRINT_STATES_MAPPING = [
147 {state: 0, class: 'default'},
jdufault 2017/03/08 23:21:28 fingerprintDefault? Or remove fingerprint prefix f
xiaoyinh(OOO Sep 11-29) 2017/03/09 20:59:12 Done.
148 {state: 1, class: 'fingerprintSignin'},
149 {state: 2, class: 'fingerprintFailed'}
150 ];
151
128 // Focus and tab order are organized as follows: 152 // Focus and tab order are organized as follows:
129 // 153 //
130 // (1) all user pods have tab index 1 so they are traversed first; 154 // (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 155 // (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; 156 // 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 157 // (3) if user pod custom icon is interactive, it has tab index 2 so it
134 // follows the input. 158 // follows the input.
135 // (4) buttons on the header bar have tab index 3 so they follow the custom 159 // (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; 160 // icon, or user pod if custom icon is not interactive;
137 // (5) Action box buttons have tab index 4 and follow header bar buttons; 161 // (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
704 728
705 /** 729 /**
706 * Whether click on the pod can issue a user click auth attempt. The 730 * 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 731 * attempt can be issued iff the pod was focused when the click
708 * started (i.e. on mouse down event). 732 * started (i.e. on mouse down event).
709 * @type {boolean} 733 * @type {boolean}
710 * @private 734 * @private
711 */ 735 */
712 userClickAuthAllowed_: false, 736 userClickAuthAllowed_: false,
713 737
738 /**
739 * Whether the user has recently authencated with fingerprint.
jdufault 2017/03/08 23:21:27 nit: authencated -> authenticated
xiaoyinh(OOO Sep 11-29) 2017/03/09 20:59:12 Done.
740 * @type {boolean}
741 * @private
742 */
743 fingerprintAuthenticated_: false,
744
714 /** @override */ 745 /** @override */
715 decorate: function() { 746 decorate: function() {
716 this.tabIndex = UserPodTabOrder.POD_INPUT; 747 this.tabIndex = UserPodTabOrder.POD_INPUT;
717 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT; 748 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT;
718 749
719 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this)); 750 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this));
720 this.addEventListener('click', this.handleClickOnPod_.bind(this)); 751 this.addEventListener('click', this.handleClickOnPod_.bind(this));
721 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this)); 752 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this));
722 753
723 if (this.pinKeyboard) { 754 if (this.pinKeyboard) {
(...skipping 19 matching lines...) Expand all
743 this.handleRemoveCommandClick_.bind(this)); 774 this.handleRemoveCommandClick_.bind(this));
744 this.actionBoxMenuRemoveElement.addEventListener('keydown', 775 this.actionBoxMenuRemoveElement.addEventListener('keydown',
745 this.handleRemoveCommandKeyDown_.bind(this)); 776 this.handleRemoveCommandKeyDown_.bind(this));
746 this.actionBoxMenuRemoveElement.addEventListener('blur', 777 this.actionBoxMenuRemoveElement.addEventListener('blur',
747 this.handleRemoveCommandBlur_.bind(this)); 778 this.handleRemoveCommandBlur_.bind(this));
748 this.actionBoxRemoveUserWarningButtonElement.addEventListener('click', 779 this.actionBoxRemoveUserWarningButtonElement.addEventListener('click',
749 this.handleRemoveUserConfirmationClick_.bind(this)); 780 this.handleRemoveUserConfirmationClick_.bind(this));
750 this.actionBoxRemoveUserWarningButtonElement.addEventListener('keydown', 781 this.actionBoxRemoveUserWarningButtonElement.addEventListener('keydown',
751 this.handleRemoveUserConfirmationKeyDown_.bind(this)); 782 this.handleRemoveUserConfirmationKeyDown_.bind(this));
752 783
784 if (this.fingerprintIconElement) {
785 this.fingerprintIconElement.addEventListener(
786 'mouseover', this.handleFingerprintIconMouseOver_.bind(this));
787 this.fingerprintIconElement.addEventListener(
788 'mouseout', this.handleFingerprintIconMouseOut_.bind(this));
789 this.fingerprintIconElement.addEventListener(
790 'mousedown', stopEventPropagation);
791 this.fingerprintIconElement.tabIndex = UserPodTabOrder.POD_CUSTOM_ICON;
jdufault 2017/03/08 23:21:27 Does tabbing work properly when easy unlock and PI
xiaoyinh(OOO Sep 11-29) 2017/03/09 20:59:12 easy unlock seems to set the tabIndex only when th
792 }
793
753 var customIcon = this.customIconElement; 794 var customIcon = this.customIconElement;
754 customIcon.parentNode.replaceChild(new UserPodCustomIcon(), customIcon); 795 customIcon.parentNode.replaceChild(new UserPodCustomIcon(), customIcon);
755 }, 796 },
756 797
757 /** 798 /**
758 * Initializes the pod after its properties set and added to a pod row. 799 * Initializes the pod after its properties set and added to a pod row.
759 */ 800 */
760 initialize: function() { 801 initialize: function() {
761 this.passwordElement.addEventListener('keydown', 802 this.passwordElement.addEventListener('keydown',
762 this.parentNode.handleKeyDown.bind(this.parentNode)); 803 this.parentNode.handleKeyDown.bind(this.parentNode));
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 'Passwords': 1130 'Passwords':
1090 this.querySelector('.action-box-remove-user-warning-passwords'), 1131 this.querySelector('.action-box-remove-user-warning-passwords'),
1091 'Bookmarks': 1132 'Bookmarks':
1092 this.querySelector('.action-box-remove-user-warning-bookmarks'), 1133 this.querySelector('.action-box-remove-user-warning-bookmarks'),
1093 'Settings': 1134 'Settings':
1094 this.querySelector('.action-box-remove-user-warning-settings') 1135 this.querySelector('.action-box-remove-user-warning-settings')
1095 } 1136 }
1096 }, 1137 },
1097 1138
1098 /** 1139 /**
1140 * Gets the fingerprint icon area.
1141 * @type {!HTMLDivElement}
1142 */
1143 get fingerprintIconElement() {
1144 return this.querySelector('.fingerprint-icon-container');
1145 },
1146
1147 /**
1099 * Updates the user pod element. 1148 * Updates the user pod element.
1100 */ 1149 */
1101 update: function() { 1150 update: function() {
1102 this.imageElement.src = 'chrome://userimage/' + this.user.username + 1151 this.imageElement.src = 'chrome://userimage/' + this.user.username +
1103 '?id=' + UserPod.userImageSalt_[this.user.username]; 1152 '?id=' + UserPod.userImageSalt_[this.user.username];
1104 1153
1105 this.nameElement.textContent = this.user_.displayName; 1154 this.nameElement.textContent = this.user_.displayName;
1106 this.reauthNameHintElement.textContent = this.user_.displayName; 1155 this.reauthNameHintElement.textContent = this.user_.displayName;
1107 this.classList.toggle('signed-in', this.user_.signedIn); 1156 this.classList.toggle('signed-in', this.user_.signedIn);
1108 1157
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 1258
1210 isPinShown: function() { 1259 isPinShown: function() {
1211 return this.classList.contains('pin-enabled'); 1260 return this.classList.contains('pin-enabled');
1212 }, 1261 },
1213 1262
1214 setUserPodIconType: function(userTypeClass) { 1263 setUserPodIconType: function(userTypeClass) {
1215 this.userTypeIconAreaElement.classList.add(userTypeClass); 1264 this.userTypeIconAreaElement.classList.add(userTypeClass);
1216 this.userTypeIconAreaElement.hidden = false; 1265 this.userTypeIconAreaElement.hidden = false;
1217 }, 1266 },
1218 1267
1268 isFingerprintIconShown: function() {
1269 return this.fingerprintIconElement && !this.fingerprintIconElement.hidden;
1270 },
1271
1219 /** 1272 /**
1220 * The user that this pod represents. 1273 * The user that this pod represents.
1221 * @type {!Object} 1274 * @type {!Object}
1222 */ 1275 */
1223 user_: undefined, 1276 user_: undefined,
1224 get user() { 1277 get user() {
1225 return this.user_; 1278 return this.user_;
1226 }, 1279 },
1227 set user(userDict) { 1280 set user(userDict) {
1228 this.user_ = userDict; 1281 this.user_ = userDict;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 * @return {boolean} True if activated successfully. 1458 * @return {boolean} True if activated successfully.
1406 */ 1459 */
1407 activate: function(e) { 1460 activate: function(e) {
1408 if (this.isAuthTypeOnlineSignIn) { 1461 if (this.isAuthTypeOnlineSignIn) {
1409 this.showSigninUI(); 1462 this.showSigninUI();
1410 } else if (this.isAuthTypeUserClick) { 1463 } else if (this.isAuthTypeUserClick) {
1411 Oobe.disableSigninUI(); 1464 Oobe.disableSigninUI();
1412 this.classList.toggle('signing-in', true); 1465 this.classList.toggle('signing-in', true);
1413 chrome.send('attemptUnlock', [this.user.username]); 1466 chrome.send('attemptUnlock', [this.user.username]);
1414 } else if (this.isAuthTypePassword) { 1467 } else if (this.isAuthTypePassword) {
1468 if (this.fingerprintAuthenticated_) {
1469 this.fingerprintAuthenticated_ = false;
1470 return true;
1471 }
1415 var pinValue = this.pinKeyboard ? this.pinKeyboard.value : ''; 1472 var pinValue = this.pinKeyboard ? this.pinKeyboard.value : '';
1416 var password = this.passwordElement.value || pinValue; 1473 var password = this.passwordElement.value || pinValue;
1417 if (!password) 1474 if (!password)
1418 return false; 1475 return false;
1419 Oobe.disableSigninUI(); 1476 Oobe.disableSigninUI();
1420 chrome.send('authenticateUser', [this.user.username, password, 1477 chrome.send('authenticateUser', [this.user.username, password,
1421 this.isPinShown()]); 1478 this.isPinShown()]);
1422 } else { 1479 } else {
1423 console.error('Activating user pod with invalid authentication type: ' + 1480 console.error('Activating user pod with invalid authentication type: ' +
1424 this.authType); 1481 this.authType);
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 */ 1872 */
1816 handleRemoveUserConfirmationClick_: function(e) { 1873 handleRemoveUserConfirmationClick_: function(e) {
1817 if (this.isActionBoxMenuActive) { 1874 if (this.isActionBoxMenuActive) {
1818 this.isActionBoxMenuActive = false; 1875 this.isActionBoxMenuActive = false;
1819 this.removeUser(this.user); 1876 this.removeUser(this.user);
1820 e.stopPropagation(); 1877 e.stopPropagation();
1821 } 1878 }
1822 }, 1879 },
1823 1880
1824 /** 1881 /**
1882 * Handles mouseover event on fingerprint icon.
1883 * @param {Event} e MouseOver event.
1884 */
1885 handleFingerprintIconMouseOver_: function(e) {
1886 var bubbleContent = document.createElement('div');
1887 bubbleContent.textContent =
1888 loadTimeData.getString('fingerprintIconMessage');
1889 this.passwordElement.placeholder =
1890 loadTimeData.getString('fingerprintHint');
1891
1892 /** @const */ var BUBBLE_OFFSET = 25;
1893 /** @const */ var BUBBLE_PADDING = -8;
1894 var attachment = this.isPinShown() ? cr.ui.Bubble.Attachment.RIGHT :
1895 cr.ui.Bubble.Attachment.BOTTOM;
1896 var bubbleAnchor = this;
1897 if (this.isPinShown())
1898 bubbleAnchor = (this.getElementsByClassName('auth-container'))[0];
1899 $('bubble').showContentForElement(
1900 bubbleAnchor, attachment, bubbleContent, BUBBLE_OFFSET,
1901 BUBBLE_PADDING, true);
1902 },
1903
1904 /**
1905 * Handles mouseout event on fingerprint icon.
1906 * @param {Event} e MouseOut event.
1907 */
1908 handleFingerprintIconMouseOut_: function(e) {
1909 if(this.isPinShown()) {
1910 $('bubble').hideForElement(
1911 (this.getElementsByClassName('auth-container'))[0]);
1912 } else {
1913 $('bubble').hideForElement(this);
1914 }
1915 this.passwordElement.placeholder = loadTimeData.getString(
1916 this.isPinShown() ? 'pinKeyboardPlaceholderPinPassword' :
1917 'passwordHint');
1918 },
1919
1920 /**
1825 * Handles a keydown event on remove user confirmation button. 1921 * Handles a keydown event on remove user confirmation button.
1826 * @param {Event} e KeyDown event. 1922 * @param {Event} e KeyDown event.
1827 */ 1923 */
1828 handleRemoveUserConfirmationKeyDown_: function(e) { 1924 handleRemoveUserConfirmationKeyDown_: function(e) {
1829 if (!this.isActionBoxMenuActive) 1925 if (!this.isActionBoxMenuActive)
1830 return; 1926 return;
1831 1927
1832 // Only handle pressing 'Enter' or 'Space', and let all other events 1928 // Only handle pressing 'Enter' or 'Space', and let all other events
1833 // bubble to the action box menu. 1929 // bubble to the action box menu.
1834 if (e.key == 'Enter' || e.key == ' ') { 1930 if (e.key == 'Enter' || e.key == ' ') {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 */ 1988 */
1893 handlePodMouseDown_: function(e) { 1989 handlePodMouseDown_: function(e) {
1894 this.userClickAuthAllowed_ = this.parentNode.isFocused(this); 1990 this.userClickAuthAllowed_ = this.parentNode.isFocused(this);
1895 }, 1991 },
1896 1992
1897 /** 1993 /**
1898 * Called when the input of the password element changes. Updates the submit 1994 * Called when the input of the password element changes. Updates the submit
1899 * button color and state and hides the error popup bubble. 1995 * button color and state and hides the error popup bubble.
1900 */ 1996 */
1901 updateInput_: function() { 1997 updateInput_: function() {
1902 if (this.submitButton) 1998 if (this.submitButton) {
1903 this.submitButton.disabled = this.passwordElement.value.length <= 0; 1999 this.submitButton.disabled = this.passwordElement.value.length <= 0;
jdufault 2017/03/08 23:21:27 Since you're here, can you change these <= to just
xiaoyinh(OOO Sep 11-29) 2017/03/09 20:59:12 Done.
2000 if (this.isFingerprintIconShown()) {
2001 this.submitButton.hidden = this.passwordElement.value.length <= 0;
2002 } else {
2003 this.submitButton.hidden = false;
2004 }
2005 }
1904 this.showError = false; 2006 this.showError = false;
1905 $('bubble').hide(); 2007 $('bubble').hide();
1906 }, 2008 },
1907 2009
1908 /** 2010 /**
1909 * Handles input event on the password element. 2011 * Handles input event on the password element.
1910 * @param {Event} e Input event. 2012 * @param {Event} e Input event.
1911 */ 2013 */
1912 handleInputChanged_: function(e) { 2014 handleInputChanged_: function(e) {
1913 this.updateInput_(); 2015 this.updateInput_();
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
2994 pod.customIconElement.setAriaLabel(ariaLabel); 3096 pod.customIconElement.setAriaLabel(ariaLabel);
2995 else 3097 else
2996 console.warn('No ARIA label for user pod custom icon.'); 3098 console.warn('No ARIA label for user pod custom icon.');
2997 3099
2998 pod.customIconElement.show(); 3100 pod.customIconElement.show();
2999 3101
3000 // This has to be called after |show| in case the tooltip should be shown 3102 // This has to be called after |show| in case the tooltip should be shown
3001 // immediatelly. 3103 // immediatelly.
3002 pod.customIconElement.setTooltip( 3104 pod.customIconElement.setTooltip(
3003 icon.tooltip || {text: '', autoshow: false}); 3105 icon.tooltip || {text: '', autoshow: false});
3106
3107 // Hide fingerprint icon when custom icon is shown.
3108 this.setUserPodFingerprintIcon(false, username);
jdufault 2017/03/08 23:21:27 Looks like you're missing the third 'state' parame
jdufault 2017/03/08 23:21:28 Please annotate the false parameter, ie, false /*v
xiaoyinh(OOO Sep 11-29) 2017/03/09 20:59:12 Done.
xiaoyinh(OOO Sep 11-29) 2017/03/09 20:59:12 I've consolidate 'visible' with 'state'.
3004 }, 3109 },
3005 3110
3006 /** 3111 /**
3007 * Hard-locks user pod for the user. If user pod is hard-locked, it can be 3112 * 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 3113 * only unlocked using password, and the authentication type cannot be
3009 * changed. 3114 * changed.
3010 * @param {!string} username The user's username. 3115 * @param {!string} username The user's username.
3011 * @private 3116 * @private
3012 */ 3117 */
3013 hardlockUserPod_: function(username) { 3118 hardlockUserPod_: function(username) {
(...skipping 16 matching lines...) Expand all
3030 */ 3135 */
3031 hideUserPodCustomIcon: function(username) { 3136 hideUserPodCustomIcon: function(username) {
3032 var pod = this.getPodWithUsername_(username); 3137 var pod = this.getPodWithUsername_(username);
3033 if (pod == null) { 3138 if (pod == null) {
3034 console.error('Unable to hide user pod button: user pod not found.'); 3139 console.error('Unable to hide user pod button: user pod not found.');
3035 return; 3140 return;
3036 } 3141 }
3037 3142
3038 // TODO(tengs): Allow option for a fading transition. 3143 // TODO(tengs): Allow option for a fading transition.
3039 pod.customIconElement.hide(); 3144 pod.customIconElement.hide();
3145
3146 // Show fingerprint icon if applicable.
3147 this.setUserPodFingerprintIcon(
3148 true, username, FINGERPRINT_STATES.DEFAULT);
jdufault 2017/03/08 23:21:27 Please annotate true parameter, ie, true /*visible
xiaoyinh(OOO Sep 11-29) 2017/03/09 20:59:12 Done.
3040 }, 3149 },
3041 3150
3042 /** 3151 /**
3152 * Set a fingerprint icon in the user pod of |username|.
3153 * @param {boolean} visible Set visiblity of the fingerprint icon
3154 * @param {string} username Username of the selected user
3155 * @param {number} state Fingerprint unlock state
3156 */
3157 setUserPodFingerprintIcon: function(visible, username, state) {
jdufault 2017/03/08 23:21:27 Instead of having |visible| and |state| be separat
xiaoyinh(OOO Sep 11-29) 2017/03/09 20:59:12 Thanks. I added a hidden class to map with hidden
3158 var pod = this.getPodWithUsername_(username);
3159 if (pod == null) {
3160 console.error(
3161 'Unable to set user pod fingerprint icon: user pod not found.');
3162 return;
3163 }
3164 pod.fingerprintAuthenticated_ = false;
3165 if (!pod.fingerprintIconElement)
3166 return;
3167 if (!pod.user.allowFingerprint || !visible ||
3168 !pod.customIconElement.hidden) {
3169 pod.fingerprintIconElement.hidden = true;
3170 pod.submitButton.hidden = false;
3171 return;
3172 }
3173
3174 FINGERPRINT_STATES_MAPPING.forEach(function(icon) {
3175 pod.fingerprintIconElement.classList.toggle(
3176 icon.class, state == icon.state);
3177 });
3178 pod.fingerprintIconElement.setAttribute(
3179 'aria-label', loadTimeData.getString('fingerprintIconMessage'));
3180 pod.fingerprintIconElement.hidden = false;
3181 pod.submitButton.hidden = pod.passwordElement.value.length <= 0;
3182 this.updatePasswordField_(pod, state);
3183 if (state == FINGERPRINT_STATES.DEFAULT)
3184 return;
3185
3186 pod.fingerprintAuthenticated_ = true;
3187 this.setActivatedPod(pod);
3188 if (state == FINGERPRINT_STATES.FINGERPRINT_FAILED) {
3189 /** @const */ var RESET_ICON_TIMEOUT_MS = 500;
3190 setTimeout(
3191 this.resetIconAndPasswordField_.bind(this, pod),
3192 RESET_ICON_TIMEOUT_MS);
3193 }
3194 },
3195
3196 /**
3197 * Reset the fingerprint icon and password field.
3198 * @param {UserPod} pod Pod to reset.
3199 */
3200 resetIconAndPasswordField_:function(pod) {
3201 if (!pod.fingerprintIconElement)
3202 return;
3203 this.setUserPodFingerprintIcon(
3204 true, pod.user.username, FINGERPRINT_STATES.DEFAULT);
3205 },
3206
3207 /**
3208 * Remove the fingerprint icon in the user pod.
3209 * @param {string} username Username of the selected user
3210 */
3211 removeUserPodFingerprintIcon: function(username) {
3212 var pod = this.getPodWithUsername_(username);
3213 if (pod == null) {
3214 console.error(
3215 'Unable to remove user pod fingerprint icon: user pod not found.');
3216 return;
3217 }
3218 this.resetIconAndPasswordField_(pod);
3219 if (pod.fingerprintIconElement)
jdufault 2017/03/08 23:21:27 nit: {}
xiaoyinh(OOO Sep 11-29) 2017/03/09 20:59:11 Done.
3220 pod.fingerprintIconElement.parentNode.removeChild(
3221 pod.fingerprintIconElement);
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.FINGERPRINT_SIGNIN) {
jdufault 2017/03/08 23:21:27 There are only two ifs here so it is probably not
xiaoyinh(OOO Sep 11-29) 2017/03/09 20:59:12 Thanks for the suggestion. I will create the mappi
jdufault 2017/03/09 21:11:25 Yep, as-is is good - with only two elements it's n
3238 placeholderStr = loadTimeData.getString('fingerprintSigningin');
3239 } else if (state == FINGERPRINT_STATES.FINGERPRINT_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
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(false, pod.user.username);
jdufault 2017/03/08 23:21:27 Annotate false parameter
xiaoyinh(OOO Sep 11-29) 2017/03/09 20:59:12 Done.
3311 // On Desktop, the faded style is not set correctly, so we should 3515 // 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. 3516 // manually fade out non-focused pods if there is a focused pod.
3313 if (pod.user.isDesktopUser && podToFocus) 3517 if (pod.user.isDesktopUser && podToFocus)
3314 pod.classList.add('faded'); 3518 pod.classList.add('faded');
3315 else 3519 else
3316 pod.classList.remove('faded'); 3520 pod.classList.remove('faded');
3317 pod.reset(false); 3521 pod.reset(false);
3318 } 3522 }
3319 } 3523 }
3320 3524
(...skipping 19 matching lines...) Expand all
3340 // is false, it doesn't focus on the password input box by default. 3544 // is false, it doesn't focus on the password input box by default.
3341 podToFocus.focus(); 3545 podToFocus.focus();
3342 } 3546 }
3343 3547
3344 // focusPod() automatically loads wallpaper 3548 // focusPod() automatically loads wallpaper
3345 if (!podToFocus.user.isApp) 3549 if (!podToFocus.user.isApp)
3346 chrome.send('focusPod', [podToFocus.user.username]); 3550 chrome.send('focusPod', [podToFocus.user.username]);
3347 this.firstShown_ = false; 3551 this.firstShown_ = false;
3348 this.lastFocusedPod_ = podToFocus; 3552 this.lastFocusedPod_ = podToFocus;
3349 this.scrollFocusedPodIntoView(); 3553 this.scrollFocusedPodIntoView();
3554 this.setUserPodFingerprintIcon(
3555 true, podToFocus.user.username, FINGERPRINT_STATES.DEFAULT);
jdufault 2017/03/08 23:21:27 Annotate true parameter
xiaoyinh(OOO Sep 11-29) 2017/03/09 20:59:12 Done.
3350 } else { 3556 } else {
3351 chrome.send('noPodFocused'); 3557 chrome.send('noPodFocused');
3352 } 3558 }
3353 this.insideFocusPod_ = false; 3559 this.insideFocusPod_ = false;
3354 }, 3560 },
3355 3561
3356 /** 3562 /**
3357 * Resets wallpaper to the last active user's wallpaper, if any. 3563 * Resets wallpaper to the last active user's wallpaper, if any.
3358 */ 3564 */
3359 loadLastWallpaper: function() { 3565 loadLastWallpaper: function() {
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
3731 if (pod && pod.multiProfilesPolicyApplied) { 3937 if (pod && pod.multiProfilesPolicyApplied) {
3732 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3938 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3733 } 3939 }
3734 } 3940 }
3735 }; 3941 };
3736 3942
3737 return { 3943 return {
3738 PodRow: PodRow 3944 PodRow: PodRow
3739 }; 3945 };
3740 }); 3946 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698