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 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 this.tabIndex = UserPodTabOrder.POD_INPUT; | 711 this.tabIndex = UserPodTabOrder.POD_INPUT; |
| 712 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT; | 712 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT; |
| 713 | 713 |
| 714 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this)); | 714 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this)); |
| 715 this.addEventListener('click', this.handleClickOnPod_.bind(this)); | 715 this.addEventListener('click', this.handleClickOnPod_.bind(this)); |
| 716 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this)); | 716 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this)); |
| 717 | 717 |
| 718 if (this.pinKeyboard) { | 718 if (this.pinKeyboard) { |
| 719 this.pinKeyboard.addEventListener('submit', | 719 this.pinKeyboard.addEventListener('submit', |
| 720 this.handlePinSubmitted_.bind(this)); | 720 this.handlePinSubmitted_.bind(this)); |
| 721 this.pinKeyboard.addEventListener('pin-change', | |
| 722 this.handlePinChanged_.bind(this)); | |
| 721 } | 723 } |
| 722 | 724 |
| 723 this.actionBoxAreaElement.addEventListener('mousedown', | 725 this.actionBoxAreaElement.addEventListener('mousedown', |
| 724 stopEventPropagation); | 726 stopEventPropagation); |
| 725 this.actionBoxAreaElement.addEventListener('click', | 727 this.actionBoxAreaElement.addEventListener('click', |
| 726 this.handleActionAreaButtonClick_.bind(this)); | 728 this.handleActionAreaButtonClick_.bind(this)); |
| 727 this.actionBoxAreaElement.addEventListener('keydown', | 729 this.actionBoxAreaElement.addEventListener('keydown', |
| 728 this.handleActionAreaButtonKeyDown_.bind(this)); | 730 this.handleActionAreaButtonKeyDown_.bind(this)); |
| 729 | 731 |
| 730 this.actionBoxMenuTitleElement.addEventListener('keydown', | 732 this.actionBoxMenuTitleElement.addEventListener('keydown', |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 748 }, | 750 }, |
| 749 | 751 |
| 750 /** | 752 /** |
| 751 * Initializes the pod after its properties set and added to a pod row. | 753 * Initializes the pod after its properties set and added to a pod row. |
| 752 */ | 754 */ |
| 753 initialize: function() { | 755 initialize: function() { |
| 754 this.passwordElement.addEventListener('keydown', | 756 this.passwordElement.addEventListener('keydown', |
| 755 this.parentNode.handleKeyDown.bind(this.parentNode)); | 757 this.parentNode.handleKeyDown.bind(this.parentNode)); |
| 756 this.passwordElement.addEventListener('keypress', | 758 this.passwordElement.addEventListener('keypress', |
| 757 this.handlePasswordKeyPress_.bind(this)); | 759 this.handlePasswordKeyPress_.bind(this)); |
| 760 this.passwordElement.addEventListener('input', | |
| 761 this.handleInputChanged_.bind(this)); | |
| 758 | 762 |
| 759 this.imageElement.addEventListener('load', | 763 this.imageElement.addEventListener('load', |
| 760 this.parentNode.handlePodImageLoad.bind(this.parentNode, this)); | 764 this.parentNode.handlePodImageLoad.bind(this.parentNode, this)); |
| 761 | 765 |
| 762 var initialAuthType = this.user.initialAuthType || | 766 var initialAuthType = this.user.initialAuthType || |
| 763 AUTH_TYPE.OFFLINE_PASSWORD; | 767 AUTH_TYPE.OFFLINE_PASSWORD; |
| 764 this.setAuthType(initialAuthType, null); | 768 this.setAuthType(initialAuthType, null); |
| 765 | 769 |
| 766 this.userClickAuthAllowed_ = false; | 770 this.userClickAuthAllowed_ = false; |
| 767 }, | 771 }, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 | 873 |
| 870 /** | 874 /** |
| 871 * Gets the password label, which is used to show a message where the | 875 * Gets the password label, which is used to show a message where the |
| 872 * password field is normally. | 876 * password field is normally. |
| 873 * @type {!HTMLInputElement} | 877 * @type {!HTMLInputElement} |
| 874 */ | 878 */ |
| 875 get passwordLabelElement() { | 879 get passwordLabelElement() { |
| 876 return this.querySelector('.password-label'); | 880 return this.querySelector('.password-label'); |
| 877 }, | 881 }, |
| 878 | 882 |
| 883 get pinContainer() { | |
| 884 return this.querySelector('.pin-container'); | |
| 885 }, | |
| 886 | |
| 879 /** | 887 /** |
| 880 * Gets the pin-keyboard of the pod. | 888 * Gets the pin-keyboard of the pod. |
| 881 * @type {!HTMLElement} | 889 * @type {!HTMLElement} |
| 882 */ | 890 */ |
| 883 get pinKeyboard() { | 891 get pinKeyboard() { |
| 884 return this.querySelector('pin-keyboard'); | 892 return this.querySelector('pin-keyboard'); |
| 885 }, | 893 }, |
| 886 | 894 |
| 887 /** | 895 /** |
| 888 * Gets user online sign in hint element. | 896 * Gets user online sign in hint element. |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1096 toggleTransitions: function(enable) { | 1104 toggleTransitions: function(enable) { |
| 1097 this.classList.toggle('flying-pin-pod', enable); | 1105 this.classList.toggle('flying-pin-pod', enable); |
| 1098 }, | 1106 }, |
| 1099 | 1107 |
| 1100 updatePinClass_: function(element, enable) { | 1108 updatePinClass_: function(element, enable) { |
| 1101 element.classList.toggle('pin-enabled', enable); | 1109 element.classList.toggle('pin-enabled', enable); |
| 1102 element.classList.toggle('pin-disabled', !enable); | 1110 element.classList.toggle('pin-disabled', !enable); |
| 1103 }, | 1111 }, |
| 1104 | 1112 |
| 1105 setPinVisibility: function(visible) { | 1113 setPinVisibility: function(visible) { |
| 1114 if (this.isPinShown() == visible) | |
| 1115 return; | |
| 1116 | |
| 1117 // If the header is hidden that means the virtual keyboard is displayed. | |
| 1118 if (visible && Oobe.getInstance().headerHidden) | |
|
jdufault
2016/08/24 01:35:11
Add a helper method hasVirtualKeyboard on the Oobe
sammiequon
2016/08/25 18:12:33
Done.
| |
| 1119 return; | |
| 1120 | |
| 1106 var elements = this.getElementsByClassName('pin-tag'); | 1121 var elements = this.getElementsByClassName('pin-tag'); |
| 1107 for (var i = 0; i < elements.length; ++i) | 1122 for (var i = 0; i < elements.length; ++i) |
| 1108 this.updatePinClass_(elements[i], visible); | 1123 this.updatePinClass_(elements[i], this.pinKeyboard? visible : false); |
| 1109 this.updatePinClass_(this, visible); | 1124 this.updatePinClass_(this, this.pinKeyboard? visible : false); |
| 1110 | 1125 |
| 1111 // Set the focus to the input element after showing/hiding pin keyboard. | 1126 // Set the focus to the input element after showing/hiding pin keyboard. |
| 1112 if (this.pinKeyboard && visible) | 1127 this.mainInput.focus(); |
| 1113 this.pinKeyboard.focus(); | |
| 1114 }, | 1128 }, |
| 1115 | 1129 |
| 1116 isPinShown: function() { | 1130 isPinShown: function() { |
| 1117 return this.classList.contains('pin-enabled'); | 1131 return this.classList.contains('pin-enabled'); |
| 1118 }, | 1132 }, |
| 1119 | 1133 |
| 1120 setUserPodIconType: function(userTypeClass) { | 1134 setUserPodIconType: function(userTypeClass) { |
| 1121 this.userTypeIconAreaElement.classList.add(userTypeClass); | 1135 this.userTypeIconAreaElement.classList.add(userTypeClass); |
| 1122 this.userTypeIconAreaElement.hidden = false; | 1136 this.userTypeIconAreaElement.hidden = false; |
| 1123 }, | 1137 }, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1145 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); | 1159 (Oobe.getInstance().displayType == DISPLAY_TYPE.USER_ADDING); |
| 1146 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed; | 1160 return isMultiProfilesUI && !this.user_.isMultiProfilesAllowed; |
| 1147 }, | 1161 }, |
| 1148 | 1162 |
| 1149 /** | 1163 /** |
| 1150 * Gets main input element. | 1164 * Gets main input element. |
| 1151 * @type {(HTMLButtonElement|HTMLInputElement)} | 1165 * @type {(HTMLButtonElement|HTMLInputElement)} |
| 1152 */ | 1166 */ |
| 1153 get mainInput() { | 1167 get mainInput() { |
| 1154 if (this.isAuthTypePassword) { | 1168 if (this.isAuthTypePassword) { |
| 1155 if (this.isPinShown() && this.pinKeyboard.inputElement) | |
| 1156 return this.pinKeyboard.inputElement; | |
| 1157 return this.passwordElement; | 1169 return this.passwordElement; |
| 1158 } else if (this.isAuthTypeOnlineSignIn) { | 1170 } else if (this.isAuthTypeOnlineSignIn) { |
| 1159 return this; | 1171 return this; |
| 1160 } else if (this.isAuthTypeUserClick) { | 1172 } else if (this.isAuthTypeUserClick) { |
| 1161 return this.passwordLabelElement; | 1173 return this.passwordLabelElement; |
| 1162 } | 1174 } |
| 1163 }, | 1175 }, |
| 1164 | 1176 |
| 1165 /** | 1177 /** |
| 1166 * Whether action box button is in active state. | 1178 * Whether action box button is in active state. |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1782 | 1794 |
| 1783 /** | 1795 /** |
| 1784 * Handles click event on submit button on the pin keyboard. | 1796 * Handles click event on submit button on the pin keyboard. |
| 1785 * @param {Event} e Click event. | 1797 * @param {Event} e Click event. |
| 1786 */ | 1798 */ |
| 1787 handlePinSubmitted_: function(e) { | 1799 handlePinSubmitted_: function(e) { |
| 1788 if (this.parentNode.isFocused(this)) | 1800 if (this.parentNode.isFocused(this)) |
| 1789 this.parentNode.setActivatedPod(this); | 1801 this.parentNode.setActivatedPod(this); |
| 1790 }, | 1802 }, |
| 1791 | 1803 |
| 1804 handlePinChanged_: function(e) { | |
| 1805 this.passwordElement.value = e.detail.pin; | |
| 1806 }, | |
| 1807 | |
| 1808 handleInputChanged_: function(e) { | |
| 1809 if (this.pinKeyboard) | |
| 1810 this.pinKeyboard.value = this.passwordElement.value; | |
| 1811 }, | |
| 1812 | |
| 1792 /** | 1813 /** |
| 1793 * Handles click event on a user pod. | 1814 * Handles click event on a user pod. |
| 1794 * @param {Event} e Click event. | 1815 * @param {Event} e Click event. |
| 1795 */ | 1816 */ |
| 1796 handleClickOnPod_: function(e) { | 1817 handleClickOnPod_: function(e) { |
| 1797 if (this.parentNode.disabled) | 1818 if (this.parentNode.disabled) |
| 1798 return; | 1819 return; |
| 1799 | 1820 |
| 1800 if (!this.isActionBoxMenuActive) { | 1821 if (!this.isActionBoxMenuActive) { |
| 1801 if (this.isAuthTypeOnlineSignIn) { | 1822 if (this.isAuthTypeOnlineSignIn) { |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2582 if (app) { | 2603 if (app) { |
| 2583 var activationEvent = cr.doc.createEvent('MouseEvents'); | 2604 var activationEvent = cr.doc.createEvent('MouseEvents'); |
| 2584 var ctrlKey = opt_diagnosticMode; | 2605 var ctrlKey = opt_diagnosticMode; |
| 2585 activationEvent.initMouseEvent('click', true, true, null, | 2606 activationEvent.initMouseEvent('click', true, true, null, |
| 2586 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null); | 2607 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null); |
| 2587 app.dispatchEvent(activationEvent); | 2608 app.dispatchEvent(activationEvent); |
| 2588 } | 2609 } |
| 2589 }, | 2610 }, |
| 2590 | 2611 |
| 2591 /** | 2612 /** |
| 2613 * Function that hides the pin keyboard. Meant to be called when the virtual | |
| 2614 * keyboard is enabled and being toggled. | |
| 2615 * @param {boolean} hidden | |
| 2616 */ | |
| 2617 setPinHidden: function(hidden) { | |
| 2618 this.setFocusedPodPinVisibility(!hidden); | |
| 2619 }, | |
| 2620 | |
| 2621 /** | |
| 2592 * Toggles pod PIN keyboard visiblity. | 2622 * Toggles pod PIN keyboard visiblity. |
| 2593 * @param {!user} username | 2623 * @param {!user} username |
| 2594 * @param {boolean} visible | 2624 * @param {boolean} visible |
| 2595 */ | 2625 */ |
| 2596 setPinVisibility: function(username, visible) { | 2626 setPinVisibility: function(username, visible) { |
| 2597 var pod = this.getPodWithUsername_(username); | 2627 var pod = this.getPodWithUsername_(username); |
| 2598 if (!pod) { | 2628 if (!pod) { |
| 2599 console.warn('Attempt to change pin visibility to ' + visible + | 2629 console.warn('Attempt to change pin visibility to ' + visible + |
| 2600 ' for missing pod'); | 2630 ' for missing pod'); |
| 2601 return; | 2631 return; |
| 2602 } | 2632 } |
| 2603 | 2633 // Remove the child, so that the virtual keyboard cannot bring it up |
| 2604 pod.setPinVisibility(visible); | 2634 // again after three tries. |
|
jdufault
2016/08/24 01:35:11
setPinVisiblity is named and read such that the PI
sammiequon
2016/08/25 18:12:34
Done.
| |
| 2635 if (pod.pinContainer) | |
| 2636 pod.removeChild(pod.pinContainer); | |
| 2637 pod.setPinVisibility(false); | |
|
jdufault
2016/08/24 01:35:11
What if |visible| is true?
If this function is on
sammiequon
2016/08/25 18:12:34
Done.
| |
| 2605 }, | 2638 }, |
| 2606 | 2639 |
| 2607 /** | 2640 /** |
| 2608 * Removes user pod from pod row. | 2641 * Removes user pod from pod row. |
| 2609 * @param {!user} username | 2642 * @param {!user} username |
| 2610 */ | 2643 */ |
| 2611 removeUserPod: function(username) { | 2644 removeUserPod: function(username) { |
| 2612 var podToRemove = this.getPodWithUsername_(username); | 2645 var podToRemove = this.getPodWithUsername_(username); |
| 2613 if (podToRemove == null) { | 2646 if (podToRemove == null) { |
| 2614 console.warn('Attempt to remove pod that does not exist'); | 2647 console.warn('Attempt to remove pod that does not exist'); |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3136 } | 3169 } |
| 3137 } | 3170 } |
| 3138 | 3171 |
| 3139 // Clear any error messages for previous pod. | 3172 // Clear any error messages for previous pod. |
| 3140 if (!this.isFocused(podToFocus)) | 3173 if (!this.isFocused(podToFocus)) |
| 3141 Oobe.clearErrors(); | 3174 Oobe.clearErrors(); |
| 3142 | 3175 |
| 3143 var hadFocus = !!this.focusedPod_; | 3176 var hadFocus = !!this.focusedPod_; |
| 3144 this.focusedPod_ = podToFocus; | 3177 this.focusedPod_ = podToFocus; |
| 3145 if (podToFocus) { | 3178 if (podToFocus) { |
| 3146 this.setFocusedPodPinVisibility(true); | 3179 if (!hadFocus) |
| 3180 this.setFocusedPodPinVisibility(true); | |
| 3147 podToFocus.classList.remove('faded'); | 3181 podToFocus.classList.remove('faded'); |
| 3148 podToFocus.classList.add('focused'); | 3182 podToFocus.classList.add('focused'); |
| 3149 if (!podToFocus.multiProfilesPolicyApplied) { | 3183 if (!podToFocus.multiProfilesPolicyApplied) { |
| 3150 podToFocus.classList.toggle('signing-in', false); | 3184 podToFocus.classList.toggle('signing-in', false); |
| 3151 if (!opt_skipInputFocus) | 3185 if (!opt_skipInputFocus) |
| 3152 podToFocus.focusInput(); | 3186 podToFocus.focusInput(); |
| 3153 } else { | 3187 } else { |
| 3154 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); | 3188 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); |
| 3155 // Note it is not necessary to skip this focus request when | 3189 // Note it is not necessary to skip this focus request when |
| 3156 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied| | 3190 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied| |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3543 if (pod && pod.multiProfilesPolicyApplied) { | 3577 if (pod && pod.multiProfilesPolicyApplied) { |
| 3544 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3578 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3545 } | 3579 } |
| 3546 } | 3580 } |
| 3547 }; | 3581 }; |
| 3548 | 3582 |
| 3549 return { | 3583 return { |
| 3550 PodRow: PodRow | 3584 PodRow: PodRow |
| 3551 }; | 3585 }; |
| 3552 }); | 3586 }); |
| OLD | NEW |