Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 }, | 296 }, |
| 297 | 297 |
| 298 /** | 298 /** |
| 299 * Updates the user pod element. | 299 * Updates the user pod element. |
| 300 */ | 300 */ |
| 301 update: function() { | 301 update: function() { |
| 302 this.imageElement.src = 'chrome://userimage/' + this.user.username + | 302 this.imageElement.src = 'chrome://userimage/' + this.user.username + |
| 303 '?id=' + UserPod.userImageSalt_[this.user.username]; | 303 '?id=' + UserPod.userImageSalt_[this.user.username]; |
| 304 | 304 |
| 305 this.nameElement.textContent = this.user_.displayName; | 305 this.nameElement.textContent = this.user_.displayName; |
| 306 this.actionBoxAreaElement.hidden = this.user_.publicAccount; | |
| 307 this.actionBoxMenuRemoveElement.hidden = !this.user_.canRemove; | |
| 308 this.signedInIndicatorElement.hidden = !this.user_.signedIn; | 306 this.signedInIndicatorElement.hidden = !this.user_.signedIn; |
| 309 | 307 |
| 310 var needSignin = this.needGaiaSignin; | 308 var needSignin = this.needGaiaSignin; |
| 311 this.passwordElement.hidden = needSignin; | 309 this.passwordElement.hidden = needSignin; |
| 310 this.signinButtonElement.hidden = !needSignin; | |
| 311 | |
| 312 this.updateActionBoxArea(); | |
| 313 }, | |
| 314 | |
| 315 updateActionBoxArea: function() { | |
| 316 this.actionBoxAreaElement.hidden = this.user_.publicAccount; | |
| 317 this.actionBoxMenuRemoveElement.hidden = !this.user_.canRemove; | |
| 318 | |
| 312 this.actionBoxAreaElement.setAttribute( | 319 this.actionBoxAreaElement.setAttribute( |
| 313 'aria-label', loadTimeData.getStringF( | 320 'aria-label', loadTimeData.getStringF( |
| 314 'podMenuButtonAccessibleName', this.user_.emailAddress)); | 321 'podMenuButtonAccessibleName', this.user_.emailAddress)); |
| 315 this.actionBoxMenuRemoveElement.setAttribute( | 322 this.actionBoxMenuRemoveElement.setAttribute( |
| 316 'aria-label', loadTimeData.getString( | 323 'aria-label', loadTimeData.getString( |
| 317 'podMenuRemoveItemAccessibleName')); | 324 'podMenuRemoveItemAccessibleName')); |
| 318 this.actionBoxMenuTitleNameElement.textContent = this.user_.isOwner ? | 325 this.actionBoxMenuTitleNameElement.textContent = this.user_.isOwner ? |
| 319 loadTimeData.getStringF('ownerUserPattern', this.user_.displayName) : | 326 loadTimeData.getStringF('ownerUserPattern', this.user_.displayName) : |
| 320 this.user_.displayName; | 327 this.user_.displayName; |
| 321 this.actionBoxMenuTitleEmailElement.textContent = this.user_.emailAddress; | 328 this.actionBoxMenuTitleEmailElement.textContent = this.user_.emailAddress; |
| 322 this.actionBoxMenuTitleEmailElement.hidden = | 329 this.actionBoxMenuTitleEmailElement.hidden = |
| 323 this.user_.locallyManagedUser; | 330 this.user_.locallyManagedUser; |
| 324 | 331 |
| 325 this.actionBoxMenuCommandElement.textContent = | 332 this.actionBoxMenuCommandElement.textContent = |
| 326 loadTimeData.getString('removeUser'); | 333 loadTimeData.getString('removeUser'); |
| 327 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( | 334 this.passwordElement.setAttribute('aria-label', loadTimeData.getStringF( |
| 328 'passwordFieldAccessibleName', this.user_.emailAddress)); | 335 'passwordFieldAccessibleName', this.user_.emailAddress)); |
| 329 this.signinButtonElement.hidden = !needSignin; | |
| 330 this.userTypeIconAreaElement.hidden = !this.user_.locallyManagedUser; | 336 this.userTypeIconAreaElement.hidden = !this.user_.locallyManagedUser; |
| 331 }, | 337 }, |
| 332 | 338 |
| 333 /** | 339 /** |
| 334 * The user that this pod represents. | 340 * The user that this pod represents. |
| 335 * @type {!Object} | 341 * @type {!Object} |
| 336 */ | 342 */ |
| 337 user_: undefined, | 343 user_: undefined, |
| 338 get user() { | 344 get user() { |
| 339 return this.user_; | 345 return this.user_; |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 this.actionBoxMenuRemoveElement.tabIndex = -1; | 565 this.actionBoxMenuRemoveElement.tabIndex = -1; |
| 560 }, | 566 }, |
| 561 | 567 |
| 562 /** | 568 /** |
| 563 * Handles mousedown event on a user pod. | 569 * Handles mousedown event on a user pod. |
| 564 * @param {Event} e Mousedown event. | 570 * @param {Event} e Mousedown event. |
| 565 */ | 571 */ |
| 566 handleMouseDown_: function(e) { | 572 handleMouseDown_: function(e) { |
| 567 if (this.parentNode.disabled) | 573 if (this.parentNode.disabled) |
| 568 return; | 574 return; |
| 575 | |
| 569 if (!this.signinButtonElement.hidden && !this.isActionBoxMenuActive) { | 576 if (!this.signinButtonElement.hidden && !this.isActionBoxMenuActive) { |
| 570 this.showSigninUI(); | 577 this.showSigninUI(); |
| 571 // Prevent default so that we don't trigger 'focus' event. | 578 // Prevent default so that we don't trigger 'focus' event. |
| 572 e.preventDefault(); | 579 e.preventDefault(); |
| 573 } | 580 } |
| 574 } | 581 } |
| 575 }; | 582 }; |
| 576 | 583 |
| 577 /** | 584 /** |
| 578 * Creates a public account user pod. | 585 * Creates a public account user pod. |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 749 return; | 756 return; |
| 750 } | 757 } |
| 751 break; | 758 break; |
| 752 } | 759 } |
| 753 chrome.send('launchHelpApp', [HELP_TOPIC_PUBLIC_SESSION]); | 760 chrome.send('launchHelpApp', [HELP_TOPIC_PUBLIC_SESSION]); |
| 754 stopEventPropagation(event); | 761 stopEventPropagation(event); |
| 755 }, | 762 }, |
| 756 }; | 763 }; |
| 757 | 764 |
| 758 /** | 765 /** |
| 766 * Creates a user pod to be used only in desktop chrome. | |
| 767 * @constructor | |
| 768 * @extends {UserPod} | |
| 769 */ | |
| 770 var DesktopUserPod = cr.ui.define(function() { | |
| 771 // Don't just instantiate a UserPod(), as this will call decorate() on the | |
| 772 // parent object, and add duplicate event listeners. | |
| 773 var node = $('user-pod-template').cloneNode(true); | |
| 774 node.removeAttribute('id'); | |
| 775 return node; | |
| 776 }); | |
| 777 | |
| 778 DesktopUserPod.prototype = { | |
| 779 __proto__: UserPod.prototype, | |
| 780 | |
| 781 /** @override */ | |
| 782 decorate: function() { | |
| 783 UserPod.prototype.decorate.call(this); | |
| 784 }, | |
| 785 | |
| 786 /** @override */ | |
| 787 focusInput: function() { | |
| 788 var isLockedUser = this.user.needsSignin; | |
|
Nikita (slow)
2013/06/11 18:22:16
Will we have concept of locked user on Chrome desk
noms (inactive)
2013/06/11 19:39:41
Yes. Signed in users will be able to "sign out" an
| |
| 789 this.signinButtonElement.hidden = isLockedUser; | |
| 790 this.passwordElement.hidden = !isLockedUser; | |
| 791 | |
| 792 // Move tabIndex from the whole pod to the main input. | |
| 793 this.tabIndex = -1; | |
| 794 this.mainInput.tabIndex = UserPodTabOrder.POD_INPUT; | |
| 795 this.mainInput.focus(); | |
| 796 }, | |
| 797 | |
| 798 /** @override */ | |
| 799 update: function() { | |
| 800 this.imageElement.src = this.user.userImage; | |
| 801 this.nameElement.textContent = this.user_.displayName; | |
| 802 var isLockedUser = this.user.needsSignin; | |
| 803 this.passwordElement.hidden = !isLockedUser; | |
| 804 this.signinButtonElement.hidden = isLockedUser; | |
| 805 | |
| 806 UserPod.prototype.updateActionBoxArea.call(this); | |
| 807 }, | |
| 808 | |
| 809 /** @override */ | |
| 810 activate: function() { | |
| 811 Oobe.launchUser(this.user.emailAddress, this.user.displayName); | |
| 812 return true; | |
| 813 }, | |
| 814 | |
| 815 /** @override */ | |
| 816 handleMouseDown_: function(e) { | |
| 817 if (this.parentNode.disabled) | |
| 818 return; | |
| 819 | |
| 820 // Don't sign in until the user presses the button. Just activate the pod. | |
| 821 Oobe.clearErrors(); | |
| 822 this.disabled = true; | |
|
Nikita (slow)
2013/06/11 18:22:16
Why user pod is disabled?
noms
2013/06/12 20:41:54
I copied the code from the standard user pod, but
| |
| 823 this.parentNode.lastFocusedPod_ = | |
| 824 this.parentNode.getPodWithUsername_(this.user.emailAddress); | |
| 825 }, | |
| 826 | |
| 827 /** @override */ | |
| 828 handleRemoveCommandClick_: function(e) { | |
| 829 //TODO(noms): Add deletion confirmation overlay before attempting | |
| 830 // to delete the user. | |
| 831 UserPod.prototype.handleRemoveCommandClick_.call(this, e); | |
| 832 | |
|
Nikita (slow)
2013/06/11 18:22:16
nit: drop empty line
noms
2013/06/12 20:41:54
Done.
| |
| 833 }, | |
| 834 }; | |
| 835 | |
| 836 /** | |
| 759 * Creates a new pod row element. | 837 * Creates a new pod row element. |
| 760 * @constructor | 838 * @constructor |
| 761 * @extends {HTMLDivElement} | 839 * @extends {HTMLDivElement} |
| 762 */ | 840 */ |
| 763 var PodRow = cr.ui.define('podrow'); | 841 var PodRow = cr.ui.define('podrow'); |
| 764 | 842 |
| 765 PodRow.prototype = { | 843 PodRow.prototype = { |
| 766 __proto__: HTMLDivElement.prototype, | 844 __proto__: HTMLDivElement.prototype, |
| 767 | 845 |
| 768 // Whether this user pod row is shown for the first time. | 846 // Whether this user pod row is shown for the first time. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 854 control.disabled = value; | 932 control.disabled = value; |
| 855 } | 933 } |
| 856 }, | 934 }, |
| 857 | 935 |
| 858 /** | 936 /** |
| 859 * Creates a user pod from given email. | 937 * Creates a user pod from given email. |
| 860 * @param {string} email User's email. | 938 * @param {string} email User's email. |
| 861 */ | 939 */ |
| 862 createUserPod: function(user) { | 940 createUserPod: function(user) { |
| 863 var userPod; | 941 var userPod; |
| 864 if (user.publicAccount) | 942 if (user.isDesktopScreen) |
|
Nikita (slow)
2013/06/11 18:22:16
nit: isDesktopScreen is property of a user but is
noms
2013/06/12 20:41:54
Done.
| |
| 943 userPod = new DesktopUserPod({user: user}); | |
| 944 else if (user.publicAccount) | |
| 865 userPod = new PublicAccountUserPod({user: user}); | 945 userPod = new PublicAccountUserPod({user: user}); |
| 866 else | 946 else |
| 867 userPod = new UserPod({user: user}); | 947 userPod = new UserPod({user: user}); |
| 868 | 948 |
| 869 userPod.hidden = false; | 949 userPod.hidden = false; |
| 870 return userPod; | 950 return userPod; |
| 871 }, | 951 }, |
| 872 | 952 |
| 873 /** | 953 /** |
| 874 * Add an existing user pod to this pod row. | 954 * Add an existing user pod to this pod row. |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1403 this.classList.remove('images-loading'); | 1483 this.classList.remove('images-loading'); |
| 1404 chrome.send('userImagesLoaded'); | 1484 chrome.send('userImagesLoaded'); |
| 1405 } | 1485 } |
| 1406 } | 1486 } |
| 1407 }; | 1487 }; |
| 1408 | 1488 |
| 1409 return { | 1489 return { |
| 1410 PodRow: PodRow | 1490 PodRow: PodRow |
| 1411 }; | 1491 }; |
| 1412 }); | 1492 }); |
| OLD | NEW |