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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 * synced with computed CSS sizes of pods. | 49 * synced with computed CSS sizes of pods. |
| 50 */ | 50 */ |
| 51 var CROS_POD_WIDTH = 180; | 51 var CROS_POD_WIDTH = 180; |
| 52 var DESKTOP_POD_WIDTH = 180; | 52 var DESKTOP_POD_WIDTH = 180; |
| 53 var MD_DESKTOP_POD_WIDTH = 160; | 53 var MD_DESKTOP_POD_WIDTH = 160; |
| 54 var PUBLIC_EXPANDED_BASIC_WIDTH = 500; | 54 var PUBLIC_EXPANDED_BASIC_WIDTH = 500; |
| 55 var PUBLIC_EXPANDED_ADVANCED_WIDTH = 610; | 55 var PUBLIC_EXPANDED_ADVANCED_WIDTH = 610; |
| 56 var CROS_POD_HEIGHT = 213; | 56 var CROS_POD_HEIGHT = 213; |
| 57 var DESKTOP_POD_HEIGHT = 226; | 57 var DESKTOP_POD_HEIGHT = 226; |
| 58 var MD_DESKTOP_POD_HEIGHT = 200; | 58 var MD_DESKTOP_POD_HEIGHT = 200; |
| 59 var POD_ROW_PADDING = 10; | 59 var POD_ROW_PADDING = 0; |
|
jdufault
2016/05/31 19:24:52
Have you tested this with multiple pods? We probab
| |
| 60 var DESKTOP_ROW_PADDING = 32; | 60 var DESKTOP_ROW_PADDING = 32; |
| 61 var CUSTOM_ICON_CONTAINER_SIZE = 40; | 61 var CUSTOM_ICON_CONTAINER_SIZE = 40; |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * Minimal padding between user pod and virtual keyboard. | 64 * Minimal padding between user pod and virtual keyboard. |
| 65 * @type {number} | 65 * @type {number} |
| 66 * @const | 66 * @const |
| 67 */ | 67 */ |
| 68 var USER_POD_KEYBOARD_MIN_PADDING = 20; | 68 var USER_POD_KEYBOARD_MIN_PADDING = 20; |
| 69 | 69 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 } | 148 } |
| 149 | 149 |
| 150 /** | 150 /** |
| 151 * Creates a user pod. | 151 * Creates a user pod. |
| 152 * @constructor | 152 * @constructor |
| 153 * @extends {HTMLDivElement} | 153 * @extends {HTMLDivElement} |
| 154 */ | 154 */ |
| 155 var UserPod = cr.ui.define(function() { | 155 var UserPod = cr.ui.define(function() { |
| 156 var node = $('user-pod-template').cloneNode(true); | 156 var node = $('user-pod-template').cloneNode(true); |
| 157 node.removeAttribute('id'); | 157 node.removeAttribute('id'); |
| 158 | |
|
jdufault
2016/05/31 19:24:52
Remove extraneous lines.
sammiequon
2016/06/14 22:22:22
Done.
| |
| 159 | |
| 158 return node; | 160 return node; |
| 159 }); | 161 }); |
| 160 | 162 |
| 161 /** | 163 /** |
| 162 * Stops event propagation from the any user pod child element. | 164 * Stops event propagation from the any user pod child element. |
| 163 * @param {Event} e Event to handle. | 165 * @param {Event} e Event to handle. |
| 164 */ | 166 */ |
| 165 function stopEventPropagation(e) { | 167 function stopEventPropagation(e) { |
| 166 // Prevent default so that we don't trigger a 'focus' event. | 168 // Prevent default so that we don't trigger a 'focus' event. |
| 167 e.preventDefault(); | 169 e.preventDefault(); |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 725 this.handleRemoveCommandKeyDown_.bind(this)); | 727 this.handleRemoveCommandKeyDown_.bind(this)); |
| 726 this.actionBoxMenuRemoveElement.addEventListener('blur', | 728 this.actionBoxMenuRemoveElement.addEventListener('blur', |
| 727 this.handleRemoveCommandBlur_.bind(this)); | 729 this.handleRemoveCommandBlur_.bind(this)); |
| 728 this.actionBoxRemoveUserWarningButtonElement.addEventListener( | 730 this.actionBoxRemoveUserWarningButtonElement.addEventListener( |
| 729 'click', | 731 'click', |
| 730 this.handleRemoveUserConfirmationClick_.bind(this)); | 732 this.handleRemoveUserConfirmationClick_.bind(this)); |
| 731 this.actionBoxRemoveUserWarningButtonElement.addEventListener( | 733 this.actionBoxRemoveUserWarningButtonElement.addEventListener( |
| 732 'keydown', | 734 'keydown', |
| 733 this.handleRemoveUserConfirmationKeyDown_.bind(this)); | 735 this.handleRemoveUserConfirmationKeyDown_.bind(this)); |
| 734 | 736 |
| 735 var pinKeyboard = $('pin-keyboard'); | |
| 736 // The pin keyboard is not present on the md user manager. | |
| 737 if (pinKeyboard) { | |
| 738 pinKeyboard.addEventListener('submit', | |
| 739 this.handlePinSubmitted_.bind(this)); | |
| 740 } | |
| 741 | 737 |
| 742 var customIcon = this.customIconElement; | 738 var customIcon = this.customIconElement; |
| 743 customIcon.parentNode.replaceChild(new UserPodCustomIcon(), customIcon); | 739 customIcon.parentNode.replaceChild(new UserPodCustomIcon(), customIcon); |
| 744 }, | 740 }, |
| 745 | 741 |
| 746 /** | 742 /** |
| 747 * 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. |
| 748 */ | 744 */ |
| 749 initialize: function() { | 745 initialize: function() { |
| 750 this.passwordElement.addEventListener('keydown', | 746 this.passwordElement.addEventListener('keydown', |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 771 this.tabIndex = UserPodTabOrder.POD_INPUT; | 767 this.tabIndex = UserPodTabOrder.POD_INPUT; |
| 772 }, | 768 }, |
| 773 | 769 |
| 774 /** | 770 /** |
| 775 * Handles the user hitting 'submit' on the PIN keyboard. | 771 * Handles the user hitting 'submit' on the PIN keyboard. |
| 776 * @param {Event} e Submit event object. | 772 * @param {Event} e Submit event object. |
| 777 * @private | 773 * @private |
| 778 */ | 774 */ |
| 779 handlePinSubmitted_: function(e) { | 775 handlePinSubmitted_: function(e) { |
| 780 var pin = e.detail.pin; | 776 var pin = e.detail.pin; |
| 781 chrome.send('authenticateUserWithPin', [this.user.username, pin]); | 777 chrome.send('authenticateUser', [this.user.username, pin]); |
|
jdufault
2016/05/31 19:24:52
Drop this change, it is handled in a different CL.
| |
| 782 }, | 778 }, |
| 783 | 779 |
| 784 /** | 780 /** |
| 785 * Handles keypress event (i.e. any textual input) on password input. | 781 * Handles keypress event (i.e. any textual input) on password input. |
| 786 * @param {Event} e Keypress Event object. | 782 * @param {Event} e Keypress Event object. |
| 787 * @private | 783 * @private |
| 788 */ | 784 */ |
| 789 handlePasswordKeyPress_: function(e) { | 785 handlePasswordKeyPress_: function(e) { |
| 790 // When tabbing from the system tray a tab key press is received. Suppress | 786 // When tabbing from the system tray a tab key press is received. Suppress |
| 791 // this so as not to type a tab character into the password field. | 787 // this so as not to type a tab character into the password field. |
| (...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2425 var userPod; | 2421 var userPod; |
| 2426 if (user.isDesktopUser) | 2422 if (user.isDesktopUser) |
| 2427 userPod = new DesktopUserPod({user: user}); | 2423 userPod = new DesktopUserPod({user: user}); |
| 2428 else if (user.publicAccount) | 2424 else if (user.publicAccount) |
| 2429 userPod = new PublicAccountUserPod({user: user}); | 2425 userPod = new PublicAccountUserPod({user: user}); |
| 2430 else if (user.isApp) | 2426 else if (user.isApp) |
| 2431 userPod = new KioskAppPod({user: user}); | 2427 userPod = new KioskAppPod({user: user}); |
| 2432 else | 2428 else |
| 2433 userPod = new UserPod({user: user}); | 2429 userPod = new UserPod({user: user}); |
| 2434 | 2430 |
| 2431 var pinKeyboard = userPod.getElementsByTagName('pin-keyboard'); | |
| 2432 | |
| 2433 var handlePinSubmitted_ = function(e) { | |
| 2434 var pin = e.detail.pin; | |
| 2435 // TODO: hardcode this.user.username | |
|
jdufault
2016/05/31 19:24:52
Remove TODO?
sammiequon
2016/06/14 22:22:22
Done.
| |
| 2436 chrome.send('authenticateUser', [user.username, pin]); | |
| 2437 } | |
| 2438 | |
| 2439 // The pin keyboard is not present on the md user manager. | |
| 2440 if (pinKeyboard && pinKeyboard.length > 0) { | |
| 2441 pinKeyboard[0].addEventListener('submit', | |
|
jdufault
2016/05/31 19:24:52
Can we add the event listener directly to the |use
sammiequon
2016/06/14 22:22:22
Done.
| |
| 2442 handlePinSubmitted_.bind(this)); | |
| 2443 } | |
| 2444 | |
| 2445 | |
| 2435 userPod.hidden = false; | 2446 userPod.hidden = false; |
| 2436 return userPod; | 2447 return userPod; |
| 2437 }, | 2448 }, |
| 2438 | 2449 |
| 2439 /** | 2450 /** |
| 2440 * Add an existing user pod to this pod row. | 2451 * Add an existing user pod to this pod row. |
| 2441 * @param {!Object} user User info dictionary. | 2452 * @param {!Object} user User info dictionary. |
| 2442 */ | 2453 */ |
| 2443 addUserPod: function(user) { | 2454 addUserPod: function(user) { |
| 2444 var userPod = this.createUserPod(user); | 2455 var userPod = this.createUserPod(user); |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3360 if (pod && pod.multiProfilesPolicyApplied) { | 3371 if (pod && pod.multiProfilesPolicyApplied) { |
| 3361 pod.userTypeBubbleElement.classList.remove('bubble-shown'); | 3372 pod.userTypeBubbleElement.classList.remove('bubble-shown'); |
| 3362 } | 3373 } |
| 3363 } | 3374 } |
| 3364 }; | 3375 }; |
| 3365 | 3376 |
| 3366 return { | 3377 return { |
| 3367 PodRow: PodRow | 3378 PodRow: PodRow |
| 3368 }; | 3379 }; |
| 3369 }); | 3380 }); |
| OLD | NEW |