Index: chrome/browser/resources/chromeos/login/user_pod_row.js |
diff --git a/chrome/browser/resources/chromeos/login/user_pod_row.js b/chrome/browser/resources/chromeos/login/user_pod_row.js |
index 7969895a095c6c517b9d7d119978dcbb514bce38..773e22d2f0770efb92367c4d296f2bddad16b29c 100644 |
--- a/chrome/browser/resources/chromeos/login/user_pod_row.js |
+++ b/chrome/browser/resources/chromeos/login/user_pod_row.js |
@@ -2,6 +2,8 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+<include src="wallpaper_loader.js"></include> |
dzhioev (left Google)
2013/10/22 00:01:19
As I know, closing tag is not needed.
Alexander Alekseev
2013/10/22 11:33:37
Nevertheless it seems it's always used with closin
|
+ |
/** |
* @fileoverview User pod row implementation. |
*/ |
@@ -22,20 +24,6 @@ cr.define('login', function() { |
var PRESELECT_FIRST_POD = true; |
/** |
- * Wallpaper load delay in milliseconds. |
- * @type {number} |
- * @const |
- */ |
- var WALLPAPER_LOAD_DELAY_MS = 500; |
- |
- /** |
- * Wallpaper load delay in milliseconds. TODO(nkostylev): Tune this constant. |
- * @type {number} |
- * @const |
- */ |
- var WALLPAPER_BOOT_LOAD_DELAY_MS = 100; |
- |
- /** |
* Maximum time for which the pod row remains hidden until all user images |
* have been loaded. |
* @type {number} |
@@ -959,17 +947,9 @@ cr.define('login', function() { |
// Whether this user pod row is shown for the first time. |
firstShown_: true, |
- // Whether the initial wallpaper load after boot has been requested. Used |
- // only if |Oobe.getInstance().shouldLoadWallpaperOnBoot()| is true. |
- bootWallpaperLoaded_: false, |
- |
// True if inside focusPod(). |
insideFocusPod_: false, |
- // True if user pod has been activated with keyboard. |
- // In case of activation with keyboard we delay wallpaper change. |
- keyboardActivated_: false, |
- |
// Focused pod. |
focusedPod_: undefined, |
@@ -979,9 +959,8 @@ cr.define('login', function() { |
// Pod that was most recently focused, if any. |
lastFocusedPod_: undefined, |
- // When moving through users quickly at login screen, set a timeout to |
- // prevent loading intermediate wallpapers. |
- loadWallpaperTimeout_: null, |
+ // Note: created only in decorate() ! |
+ wallpaperLoader_: undefined, |
// Pods whose initial images haven't been loaded yet. |
podsWithPendingImages_: [], |
@@ -998,6 +977,7 @@ cr.define('login', function() { |
mousemove: [this.handleMouseMove_.bind(this), false], |
keydown: [this.handleKeyDown.bind(this), false] |
}; |
+ this.wallpaperLoader_ = new login.WallpaperLoader(); |
}, |
/** |
@@ -1242,7 +1222,7 @@ cr.define('login', function() { |
} |
this.insideFocusPod_ = true; |
- clearTimeout(this.loadWallpaperTimeout_); |
+ this.wallpaperLoader_.reset(); |
for (var i = 0, pod; pod = this.pods[i]; ++i) { |
if (!this.isSinglePod) { |
pod.isActionBoxMenuActive = false; |
@@ -1266,15 +1246,8 @@ cr.define('login', function() { |
podToFocus.classList.add('focused'); |
podToFocus.reset(true); // Reset and give focus. |
chrome.send('focusPod', [podToFocus.user.emailAddress]); |
- if (hadFocus && this.keyboardActivated_) { |
- // Delay wallpaper loading to let user tab through pods without lag. |
- this.loadWallpaperTimeout_ = window.setTimeout( |
- this.loadWallpaper_.bind(this), WALLPAPER_LOAD_DELAY_MS); |
- } else if (!this.firstShown_) { |
- // Load wallpaper immediately if there no pod was focused |
- // previously, and it is not a boot into user pod list case. |
- this.loadWallpaper_(); |
- } |
+ |
+ this.wallpaperLoader_.scheduleLoad(podToFocus.user.emailAddress); |
this.firstShown_ = false; |
this.lastFocusedPod_ = podToFocus; |
} |
@@ -1283,20 +1256,19 @@ cr.define('login', function() { |
}, |
/** |
- * Loads wallpaper for the active user pod, if any. |
- * @private |
+ * Resets wallpaper to the last active user's wallpaper, if any. |
*/ |
- loadWallpaper_: function() { |
- if (this.focusedPod_) |
- chrome.send('loadWallpaper', [this.focusedPod_.user.username]); |
+ loadLastWallpaper: function() { |
+ if (this.lastFocusedPod_) |
+ this.wallpaperLoader_.scheduleLoad(this.lastFocusedPod_.user.username); |
}, |
/** |
- * Resets wallpaper to the last active user's wallpaper, if any. |
+ * Handles 'onWallpaperLoaded' event. Recalculates statistics and |
+ * [re]schedules next wallpaper load. |
*/ |
- loadLastWallpaper: function() { |
- if (this.lastFocusedPod_) |
- chrome.send('loadWallpaper', [this.lastFocusedPod_.user.username]); |
+ onWallpaperLoaded: function(email) { |
+ this.wallpaperLoader_.onWallpaperLoaded(email); |
}, |
/** |
@@ -1560,13 +1532,7 @@ cr.define('login', function() { |
focusedPod.reset(true); |
// Notify screen that it is ready. |
screen.onShow(); |
- // Boot transition: load wallpaper. |
- if (!self.bootWallpaperLoaded_ && |
- Oobe.getInstance().shouldLoadWallpaperOnBoot()) { |
- self.loadWallpaperTimeout_ = window.setTimeout( |
- self.loadWallpaper_.bind(self), WALLPAPER_BOOT_LOAD_DELAY_MS); |
- self.bootWallpaperLoaded_ = true; |
- } |
+ self.wallpaperLoader_.scheduleLoad(focusedPod.user.username); |
} |
}); |
} |