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 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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} | |
| 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 Loading... | |
| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1087 this.querySelector('.mp-policy-primary-only-msg').hidden = false; | 1117 this.querySelector('.mp-policy-primary-only-msg').hidden = false; |
| 1088 else if (this.user.multiProfilesPolicy == 'owner-primary-only') | 1118 else if (this.user.multiProfilesPolicy == 'owner-primary-only') |
| 1089 this.querySelector('.mp-owner-primary-only-msg').hidden = false; | 1119 this.querySelector('.mp-owner-primary-only-msg').hidden = false; |
| 1090 else | 1120 else |
| 1091 this.querySelector('.mp-policy-not-allowed-msg').hidden = false; | 1121 this.querySelector('.mp-policy-not-allowed-msg').hidden = false; |
| 1092 } else if (this.user_.isApp) { | 1122 } else if (this.user_.isApp) { |
| 1093 this.setUserPodIconType('app'); | 1123 this.setUserPodIconType('app'); |
| 1094 } | 1124 } |
| 1095 }, | 1125 }, |
| 1096 | 1126 |
| 1127 setPinVisibility: function(visible) { | |
| 1128 var elements = [this, this.authElement, this.imageElement, | |
| 1129 this.signInElement, this.pinContainer]; | |
| 1130 | |
| 1131 for (var idx = 0; idx < elements.length; idx++) { | |
| 1132 var currentElement = elements[idx]; | |
| 1133 if (visible) { | |
| 1134 currentElement.classList.add('pin-enabled'); | |
| 1135 currentElement.classList.remove('pin-disabled'); | |
| 1136 } | |
| 1137 else { | |
|
xiyuan
2016/06/24 21:19:09
nit: move it to line 1136
sammiequon
2016/06/24 22:06:39
Done.
| |
| 1138 currentElement.classList.remove('pin-enabled'); | |
| 1139 currentElement.classList.add('pin-disabled'); | |
|
xiyuan
2016/06/24 21:19:10
nit: we replace the if with:
currentElement.class
sammiequon
2016/06/24 22:06:39
Done.
| |
| 1140 } | |
| 1141 } | |
| 1142 }, | |
| 1143 | |
| 1097 setUserPodIconType: function(userTypeClass) { | 1144 setUserPodIconType: function(userTypeClass) { |
| 1098 this.userTypeIconAreaElement.classList.add(userTypeClass); | 1145 this.userTypeIconAreaElement.classList.add(userTypeClass); |
| 1099 this.userTypeIconAreaElement.hidden = false; | 1146 this.userTypeIconAreaElement.hidden = false; |
| 1100 }, | 1147 }, |
| 1101 | 1148 |
| 1102 /** | 1149 /** |
| 1103 * The user that this pod represents. | 1150 * The user that this pod represents. |
| 1104 * @type {!Object} | 1151 * @type {!Object} |
| 1105 */ | 1152 */ |
| 1106 user_: undefined, | 1153 user_: undefined, |
| (...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2503 /** | 2550 /** |
| 2504 * Add an existing user pod to this pod row. | 2551 * Add an existing user pod to this pod row. |
| 2505 * @param {!Object} user User info dictionary. | 2552 * @param {!Object} user User info dictionary. |
| 2506 */ | 2553 */ |
| 2507 addUserPod: function(user) { | 2554 addUserPod: function(user) { |
| 2508 var userPod = this.createUserPod(user); | 2555 var userPod = this.createUserPod(user); |
| 2509 this.appendChild(userPod); | 2556 this.appendChild(userPod); |
| 2510 userPod.initialize(); | 2557 userPod.initialize(); |
| 2511 }, | 2558 }, |
| 2512 | 2559 |
| 2560 setFocusedPodPinVisibility: function(visible) { | |
| 2561 if (this.focusedPod_ && this.focusedPod_.user.showPin) | |
| 2562 this.focusedPod_.setPinVisibility(visible); | |
| 2563 }, | |
| 2564 | |
| 2513 /** | 2565 /** |
| 2514 * Runs app with a given id from the list of loaded apps. | 2566 * Runs app with a given id from the list of loaded apps. |
| 2515 * @param {!string} app_id of an app to run. | 2567 * @param {!string} app_id of an app to run. |
| 2516 * @param {boolean=} opt_diagnosticMode Whether to run the app in | 2568 * @param {boolean=} opt_diagnosticMode Whether to run the app in |
| 2517 * diagnostic mode. Default is false. | 2569 * diagnostic mode. Default is false. |
| 2518 */ | 2570 */ |
| 2519 findAndRunAppForTesting: function(app_id, opt_diagnosticMode) { | 2571 findAndRunAppForTesting: function(app_id, opt_diagnosticMode) { |
| 2520 var app = this.getPodWithAppId_(app_id); | 2572 var app = this.getPodWithAppId_(app_id); |
| 2521 if (app) { | 2573 if (app) { |
| 2522 var activationEvent = cr.doc.createEvent('MouseEvents'); | 2574 var activationEvent = cr.doc.createEvent('MouseEvents'); |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3427 if (pod && pod.multiProfilesPolicyApplied) { | 3479 if (pod && pod.multiProfilesPolicyApplied) { |
| 3428 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3480 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3429 } | 3481 } |
| 3430 } | 3482 } |
| 3431 }; | 3483 }; |
| 3432 | 3484 |
| 3433 return { | 3485 return { |
| 3434 PodRow: PodRow | 3486 PodRow: PodRow |
| 3435 }; | 3487 }; |
| 3436 }); | 3488 }); |
| OLD | NEW |