| 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 // True if user pod has been activated with keyboard. | 419 // True if user pod has been activated with keyboard. |
| 420 // In case of activation with keyboard we delay wallpaper change. | 420 // In case of activation with keyboard we delay wallpaper change. |
| 421 keyboardActivated_: false, | 421 keyboardActivated_: false, |
| 422 | 422 |
| 423 // Focused pod. | 423 // Focused pod. |
| 424 focusedPod_: undefined, | 424 focusedPod_: undefined, |
| 425 | 425 |
| 426 // Activated pod, i.e. the pod of current login attempt. | 426 // Activated pod, i.e. the pod of current login attempt. |
| 427 activatedPod_: undefined, | 427 activatedPod_: undefined, |
| 428 | 428 |
| 429 // Pod that was most recently focused, if any. |
| 430 lastFocusedPod_: undefined, |
| 431 |
| 429 // When moving through users quickly at login screen, set a timeout to | 432 // When moving through users quickly at login screen, set a timeout to |
| 430 // prevent loading intermediate wallpapers. | 433 // prevent loading intermediate wallpapers. |
| 431 loadWallpaperTimeout_: null, | 434 loadWallpaperTimeout_: null, |
| 432 | 435 |
| 433 // Pods whose initial images haven't been loaded yet. | 436 // Pods whose initial images haven't been loaded yet. |
| 434 podsWithPendingImages_: [], | 437 podsWithPendingImages_: [], |
| 435 | 438 |
| 436 /** @inheritDoc */ | 439 /** @inheritDoc */ |
| 437 decorate: function() { | 440 decorate: function() { |
| 438 this.style.left = 0; | 441 this.style.left = 0; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 /** | 592 /** |
| 590 * Populates pod row with given existing users and start init animation. | 593 * Populates pod row with given existing users and start init animation. |
| 591 * @param {array} users Array of existing user emails. | 594 * @param {array} users Array of existing user emails. |
| 592 * @param {boolean} animated Whether to use init animation. | 595 * @param {boolean} animated Whether to use init animation. |
| 593 */ | 596 */ |
| 594 loadPods: function(users, animated) { | 597 loadPods: function(users, animated) { |
| 595 // Clear existing pods. | 598 // Clear existing pods. |
| 596 this.innerHTML = ''; | 599 this.innerHTML = ''; |
| 597 this.focusedPod_ = undefined; | 600 this.focusedPod_ = undefined; |
| 598 this.activatedPod_ = undefined; | 601 this.activatedPod_ = undefined; |
| 602 this.lastFocusedPod_ = undefined; |
| 599 | 603 |
| 600 // Populate the pod row. | 604 // Populate the pod row. |
| 601 for (var i = 0; i < users.length; ++i) { | 605 for (var i = 0; i < users.length; ++i) { |
| 602 this.addUserPod(users[i], animated); | 606 this.addUserPod(users[i], animated); |
| 603 } | 607 } |
| 604 for (var i = 0, pod; pod = this.pods[i]; ++i) { | 608 for (var i = 0, pod; pod = this.pods[i]; ++i) { |
| 605 this.podsWithPendingImages_.push(pod); | 609 this.podsWithPendingImages_.push(pod); |
| 606 } | 610 } |
| 607 // Make sure we eventually show the pod row, even if some image is stuck. | 611 // Make sure we eventually show the pod row, even if some image is stuck. |
| 608 setTimeout(function() { | 612 setTimeout(function() { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 if (hadFocus && this.keyboardActivated_) { | 664 if (hadFocus && this.keyboardActivated_) { |
| 661 // Delay wallpaper loading to let user tab through pods without lag. | 665 // Delay wallpaper loading to let user tab through pods without lag. |
| 662 this.loadWallpaperTimeout_ = window.setTimeout( | 666 this.loadWallpaperTimeout_ = window.setTimeout( |
| 663 this.loadWallpaper_.bind(this), WALLPAPER_LOAD_DELAY_MS); | 667 this.loadWallpaper_.bind(this), WALLPAPER_LOAD_DELAY_MS); |
| 664 } else if (!this.firstShown_) { | 668 } else if (!this.firstShown_) { |
| 665 // Load wallpaper immediately if there no pod was focused | 669 // Load wallpaper immediately if there no pod was focused |
| 666 // previously, and it is not a boot into user pod list case. | 670 // previously, and it is not a boot into user pod list case. |
| 667 this.loadWallpaper_(); | 671 this.loadWallpaper_(); |
| 668 } | 672 } |
| 669 this.firstShown_ = false; | 673 this.firstShown_ = false; |
| 670 } else { | 674 this.lastFocusedPod_ = podToFocus; |
| 671 chrome.send('userDeselected'); | |
| 672 } | 675 } |
| 673 this.insideFocusPod_ = false; | 676 this.insideFocusPod_ = false; |
| 674 this.keyboardActivated_ = false; | 677 this.keyboardActivated_ = false; |
| 675 }, | 678 }, |
| 676 | 679 |
| 680 /** |
| 681 * Loads wallpaper for the active user pod, if any. |
| 682 * @private |
| 683 */ |
| 677 loadWallpaper_: function() { | 684 loadWallpaper_: function() { |
| 678 if (this.focusedPod_) | 685 if (this.focusedPod_) |
| 679 chrome.send('userSelectedDelayed', [this.focusedPod_.user.username]); | 686 chrome.send('loadWallpaper', [this.focusedPod_.user.username]); |
| 680 }, | 687 }, |
| 681 | 688 |
| 682 /** | 689 /** |
| 690 * Resets wallpaper to the last active user's wallpaper, if any. |
| 691 */ |
| 692 loadLastWallpaper: function() { |
| 693 if (this.lastFocusedPod_) |
| 694 chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); |
| 695 }, |
| 696 |
| 697 /** |
| 683 * Returns the currently activated pod. | 698 * Returns the currently activated pod. |
| 684 * @type {UserPod} | 699 * @type {UserPod} |
| 685 */ | 700 */ |
| 686 get activatedPod() { | 701 get activatedPod() { |
| 687 return this.activatedPod_; | 702 return this.activatedPod_; |
| 688 }, | 703 }, |
| 689 set activatedPod(pod) { | 704 set activatedPod(pod) { |
| 690 if (pod && pod.activate()) | 705 if (pod && pod.activate()) |
| 691 this.activatedPod_ = pod; | 706 this.activatedPod_ = pod; |
| 692 }, | 707 }, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 }, | 740 }, |
| 726 | 741 |
| 727 /** | 742 /** |
| 728 * Shows signin UI. | 743 * Shows signin UI. |
| 729 * @param {string} email Email for signin UI. | 744 * @param {string} email Email for signin UI. |
| 730 */ | 745 */ |
| 731 showSigninUI: function(email) { | 746 showSigninUI: function(email) { |
| 732 // Clear any error messages that might still be around. | 747 // Clear any error messages that might still be around. |
| 733 Oobe.clearErrors(); | 748 Oobe.clearErrors(); |
| 734 this.disabled = true; | 749 this.disabled = true; |
| 750 this.lastFocusedPod_ = this.getPodWithUsername_(email); |
| 735 Oobe.showSigninUI(email); | 751 Oobe.showSigninUI(email); |
| 736 }, | 752 }, |
| 737 | 753 |
| 738 /** | 754 /** |
| 739 * Updates current image of a user. | 755 * Updates current image of a user. |
| 740 * @param {string} username User for which to update the image. | 756 * @param {string} username User for which to update the image. |
| 741 */ | 757 */ |
| 742 updateUserImage: function(username) { | 758 updateUserImage: function(username) { |
| 743 var pod = this.getPodWithUsername_(username); | 759 var pod = this.getPodWithUsername_(username); |
| 744 if (pod) | 760 if (pod) |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 this.classList.remove('images-loading'); | 926 this.classList.remove('images-loading'); |
| 911 chrome.send('userImagesLoaded'); | 927 chrome.send('userImagesLoaded'); |
| 912 } | 928 } |
| 913 } | 929 } |
| 914 }; | 930 }; |
| 915 | 931 |
| 916 return { | 932 return { |
| 917 PodRow: PodRow | 933 PodRow: PodRow |
| 918 }; | 934 }; |
| 919 }); | 935 }); |
| OLD | NEW |