Index: chrome/browser/chromeos/login/wallpaper_manager.cc |
=================================================================== |
--- chrome/browser/chromeos/login/wallpaper_manager.cc (revision 150736) |
+++ chrome/browser/chromeos/login/wallpaper_manager.cc (working copy) |
@@ -17,7 +17,6 @@ |
#include "base/time.h" |
#include "base/values.h" |
#include "chrome/browser/browser_process.h" |
-#include "chrome/browser/chromeos/login/user.h" |
#include "chrome/browser/chromeos/login/user_manager.h" |
#include "chrome/browser/chromeos/login/wizard_controller.h" |
#include "chrome/browser/chromeos/settings/cros_settings.h" |
@@ -48,8 +47,6 @@ |
const int kThumbnailWidth = 128; |
const int kThumbnailHeight = 80; |
-const int kCacheWallpaperDelayMs = 500; |
- |
// Default wallpaper index used in OOBE (first boot). |
// Defined here because Chromium default index differs. |
// Also see ash::WallpaperInfo kDefaultWallpapers in |
@@ -86,18 +83,11 @@ |
current_user_wallpaper_type_(User::UNKNOWN), |
ALLOW_THIS_IN_INITIALIZER_LIST(current_user_wallpaper_index_( |
ash::GetInvalidWallpaperIndex())), |
- should_cache_wallpaper_(false), |
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
RestartTimer(); |
registrar_.Add(this, |
chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
content::NotificationService::AllSources()); |
- registrar_.Add(this, |
- chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, |
- content::NotificationService::AllSources()); |
- registrar_.Add(this, |
- chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED, |
- content::NotificationService::AllSources()); |
} |
// static |
@@ -112,6 +102,21 @@ |
system::TimezoneSettings::GetInstance()->AddObserver(this); |
} |
+void WallpaperManager::CacheIfCustomWallpaper(const std::string& email) { |
+ User::WallpaperType type; |
+ int index; |
+ base::Time date; |
+ GetUserWallpaperProperties(email, &type, &index, &date); |
+ if (type == User::CUSTOMIZED) { |
+ std::string wallpaper_path = GetWallpaperPathForUser(email, false).value(); |
+ |
+ // Uses WeakPtr here to make the request cancelable. |
+ wallpaper_loader_->Start(wallpaper_path, 0, |
+ base::Bind(&WallpaperManager::CacheWallpaper, |
+ weak_factory_.GetWeakPtr(), email)); |
+ } |
+} |
+ |
void WallpaperManager::EnsureLoggedInUserWallpaperLoaded() { |
User::WallpaperType type; |
int index; |
@@ -240,39 +245,10 @@ |
const content::NotificationSource& source, |
const content::NotificationDetails& details) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- switch (type) { |
- case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { |
- // Cancel callback for previous cache requests. |
- weak_factory_.InvalidateWeakPtrs(); |
- custom_wallpaper_cache_.clear(); |
- break; |
- } |
- case chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE: { |
- if (!CommandLine::ForCurrentProcess()-> |
- HasSwitch(switches::kDisableBootAnimation)) { |
- BrowserThread::PostDelayedTask( |
- BrowserThread::UI, FROM_HERE, |
- base::Bind(&WallpaperManager::CacheAllUsersWallpapers, |
- weak_factory_.GetWeakPtr()), |
- base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); |
- } else { |
- should_cache_wallpaper_ = true; |
- } |
- break; |
- } |
- case chrome::NOTIFICATION_WALLPAPER_ANIMATION_FINISHED: { |
- if (should_cache_wallpaper_) { |
- BrowserThread::PostDelayedTask( |
- BrowserThread::UI, FROM_HERE, |
- base::Bind(&WallpaperManager::CacheAllUsersWallpapers, |
- weak_factory_.GetWeakPtr()), |
- base::TimeDelta::FromMilliseconds(kCacheWallpaperDelayMs)); |
- should_cache_wallpaper_ = false; |
- } |
- break; |
- } |
- default: |
- NOTREACHED() << "Unexpected notification " << type; |
+ if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { |
+ // Cancel callback for previous cache requests. |
+ weak_factory_.InvalidateWeakPtrs(); |
+ custom_wallpaper_cache_.clear(); |
} |
} |
@@ -472,37 +448,6 @@ |
RestartTimer(); |
} |
-void WallpaperManager::CacheAllUsersWallpapers() { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- UserList users = UserManager::Get()->GetUsers(); |
- |
- UserList::const_iterator it = users.begin(); |
- // Skip the wallpaper of first user in the list. It should have been cached. |
- it++; |
- for (; it != users.end(); ++it) { |
- std::string user_email = (*it)->email(); |
- CacheUserWallpaper(user_email); |
- } |
-} |
- |
-void WallpaperManager::CacheUserWallpaper(const std::string& email) { |
- User::WallpaperType type; |
- int index; |
- base::Time date; |
- GetUserWallpaperProperties(email, &type, &index, &date); |
- if (type == User::CUSTOMIZED) { |
- std::string wallpaper_path = GetWallpaperPathForUser(email, false).value(); |
- |
- // Uses WeakPtr here to make the request cancelable. |
- wallpaper_loader_->Start(wallpaper_path, 0, |
- base::Bind(&WallpaperManager::CacheWallpaper, |
- weak_factory_.GetWeakPtr(), email)); |
- } else { |
- ash::Shell::GetInstance()->desktop_background_controller()-> |
- CacheDefaultWallpaper(index); |
- } |
-} |
- |
void WallpaperManager::CacheWallpaper(const std::string& email, |
const UserImage& wallpaper) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
@@ -538,7 +483,6 @@ |
base::Bind(&WallpaperManager::CacheThumbnail, |
base::Unretained(this), email, wallpaper.image())); |
- custom_wallpaper_cache_.insert(std::make_pair(email, wallpaper.image())); |
ash::Shell::GetInstance()->desktop_background_controller()-> |
SetCustomWallpaper(wallpaper.image(), layout); |
} |