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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
737 */ | 737 */ |
738 userClickAuthAllowed_: false, | 738 userClickAuthAllowed_: false, |
739 | 739 |
740 /** | 740 /** |
741 * Whether the user has recently authenticated with fingerprint. | 741 * Whether the user has recently authenticated with fingerprint. |
742 * @type {boolean} | 742 * @type {boolean} |
743 * @private | 743 * @private |
744 */ | 744 */ |
745 fingerprintAuthenticated_: false, | 745 fingerprintAuthenticated_: false, |
746 | 746 |
747 /** | |
748 * True iff the pod can display the pin keyboard. The pin keyboard may not | |
749 * always be displayed even if this is true, ie, if the virtual keyboard is | |
750 * also being displayed. | |
751 */ | |
752 pinEnabled: false, | |
753 | |
747 /** @override */ | 754 /** @override */ |
748 decorate: function() { | 755 decorate: function() { |
749 this.tabIndex = UserPodTabOrder.POD_INPUT; | 756 this.tabIndex = UserPodTabOrder.POD_INPUT; |
750 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT; | 757 this.actionBoxAreaElement.tabIndex = UserPodTabOrder.POD_INPUT; |
751 | 758 |
752 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this)); | 759 this.addEventListener('keydown', this.handlePodKeyDown_.bind(this)); |
753 this.addEventListener('click', this.handleClickOnPod_.bind(this)); | 760 this.addEventListener('click', this.handleClickOnPod_.bind(this)); |
754 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this)); | 761 this.addEventListener('mousedown', this.handlePodMouseDown_.bind(this)); |
755 | 762 |
756 if (this.pinKeyboard) { | 763 if (this.pinKeyboard) { |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1218 | 1225 |
1219 isPinReady: function() { | 1226 isPinReady: function() { |
1220 return this.pinKeyboard && this.pinKeyboard.offsetHeight > 0; | 1227 return this.pinKeyboard && this.pinKeyboard.offsetHeight > 0; |
1221 }, | 1228 }, |
1222 | 1229 |
1223 set showError(visible) { | 1230 set showError(visible) { |
1224 if (this.submitButton) | 1231 if (this.submitButton) |
1225 this.submitButton.classList.toggle('error-shown', visible); | 1232 this.submitButton.classList.toggle('error-shown', visible); |
1226 }, | 1233 }, |
1227 | 1234 |
1228 toggleTransitions: function(enable) { | |
1229 this.classList.toggle('flying-pin-pod', enable); | |
1230 }, | |
1231 | |
1232 updatePinClass_: function(element, enable) { | 1235 updatePinClass_: function(element, enable) { |
1233 element.classList.toggle('pin-enabled', enable); | 1236 element.classList.toggle('pin-enabled', enable); |
1234 element.classList.toggle('pin-disabled', !enable); | 1237 element.classList.toggle('pin-disabled', !enable); |
1235 }, | 1238 }, |
1236 | 1239 |
1237 setPinVisibility: function(visible) { | 1240 setPinVisibility: function(visible) { |
1238 if (this.isPinShown() == visible) | 1241 if (this.isPinShown() == visible) |
1239 return; | 1242 return; |
1240 | 1243 |
1241 // Do not show pin if virtual keyboard is there. | 1244 // Do not show pin if virtual keyboard is there. |
1242 if (visible && Oobe.getInstance().virtualKeyboardShown) | 1245 if (visible && Oobe.getInstance().virtualKeyboardShown) |
1243 return; | 1246 return; |
1244 | 1247 |
1248 // Do not show pin keyboard if the pod does not have pin enabled. | |
1249 if (visible && !this.pinEnabled) | |
1250 return; | |
1251 | |
1245 var elements = this.getElementsByClassName('pin-tag'); | 1252 var elements = this.getElementsByClassName('pin-tag'); |
1246 for (var i = 0; i < elements.length; ++i) | 1253 for (var i = 0; i < elements.length; ++i) |
1247 this.updatePinClass_(elements[i], visible); | 1254 this.updatePinClass_(elements[i], visible); |
1248 this.updatePinClass_(this, visible); | 1255 this.updatePinClass_(this, visible); |
1249 | 1256 |
1250 // Set the focus to the input element after showing/hiding pin keyboard. | 1257 // Set the focus to the input element after showing/hiding pin keyboard. |
1251 this.mainInput.focus(); | 1258 this.mainInput.focus(); |
1252 | 1259 |
1253 // Change the password placeholder based on pin keyboard visibility. | 1260 // Change the password placeholder based on pin keyboard visibility. |
1254 this.passwordElement.placeholder = loadTimeData.getString(visible ? | 1261 this.passwordElement.placeholder = loadTimeData.getString(visible ? |
(...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2843 * Add an existing user pod to this pod row. | 2850 * Add an existing user pod to this pod row. |
2844 * @param {!Object} user User info dictionary. | 2851 * @param {!Object} user User info dictionary. |
2845 */ | 2852 */ |
2846 addUserPod: function(user) { | 2853 addUserPod: function(user) { |
2847 var userPod = this.createUserPod(user); | 2854 var userPod = this.createUserPod(user); |
2848 this.appendChild(userPod); | 2855 this.appendChild(userPod); |
2849 userPod.initialize(); | 2856 userPod.initialize(); |
2850 }, | 2857 }, |
2851 | 2858 |
2852 /** | 2859 /** |
2853 * Enables or disables transitions on every pod instance. | |
2854 * @param {boolean} enable | |
2855 */ | |
2856 toggleTransitions: function(enable) { | |
2857 for (var i = 0; i < this.pods.length; ++i) | |
2858 this.pods[i].toggleTransitions(enable); | |
2859 }, | |
2860 | |
2861 /** | |
2862 * Performs visual changes on the user pod if there is an error. | 2860 * Performs visual changes on the user pod if there is an error. |
2863 * @param {boolean} visible Whether to show or hide the display. | 2861 * @param {boolean} visible Whether to show or hide the display. |
2864 */ | 2862 */ |
2865 setFocusedPodErrorDisplay: function(visible) { | 2863 setFocusedPodErrorDisplay: function(visible) { |
2866 if (this.focusedPod_) | 2864 if (this.focusedPod_) |
2867 this.focusedPod_.showError = visible; | 2865 this.focusedPod_.showError = visible; |
2868 }, | 2866 }, |
2869 | 2867 |
2870 /** | 2868 /** |
2871 * Shows or hides the pin keyboard for the current focused pod. | 2869 * Shows or hides the pin keyboard for the current focused pod. |
2872 * @param {boolean} visible | 2870 * @param {boolean} visible |
2873 */ | 2871 */ |
2874 setFocusedPodPinVisibility: function(visible) { | 2872 setFocusedPodPinVisibility: function(visible) { |
2875 if (this.focusedPod_ && this.focusedPod_.user.showPin) | 2873 if (this.focusedPod_) |
2876 this.focusedPod_.setPinVisibility(visible); | 2874 this.focusedPod_.setPinVisibility(visible); |
2877 }, | 2875 }, |
2878 | 2876 |
2879 /** | 2877 /** |
2880 * Runs app with a given id from the list of loaded apps. | 2878 * Runs app with a given id from the list of loaded apps. |
2881 * @param {!string} app_id of an app to run. | 2879 * @param {!string} app_id of an app to run. |
2882 * @param {boolean=} opt_diagnosticMode Whether to run the app in | 2880 * @param {boolean=} opt_diagnosticMode Whether to run the app in |
2883 * diagnostic mode. Default is false. | 2881 * diagnostic mode. Default is false. |
2884 */ | 2882 */ |
2885 findAndRunAppForTesting: function(app_id, opt_diagnosticMode) { | 2883 findAndRunAppForTesting: function(app_id, opt_diagnosticMode) { |
2886 var app = this.getPodWithAppId_(app_id); | 2884 var app = this.getPodWithAppId_(app_id); |
2887 if (app) { | 2885 if (app) { |
2888 var activationEvent = cr.doc.createEvent('MouseEvents'); | 2886 var activationEvent = cr.doc.createEvent('MouseEvents'); |
2889 var ctrlKey = opt_diagnosticMode; | 2887 var ctrlKey = opt_diagnosticMode; |
2890 activationEvent.initMouseEvent('click', true, true, null, | 2888 activationEvent.initMouseEvent('click', true, true, null, |
2891 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null); | 2889 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null); |
2892 app.dispatchEvent(activationEvent); | 2890 app.dispatchEvent(activationEvent); |
2893 } | 2891 } |
2894 }, | 2892 }, |
2895 | 2893 |
2896 /** | 2894 /** |
2897 * Remove the pin keyboard from the pod with the given |username|. | 2895 * Enables or disables the pin keyboard for the given user. A disabled pin |
2896 * keyboard will never be displayed. | |
2897 * | |
2898 * If the user's pod is focused, then enabling the pin keyboard will display | |
2899 * it; disabling the pin keyboard will hide it. | |
2900 * @param {!user} username | |
xiyuan
2017/04/03 21:21:43
nit: {!user} -> {!string}
jdufault
2017/04/10 21:06:31
Done.
| |
2901 * @param {boolean} enabled | |
2902 */ | |
2903 setPinEnabled: function(username, enabled) { | |
2904 var pod = this.getPodWithUsername_(username); | |
2905 if (!pod) { | |
2906 console.error('Attempt to enable/disable pin keyboard of missing pod.'); | |
2907 return; | |
2908 } | |
2909 | |
2910 // Make sure to set |pinEnabled| before toggling visiblity to avoid | |
2911 // validation errors. | |
2912 pod.pinEnabled = enabled; | |
2913 | |
2914 if (this.focusedPod_ == pod) { | |
2915 if (enabled) { | |
2916 ensurePinKeyboardLoaded( | |
2917 this.setPinVisibility.bind(this, username, true)); | |
2918 } else { | |
2919 this.setPinVisibility(username, false); | |
2920 } | |
2921 } | |
2922 }, | |
2923 | |
2924 /** | |
2925 * Shows or hides the pin keyboard from the pod with the given |username|. | |
2926 * This is only a visibility change; the pin keyboard can be reshown. | |
2927 * | |
2928 * Use setPinEnabled if the pin keyboard should be disabled for the given | |
2929 * user. | |
2898 * @param {!user} username | 2930 * @param {!user} username |
2899 * @param {boolean} visible | 2931 * @param {boolean} visible |
2900 */ | 2932 */ |
2901 removePinKeyboard: function(username) { | 2933 setPinVisibility: function(username, visible) { |
2902 var pod = this.getPodWithUsername_(username); | 2934 var pod = this.getPodWithUsername_(username); |
2903 if (!pod) { | 2935 if (!pod) { |
2904 console.warn('Attempt to remove pin keyboard of missing pod.'); | 2936 console.error('Attempt to show/hide pin keyboard of missing pod.'); |
2905 return; | 2937 return; |
2906 } | 2938 } |
2907 // Remove the child, so that the virtual keyboard cannot bring it up | 2939 if (visible && pod.pinEnabled === false) { |
2908 // again after three tries. | 2940 console.error('Attempt to show disabled pin keyboard'); |
2909 if (pod.pinContainer) | 2941 return; |
2910 pod.removeChild(pod.pinContainer); | 2942 } |
2911 pod.setPinVisibility(false); | 2943 if (visible && this.focusedPod_ != pod) { |
2944 console.error('Attempt to show pin keyboard on non-focused pod'); | |
2945 return; | |
2946 } | |
2947 | |
2948 pod.setPinVisibility(visible); | |
2912 }, | 2949 }, |
2913 | 2950 |
2914 /** | 2951 /** |
2915 * Removes user pod from pod row. | 2952 * Removes user pod from pod row. |
2916 * @param {!user} username | 2953 * @param {!user} username |
2917 */ | 2954 */ |
2918 removeUserPod: function(username) { | 2955 removeUserPod: function(username) { |
2919 var podToRemove = this.getPodWithUsername_(username); | 2956 var podToRemove = this.getPodWithUsername_(username); |
2920 if (podToRemove == null) { | 2957 if (podToRemove == null) { |
2921 console.warn('Attempt to remove pod that does not exist'); | 2958 console.warn('Attempt to remove pod that does not exist'); |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3940 if (pod && pod.multiProfilesPolicyApplied) { | 3977 if (pod && pod.multiProfilesPolicyApplied) { |
3941 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3978 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
3942 } | 3979 } |
3943 } | 3980 } |
3944 }; | 3981 }; |
3945 | 3982 |
3946 return { | 3983 return { |
3947 PodRow: PodRow | 3984 PodRow: PodRow |
3948 }; | 3985 }; |
3949 }); | 3986 }); |
OLD | NEW |