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

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

Issue 2027683003: Pin keyboard moved to under the user profile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fixed patch set 3 errors. Created 4 years, 6 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 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 this.handleRemoveCommandClick_.bind(this)); 728 this.handleRemoveCommandClick_.bind(this));
729 this.actionBoxMenuRemoveElement.addEventListener('keydown', 729 this.actionBoxMenuRemoveElement.addEventListener('keydown',
730 this.handleRemoveCommandKeyDown_.bind(this)); 730 this.handleRemoveCommandKeyDown_.bind(this));
731 this.actionBoxMenuRemoveElement.addEventListener('blur', 731 this.actionBoxMenuRemoveElement.addEventListener('blur',
732 this.handleRemoveCommandBlur_.bind(this)); 732 this.handleRemoveCommandBlur_.bind(this));
733 this.actionBoxRemoveUserWarningButtonElement.addEventListener('click', 733 this.actionBoxRemoveUserWarningButtonElement.addEventListener('click',
734 this.handleRemoveUserConfirmationClick_.bind(this)); 734 this.handleRemoveUserConfirmationClick_.bind(this));
735 this.actionBoxRemoveUserWarningButtonElement.addEventListener('keydown', 735 this.actionBoxRemoveUserWarningButtonElement.addEventListener('keydown',
736 this.handleRemoveUserConfirmationKeyDown_.bind(this)); 736 this.handleRemoveUserConfirmationKeyDown_.bind(this));
737 737
738 var pinKeyboard = $('pin-keyboard');
739 // The pin keyboard is not present on the md user manager.
740 if (pinKeyboard) {
741 pinKeyboard.addEventListener('submit',
742 this.handlePinSubmitted_.bind(this));
743 }
744
745 var customIcon = this.customIconElement; 738 var customIcon = this.customIconElement;
746 customIcon.parentNode.replaceChild(new UserPodCustomIcon(), customIcon); 739 customIcon.parentNode.replaceChild(new UserPodCustomIcon(), customIcon);
747 }, 740 },
748 741
749 /** 742 /**
750 * 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.
751 */ 744 */
752 initialize: function() { 745 initialize: function() {
753 this.passwordElement.addEventListener('keydown', 746 this.passwordElement.addEventListener('keydown',
754 this.parentNode.handleKeyDown.bind(this.parentNode)); 747 this.parentNode.handleKeyDown.bind(this.parentNode));
755 this.passwordElement.addEventListener('keypress', 748 this.passwordElement.addEventListener('keypress',
756 this.handlePasswordKeyPress_.bind(this)); 749 this.handlePasswordKeyPress_.bind(this));
757 750
751 if (this.pinKeyboard) {
752 this.pinKeyboard.addEventListener('submit',
753 this.handlePinSubmitted_.bind(this));
754 }
755
758 this.imageElement.addEventListener('load', 756 this.imageElement.addEventListener('load',
759 this.parentNode.handlePodImageLoad.bind(this.parentNode, this)); 757 this.parentNode.handlePodImageLoad.bind(this.parentNode, this));
760 758
761 var initialAuthType = this.user.initialAuthType || 759 var initialAuthType = this.user.initialAuthType ||
762 AUTH_TYPE.OFFLINE_PASSWORD; 760 AUTH_TYPE.OFFLINE_PASSWORD;
763 this.setAuthType(initialAuthType, null); 761 this.setAuthType(initialAuthType, null);
764 762
765 this.userClickAuthAllowed_ = false; 763 this.userClickAuthAllowed_ = false;
766 }, 764 },
767 765
768 /** 766 /**
769 * Resets tab order for pod elements to its initial state. 767 * Resets tab order for pod elements to its initial state.
770 */ 768 */
771 resetTabOrder: function() { 769 resetTabOrder: function() {
772 // Note: the |mainInput| can be the pod itself. 770 // Note: the |mainInput| can be the pod itself.
773 this.mainInput.tabIndex = -1; 771 this.mainInput.tabIndex = -1;
774 this.tabIndex = UserPodTabOrder.POD_INPUT; 772 this.tabIndex = UserPodTabOrder.POD_INPUT;
775 }, 773 },
776 774
777 /** 775 /**
778 * Handles the user hitting 'submit' on the PIN keyboard. 776 * Handles the user hitting 'submit' on the PIN keyboard.
779 * @param {Event} e Submit event object. 777 * @param {Event} e Submit event object.
780 * @private 778 * @private
781 */ 779 */
782 handlePinSubmitted_: function(e) { 780 handlePinSubmitted_: function(e) {
783 var pin = e.detail.pin; 781 var pin = e.detail.pin;
784 chrome.send('authenticateUser', [this.user.username, pin]); 782 chrome.send('authenticateUserWithPin', [this.user.username, pin]);
jdufault 2016/06/17 18:54:23 Undo this change
sammiequon 2016/06/22 23:26:17 Done.
785 }, 783 },
786 784
787 /** 785 /**
788 * Handles keypress event (i.e. any textual input) on password input. 786 * Handles keypress event (i.e. any textual input) on password input.
789 * @param {Event} e Keypress Event object. 787 * @param {Event} e Keypress Event object.
790 * @private 788 * @private
791 */ 789 */
792 handlePasswordKeyPress_: function(e) { 790 handlePasswordKeyPress_: function(e) {
793 // When tabbing from the system tray a tab key press is received. Suppress 791 // When tabbing from the system tray a tab key press is received. Suppress
794 // this so as not to type a tab character into the password field. 792 // this so as not to type a tab character into the password field.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 }, 828 },
831 829
832 /** 830 /**
833 * Height number of pixels. 831 * Height number of pixels.
834 */ 832 */
835 get height() { 833 get height() {
836 return this.offsetHeight; 834 return this.offsetHeight;
837 }, 835 },
838 836
839 /** 837 /**
838 * Gets the authorization element of the pod.
839 * @type {!HTMLDivElement}
jdufault 2016/06/17 18:54:23 I think it makes sense to define the setPinVisible
sammiequon 2016/06/22 23:26:17 Done.
840 */
841 get authElement() {
842 return this.querySelector('.auth-container');
843 },
844
845 /**
840 * Gets image element. 846 * Gets image element.
841 * @type {!HTMLImageElement} 847 * @type {!HTMLImageElement}
842 */ 848 */
843 get imageElement() { 849 get imageElement() {
844 return this.querySelector('.user-image'); 850 return this.querySelector('.user-image');
845 }, 851 },
846 852
847 /** 853 /**
848 * Gets name element. 854 * Gets name element.
849 * @type {!HTMLDivElement} 855 * @type {!HTMLDivElement}
(...skipping 29 matching lines...) Expand all
879 /** 885 /**
880 * Gets the password label, which is used to show a message where the 886 * Gets the password label, which is used to show a message where the
881 * password field is normally. 887 * password field is normally.
882 * @type {!HTMLInputElement} 888 * @type {!HTMLInputElement}
883 */ 889 */
884 get passwordLabelElement() { 890 get passwordLabelElement() {
885 return this.querySelector('.password-label'); 891 return this.querySelector('.password-label');
886 }, 892 },
887 893
888 /** 894 /**
895 * Gets the pin-container of the pod.
896 * @type {!HTMLDivElement}
897 */
898 get pinContainer() {
899 return this.querySelector('#pin-container');
900 },
901
902 /**
903 * Gets the pin-keyboard of the pod.
904 * @type {!HTMLElement}
905 */
906 get pinKeyboard() {
907 return this.querySelector('#pin-keyboard');
908 },
909
910 /**
889 * Gets user online sign in hint element. 911 * Gets user online sign in hint element.
890 * @type {!HTMLDivElement} 912 * @type {!HTMLDivElement}
891 */ 913 */
892 get reauthWarningElement() { 914 get reauthWarningElement() {
893 return this.querySelector('.reauth-hint-container'); 915 return this.querySelector('.reauth-hint-container');
894 }, 916 },
895 917
896 /** 918 /**
919 * Gets the signed in indicator of the pod.
920 * @type {!HTMLDivElement}
921 */
922 get signInElement() {
923 return this.querySelector('.signed-in-indicator');
924 },
925
926 /**
897 * Gets the container holding the launch app button. 927 * Gets the container holding the launch app button.
898 * @type {!HTMLButtonElement} 928 * @type {!HTMLButtonElement}
899 */ 929 */
900 get launchAppButtonContainerElement() { 930 get launchAppButtonContainerElement() {
901 return this.querySelector('.launch-app-button-container'); 931 return this.querySelector('.launch-app-button-container');
902 }, 932 },
903 933
904 /** 934 /**
905 * Gets launch app button. 935 * Gets launch app button.
906 * @type {!HTMLButtonElement} 936 * @type {!HTMLButtonElement}
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 } 2480 }
2451 return null; 2481 return null;
2452 }, 2482 },
2453 2483
2454 /** 2484 /**
2455 * Returns pod with the given username (null if there is no such pod). 2485 * Returns pod with the given username (null if there is no such pod).
2456 * @param {string} username Username to be matched. 2486 * @param {string} username Username to be matched.
2457 * @return {Object} Pod with the given username. null if pod hasn't been 2487 * @return {Object} Pod with the given username. null if pod hasn't been
2458 * found. 2488 * found.
2459 */ 2489 */
2460 getPodWithUsername_: function(username) { 2490 getPodWithUsername: function(username) {
2461 for (var i = 0, pod; pod = this.pods[i]; ++i) { 2491 for (var i = 0, pod; pod = this.pods[i]; ++i) {
2462 if (pod.user.username == username) 2492 if (pod.user.username == username)
2463 return pod; 2493 return pod;
2464 } 2494 }
2465 return null; 2495 return null;
2466 }, 2496 },
2467 2497
2468 /** 2498 /**
2469 * True if the the pod row is disabled (handles no user interaction). 2499 * True if the the pod row is disabled (handles no user interaction).
2470 * @type {boolean} 2500 * @type {boolean}
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2525 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null); 2555 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null);
2526 app.dispatchEvent(activationEvent); 2556 app.dispatchEvent(activationEvent);
2527 } 2557 }
2528 }, 2558 },
2529 2559
2530 /** 2560 /**
2531 * Removes user pod from pod row. 2561 * Removes user pod from pod row.
2532 * @param {string} email User's email. 2562 * @param {string} email User's email.
2533 */ 2563 */
2534 removeUserPod: function(username) { 2564 removeUserPod: function(username) {
2535 var podToRemove = this.getPodWithUsername_(username); 2565 var podToRemove = this.getPodWithUsername(username);
2536 if (podToRemove == null) { 2566 if (podToRemove == null) {
2537 console.warn('Attempt to remove not existing pod for ' + username + 2567 console.warn('Attempt to remove not existing pod for ' + username +
2538 '.'); 2568 '.');
2539 return; 2569 return;
2540 } 2570 }
2541 this.removeChild(podToRemove); 2571 this.removeChild(podToRemove);
2542 if (this.pods.length > 0) 2572 if (this.pods.length > 0)
2543 this.placePods_(); 2573 this.placePods_();
2544 }, 2574 },
2545 2575
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
2685 * Shows a custom icon on a user pod besides the input field. 2715 * Shows a custom icon on a user pod besides the input field.
2686 * @param {string} username Username of pod to add button 2716 * @param {string} username Username of pod to add button
2687 * @param {!{id: !string, 2717 * @param {!{id: !string,
2688 * hardlockOnClick: boolean, 2718 * hardlockOnClick: boolean,
2689 * isTrialRun: boolean, 2719 * isTrialRun: boolean,
2690 * ariaLabel: string | undefined, 2720 * ariaLabel: string | undefined,
2691 * tooltip: ({text: string, autoshow: boolean} | undefined)}} icon 2721 * tooltip: ({text: string, autoshow: boolean} | undefined)}} icon
2692 * The icon parameters. 2722 * The icon parameters.
2693 */ 2723 */
2694 showUserPodCustomIcon: function(username, icon) { 2724 showUserPodCustomIcon: function(username, icon) {
2695 var pod = this.getPodWithUsername_(username); 2725 var pod = this.getPodWithUsername(username);
2696 if (pod == null) { 2726 if (pod == null) {
2697 console.error('Unable to show user pod button: user pod not found.'); 2727 console.error('Unable to show user pod button: user pod not found.');
2698 return; 2728 return;
2699 } 2729 }
2700 2730
2701 if (!icon.id && !icon.tooltip) 2731 if (!icon.id && !icon.tooltip)
2702 return; 2732 return;
2703 2733
2704 if (icon.id) 2734 if (icon.id)
2705 pod.customIconElement.setIcon(icon.id); 2735 pod.customIconElement.setIcon(icon.id);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2747 */ 2777 */
2748 onDidClickLockIconDuringTrialRun_: function(username) { 2778 onDidClickLockIconDuringTrialRun_: function(username) {
2749 chrome.send('recordClickOnLockIcon', [username]); 2779 chrome.send('recordClickOnLockIcon', [username]);
2750 }, 2780 },
2751 2781
2752 /** 2782 /**
2753 * Hides the custom icon in the user pod added by showUserPodCustomIcon(). 2783 * Hides the custom icon in the user pod added by showUserPodCustomIcon().
2754 * @param {string} username Username of pod to remove button 2784 * @param {string} username Username of pod to remove button
2755 */ 2785 */
2756 hideUserPodCustomIcon: function(username) { 2786 hideUserPodCustomIcon: function(username) {
2757 var pod = this.getPodWithUsername_(username); 2787 var pod = this.getPodWithUsername(username);
2758 if (pod == null) { 2788 if (pod == null) {
2759 console.error('Unable to hide user pod button: user pod not found.'); 2789 console.error('Unable to hide user pod button: user pod not found.');
2760 return; 2790 return;
2761 } 2791 }
2762 2792
2763 // TODO(tengs): Allow option for a fading transition. 2793 // TODO(tengs): Allow option for a fading transition.
2764 pod.customIconElement.hide(); 2794 pod.customIconElement.hide();
2765 }, 2795 },
2766 2796
2767 /** 2797 /**
2768 * Sets the authentication type used to authenticate the user. 2798 * Sets the authentication type used to authenticate the user.
2769 * @param {string} username Username of selected user 2799 * @param {string} username Username of selected user
2770 * @param {number} authType Authentication type, must be one of the 2800 * @param {number} authType Authentication type, must be one of the
2771 * values listed in AUTH_TYPE enum. 2801 * values listed in AUTH_TYPE enum.
2772 * @param {string} value The initial value to use for authentication. 2802 * @param {string} value The initial value to use for authentication.
2773 */ 2803 */
2774 setAuthType: function(username, authType, value) { 2804 setAuthType: function(username, authType, value) {
2775 var pod = this.getPodWithUsername_(username); 2805 var pod = this.getPodWithUsername(username);
2776 if (pod == null) { 2806 if (pod == null) {
2777 console.error('Unable to set auth type: user pod not found.'); 2807 console.error('Unable to set auth type: user pod not found.');
2778 return; 2808 return;
2779 } 2809 }
2780 pod.setAuthType(authType, value); 2810 pod.setAuthType(authType, value);
2781 }, 2811 },
2782 2812
2783 /** 2813 /**
2784 * Sets the state of touch view mode. 2814 * Sets the state of touch view mode.
2785 * @param {boolean} isTouchViewEnabled true if the mode is on. 2815 * @param {boolean} isTouchViewEnabled true if the mode is on.
2786 */ 2816 */
2787 setTouchViewState: function(isTouchViewEnabled) { 2817 setTouchViewState: function(isTouchViewEnabled) {
2788 this.touchViewEnabled_ = isTouchViewEnabled; 2818 this.touchViewEnabled_ = isTouchViewEnabled;
2789 this.pods.forEach(function(pod, index) { 2819 this.pods.forEach(function(pod, index) {
2790 pod.actionBoxAreaElement.classList.toggle('forced', isTouchViewEnabled); 2820 pod.actionBoxAreaElement.classList.toggle('forced', isTouchViewEnabled);
2791 }); 2821 });
2792 }, 2822 },
2793 2823
2794 /** 2824 /**
2795 * Updates the display name shown on a public session pod. 2825 * Updates the display name shown on a public session pod.
2796 * @param {string} userID The user ID of the public session 2826 * @param {string} userID The user ID of the public session
2797 * @param {string} displayName The new display name 2827 * @param {string} displayName The new display name
2798 */ 2828 */
2799 setPublicSessionDisplayName: function(userID, displayName) { 2829 setPublicSessionDisplayName: function(userID, displayName) {
2800 var pod = this.getPodWithUsername_(userID); 2830 var pod = this.getPodWithUsername(userID);
2801 if (pod != null) 2831 if (pod != null)
2802 pod.setDisplayName(displayName); 2832 pod.setDisplayName(displayName);
2803 }, 2833 },
2804 2834
2805 /** 2835 /**
2806 * Updates the list of locales available for a public session. 2836 * Updates the list of locales available for a public session.
2807 * @param {string} userID The user ID of the public session 2837 * @param {string} userID The user ID of the public session
2808 * @param {!Object} locales The list of available locales 2838 * @param {!Object} locales The list of available locales
2809 * @param {string} defaultLocale The locale to select by default 2839 * @param {string} defaultLocale The locale to select by default
2810 * @param {boolean} multipleRecommendedLocales Whether |locales| contains 2840 * @param {boolean} multipleRecommendedLocales Whether |locales| contains
2811 * two or more recommended locales 2841 * two or more recommended locales
2812 */ 2842 */
2813 setPublicSessionLocales: function(userID, 2843 setPublicSessionLocales: function(userID,
2814 locales, 2844 locales,
2815 defaultLocale, 2845 defaultLocale,
2816 multipleRecommendedLocales) { 2846 multipleRecommendedLocales) {
2817 var pod = this.getPodWithUsername_(userID); 2847 var pod = this.getPodWithUsername(userID);
2818 if (pod != null) { 2848 if (pod != null) {
2819 pod.populateLanguageSelect(locales, 2849 pod.populateLanguageSelect(locales,
2820 defaultLocale, 2850 defaultLocale,
2821 multipleRecommendedLocales); 2851 multipleRecommendedLocales);
2822 } 2852 }
2823 }, 2853 },
2824 2854
2825 /** 2855 /**
2826 * Updates the list of available keyboard layouts for a public session pod. 2856 * Updates the list of available keyboard layouts for a public session pod.
2827 * @param {string} userID The user ID of the public session 2857 * @param {string} userID The user ID of the public session
2828 * @param {string} locale The locale to which this list of keyboard layouts 2858 * @param {string} locale The locale to which this list of keyboard layouts
2829 * applies 2859 * applies
2830 * @param {!Object} list List of available keyboard layouts 2860 * @param {!Object} list List of available keyboard layouts
2831 */ 2861 */
2832 setPublicSessionKeyboardLayouts: function(userID, locale, list) { 2862 setPublicSessionKeyboardLayouts: function(userID, locale, list) {
2833 var pod = this.getPodWithUsername_(userID); 2863 var pod = this.getPodWithUsername(userID);
2834 if (pod != null) 2864 if (pod != null)
2835 pod.populateKeyboardSelect(locale, list); 2865 pod.populateKeyboardSelect(locale, list);
2836 }, 2866 },
2837 2867
2838 /** 2868 /**
2839 * Called when window was resized. 2869 * Called when window was resized.
2840 */ 2870 */
2841 onWindowResize: function() { 2871 onWindowResize: function() {
2842 var layout = this.calculateLayout_(); 2872 var layout = this.calculateLayout_();
2843 if (layout.columns != this.columns || layout.rows != this.rows) 2873 if (layout.columns != this.columns || layout.rows != this.rows)
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
3154 }, 3184 },
3155 3185
3156 /** 3186 /**
3157 * Shows signin UI. 3187 * Shows signin UI.
3158 * @param {string} email Email for signin UI. 3188 * @param {string} email Email for signin UI.
3159 */ 3189 */
3160 showSigninUI: function(email) { 3190 showSigninUI: function(email) {
3161 // Clear any error messages that might still be around. 3191 // Clear any error messages that might still be around.
3162 Oobe.clearErrors(); 3192 Oobe.clearErrors();
3163 this.disabled = true; 3193 this.disabled = true;
3164 this.lastFocusedPod_ = this.getPodWithUsername_(email); 3194 this.lastFocusedPod_ = this.getPodWithUsername(email);
3165 Oobe.showSigninUI(email); 3195 Oobe.showSigninUI(email);
3166 }, 3196 },
3167 3197
3168 /** 3198 /**
3169 * Updates current image of a user. 3199 * Updates current image of a user.
3170 * @param {string} username User for which to update the image. 3200 * @param {string} username User for which to update the image.
3171 */ 3201 */
3172 updateUserImage: function(username) { 3202 updateUserImage: function(username) {
3173 var pod = this.getPodWithUsername_(username); 3203 var pod = this.getPodWithUsername(username);
3174 if (pod) 3204 if (pod)
3175 pod.updateUserImage(); 3205 pod.updateUserImage();
3176 }, 3206 },
3177 3207
3178 /** 3208 /**
3179 * Handler of click event. 3209 * Handler of click event.
3180 * @param {Event} e Click Event object. 3210 * @param {Event} e Click Event object.
3181 * @private 3211 * @private
3182 */ 3212 */
3183 handleClick_: function(e) { 3213 handleClick_: function(e) {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
3427 if (pod && pod.multiProfilesPolicyApplied) { 3457 if (pod && pod.multiProfilesPolicyApplied) {
3428 pod.userTypeBubbleElement.classList.remove('bubble-shown'); 3458 pod.userTypeBubbleElement.classList.remove('bubble-shown');
3429 } 3459 }
3430 } 3460 }
3431 }; 3461 };
3432 3462
3433 return { 3463 return {
3434 PodRow: PodRow 3464 PodRow: PodRow
3435 }; 3465 };
3436 }); 3466 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698