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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1096 toggleTransitions: function(enable) { | 1100 toggleTransitions: function(enable) { |
| 1097 this.classList.toggle('flying-pin-pod', enable); | 1101 this.classList.toggle('flying-pin-pod', enable); |
| 1098 }, | 1102 }, |
| 1099 | 1103 |
| 1100 updatePinClass_: function(element, enable) { | 1104 updatePinClass_: function(element, enable) { |
| 1101 element.classList.toggle('pin-enabled', enable); | 1105 element.classList.toggle('pin-enabled', enable); |
| 1102 element.classList.toggle('pin-disabled', !enable); | 1106 element.classList.toggle('pin-disabled', !enable); |
| 1103 }, | 1107 }, |
| 1104 | 1108 |
| 1105 setPinVisibility: function(visible) { | 1109 setPinVisibility: function(visible) { |
| 1110 if (this.isPinShown() == visible) | |
| 1111 return; | |
| 1112 | |
| 1106 var elements = this.getElementsByClassName('pin-tag'); | 1113 var elements = this.getElementsByClassName('pin-tag'); |
| 1107 for (var i = 0; i < elements.length; ++i) | 1114 for (var i = 0; i < elements.length; ++i) |
| 1108 this.updatePinClass_(elements[i], visible); | 1115 this.updatePinClass_(elements[i], visible); |
| 1109 this.updatePinClass_(this, visible); | 1116 this.updatePinClass_(this, visible); |
| 1110 | 1117 |
| 1111 // Set the focus to the input element after showing/hiding pin keyboard. | 1118 // Set the focus to the input element after showing/hiding pin keyboard. |
| 1112 if (this.pinKeyboard && visible) | 1119 this.mainInput.focus(); |
| 1113 this.pinKeyboard.focus(); | |
| 1114 }, | 1120 }, |
| 1115 | 1121 |
| 1116 isPinShown: function() { | 1122 isPinShown: function() { |
| 1117 return this.classList.contains('pin-enabled'); | 1123 return this.classList.contains('pin-enabled'); |
| 1118 }, | 1124 }, |
| 1119 | 1125 |
| 1120 setUserPodIconType: function(userTypeClass) { | 1126 setUserPodIconType: function(userTypeClass) { |
| 1121 this.userTypeIconAreaElement.classList.add(userTypeClass); | 1127 this.userTypeIconAreaElement.classList.add(userTypeClass); |
| 1122 this.userTypeIconAreaElement.hidden = false; | 1128 this.userTypeIconAreaElement.hidden = false; |
| 1123 }, | 1129 }, |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1763 | 1769 |
| 1764 /** | 1770 /** |
| 1765 * Handles click event on submit button on the pin keyboard. | 1771 * Handles click event on submit button on the pin keyboard. |
| 1766 * @param {Event} e Click event. | 1772 * @param {Event} e Click event. |
| 1767 */ | 1773 */ |
| 1768 handlePinSubmitted_: function(e) { | 1774 handlePinSubmitted_: function(e) { |
| 1769 if (this.parentNode.isFocused(this)) | 1775 if (this.parentNode.isFocused(this)) |
| 1770 this.parentNode.setActivatedPod(this); | 1776 this.parentNode.setActivatedPod(this); |
| 1771 }, | 1777 }, |
| 1772 | 1778 |
| 1779 handlePinChanged_: function(e) { | |
| 1780 this.passwordElement.value = e.detail.pin; | |
| 1781 }, | |
| 1782 | |
| 1783 handleInputChanged_: function(e) { | |
| 1784 if (this.pinKeyboard) | |
| 1785 this.pinKeyboard.setNewValue(this.passwordElement.value); | |
| 1786 }, | |
| 1787 | |
| 1773 /** | 1788 /** |
| 1774 * Handles click event on a user pod. | 1789 * Handles click event on a user pod. |
| 1775 * @param {Event} e Click event. | 1790 * @param {Event} e Click event. |
| 1776 */ | 1791 */ |
| 1777 handleClickOnPod_: function(e) { | 1792 handleClickOnPod_: function(e) { |
| 1778 if (this.parentNode.disabled) | 1793 if (this.parentNode.disabled) |
| 1779 return; | 1794 return; |
| 1780 | 1795 |
| 1781 if (!this.isActionBoxMenuActive) { | 1796 if (!this.isActionBoxMenuActive) { |
| 1782 if (this.isAuthTypeOnlineSignIn) { | 1797 if (this.isAuthTypeOnlineSignIn) { |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2386 | 2401 |
| 2387 PodRow.prototype = { | 2402 PodRow.prototype = { |
| 2388 __proto__: HTMLDivElement.prototype, | 2403 __proto__: HTMLDivElement.prototype, |
| 2389 | 2404 |
| 2390 // Whether this user pod row is shown for the first time. | 2405 // Whether this user pod row is shown for the first time. |
| 2391 firstShown_: true, | 2406 firstShown_: true, |
| 2392 | 2407 |
| 2393 // True if inside focusPod(). | 2408 // True if inside focusPod(). |
| 2394 insideFocusPod_: false, | 2409 insideFocusPod_: false, |
| 2395 | 2410 |
| 2411 // Prevents the pin from being shown because the virtual keyboard is enabled | |
| 2412 // and being displayed. | |
| 2413 dontShowPinOverride_: false, | |
|
jdufault
2016/08/19 01:06:47
forceHidePin?
sammiequon
2016/08/23 17:28:11
Removed.
| |
| 2414 | |
| 2396 // Focused pod. | 2415 // Focused pod. |
| 2397 focusedPod_: undefined, | 2416 focusedPod_: undefined, |
| 2398 | 2417 |
| 2399 // Activated pod, i.e. the pod of current login attempt. | 2418 // Activated pod, i.e. the pod of current login attempt. |
| 2400 activatedPod_: undefined, | 2419 activatedPod_: undefined, |
| 2401 | 2420 |
| 2402 // Pod that was most recently focused, if any. | 2421 // Pod that was most recently focused, if any. |
| 2403 lastFocusedPod_: undefined, | 2422 lastFocusedPod_: undefined, |
| 2404 | 2423 |
| 2405 // Pods whose initial images haven't been loaded yet. | 2424 // Pods whose initial images haven't been loaded yet. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2541 this.appendChild(userPod); | 2560 this.appendChild(userPod); |
| 2542 userPod.initialize(); | 2561 userPod.initialize(); |
| 2543 }, | 2562 }, |
| 2544 | 2563 |
| 2545 togglePinTransitions: function(enable) { | 2564 togglePinTransitions: function(enable) { |
| 2546 for (var i = 0; i < this.pods.length; ++i) | 2565 for (var i = 0; i < this.pods.length; ++i) |
| 2547 this.pods[i].toggleTransitions(enable); | 2566 this.pods[i].toggleTransitions(enable); |
| 2548 }, | 2567 }, |
| 2549 | 2568 |
| 2550 setFocusedPodPinVisibility: function(visible) { | 2569 setFocusedPodPinVisibility: function(visible) { |
| 2551 if (this.focusedPod_ && this.focusedPod_.user.showPin) | 2570 if (this.focusedPod_ && this.focusedPod_.user.showPin) { |
| 2571 if (this.dontShowPinOverride_) { | |
| 2572 this.dontShowPinOverride_ = false; | |
| 2573 return; | |
| 2574 } | |
| 2552 this.focusedPod_.setPinVisibility(visible); | 2575 this.focusedPod_.setPinVisibility(visible); |
| 2576 } | |
| 2553 }, | 2577 }, |
| 2554 | 2578 |
| 2555 /** | 2579 /** |
| 2556 * Runs app with a given id from the list of loaded apps. | 2580 * Runs app with a given id from the list of loaded apps. |
| 2557 * @param {!string} app_id of an app to run. | 2581 * @param {!string} app_id of an app to run. |
| 2558 * @param {boolean=} opt_diagnosticMode Whether to run the app in | 2582 * @param {boolean=} opt_diagnosticMode Whether to run the app in |
| 2559 * diagnostic mode. Default is false. | 2583 * diagnostic mode. Default is false. |
| 2560 */ | 2584 */ |
| 2561 findAndRunAppForTesting: function(app_id, opt_diagnosticMode) { | 2585 findAndRunAppForTesting: function(app_id, opt_diagnosticMode) { |
| 2562 var app = this.getPodWithAppId_(app_id); | 2586 var app = this.getPodWithAppId_(app_id); |
| 2563 if (app) { | 2587 if (app) { |
| 2564 var activationEvent = cr.doc.createEvent('MouseEvents'); | 2588 var activationEvent = cr.doc.createEvent('MouseEvents'); |
| 2565 var ctrlKey = opt_diagnosticMode; | 2589 var ctrlKey = opt_diagnosticMode; |
| 2566 activationEvent.initMouseEvent('click', true, true, null, | 2590 activationEvent.initMouseEvent('click', true, true, null, |
| 2567 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null); | 2591 0, 0, 0, 0, 0, ctrlKey, false, false, false, 0, null); |
| 2568 app.dispatchEvent(activationEvent); | 2592 app.dispatchEvent(activationEvent); |
| 2569 } | 2593 } |
| 2570 }, | 2594 }, |
| 2571 | 2595 |
| 2572 /** | 2596 /** |
| 2597 * Function that hides the pin keyboard. Meant to be called when the virtual | |
| 2598 * keyboard is enabled and being toggled. | |
| 2599 * @param {boolean} hidden | |
| 2600 */ | |
| 2601 setPinHidden: function(hidden) { | |
| 2602 if (hidden) { | |
| 2603 // This function gets called before the pods are loaded so we set a flag | |
| 2604 // tell the next show pin keyboard call to not show the pin keyboard. | |
| 2605 if (this.pods.length <= 0) | |
| 2606 this.dontShowPinOverride_ = true; | |
|
jdufault
2016/08/19 17:28:18
We have code that fires when the PIN keyboard is f
sammiequon
2016/08/23 17:28:12
Done.
| |
| 2607 else | |
| 2608 this.setFocusedPodPinVisibility(false); | |
| 2609 } else | |
| 2610 this.setFocusedPodPinVisibility(true); | |
|
jdufault
2016/08/19 17:28:18
need {}
sammiequon
2016/08/23 17:28:12
Removed.
| |
| 2611 }, | |
| 2612 | |
| 2613 /** | |
| 2573 * Toggles pod PIN keyboard visiblity. | 2614 * Toggles pod PIN keyboard visiblity. |
| 2574 * @param {!user} username | 2615 * @param {!user} username |
| 2575 * @param {boolean} visible | 2616 * @param {boolean} visible |
| 2576 */ | 2617 */ |
| 2577 setPinVisibility: function(username, visible) { | 2618 setPinVisibility: function(username, visible) { |
| 2578 var pod = this.getPodWithUsername_(username); | 2619 var pod = this.getPodWithUsername_(username); |
| 2579 if (!pod) { | 2620 if (!pod) { |
| 2580 console.warn('Attempt to change pin visibility to ' + visible + | 2621 console.warn('Attempt to change pin visibility to ' + visible + |
| 2581 ' for missing pod'); | 2622 ' for missing pod'); |
| 2582 return; | 2623 return; |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3117 } | 3158 } |
| 3118 } | 3159 } |
| 3119 | 3160 |
| 3120 // Clear any error messages for previous pod. | 3161 // Clear any error messages for previous pod. |
| 3121 if (!this.isFocused(podToFocus)) | 3162 if (!this.isFocused(podToFocus)) |
| 3122 Oobe.clearErrors(); | 3163 Oobe.clearErrors(); |
| 3123 | 3164 |
| 3124 var hadFocus = !!this.focusedPod_; | 3165 var hadFocus = !!this.focusedPod_; |
| 3125 this.focusedPod_ = podToFocus; | 3166 this.focusedPod_ = podToFocus; |
| 3126 if (podToFocus) { | 3167 if (podToFocus) { |
| 3127 this.setFocusedPodPinVisibility(true); | 3168 if (!hadFocus) { |
| 3169 if (!this.dontShowPinOverride_) | |
|
jdufault
2016/08/19 17:28:18
combine if statements
sammiequon
2016/08/23 17:28:12
Removed.
| |
| 3170 this.setFocusedPodPinVisibility(true); | |
| 3171 } | |
| 3128 podToFocus.classList.remove('faded'); | 3172 podToFocus.classList.remove('faded'); |
| 3129 podToFocus.classList.add('focused'); | 3173 podToFocus.classList.add('focused'); |
| 3130 if (!podToFocus.multiProfilesPolicyApplied) { | 3174 if (!podToFocus.multiProfilesPolicyApplied) { |
| 3131 podToFocus.classList.toggle('signing-in', false); | 3175 podToFocus.classList.toggle('signing-in', false); |
| 3132 if (!opt_skipInputFocus) | 3176 if (!opt_skipInputFocus) |
| 3133 podToFocus.focusInput(); | 3177 podToFocus.focusInput(); |
| 3134 } else { | 3178 } else { |
| 3135 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); | 3179 podToFocus.userTypeBubbleElement.classList.add('bubble-shown'); |
| 3136 // Note it is not necessary to skip this focus request when | 3180 // Note it is not necessary to skip this focus request when |
| 3137 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied| | 3181 // |opt_skipInputFocus| is true. When |multiProfilesPolicyApplied| |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3524 if (pod && pod.multiProfilesPolicyApplied) { | 3568 if (pod && pod.multiProfilesPolicyApplied) { |
| 3525 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3569 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3526 } | 3570 } |
| 3527 } | 3571 } |
| 3528 }; | 3572 }; |
| 3529 | 3573 |
| 3530 return { | 3574 return { |
| 3531 PodRow: PodRow | 3575 PodRow: PodRow |
| 3532 }; | 3576 }; |
| 3533 }); | 3577 }); |
| OLD | NEW |