Index: chrome/browser/chromeos/background/desktop_background_observer.cc |
diff --git a/chrome/browser/chromeos/background/desktop_background_observer.cc b/chrome/browser/chromeos/background/desktop_background_observer.cc |
index bf464d76792727df7eb0b003f1a54568ec86830e..6a851941ee40b37dbbeeef521780dc144125d9ad 100644 |
--- a/chrome/browser/chromeos/background/desktop_background_observer.cc |
+++ b/chrome/browser/chromeos/background/desktop_background_observer.cc |
@@ -14,6 +14,37 @@ |
namespace chromeos { |
+namespace { |
+ |
+class UserWallpaperDelegate: public ash::UserWallpaperDelegate { |
+ public: |
+ explicit UserWallpaperDelegate() { |
+ } |
+ |
+ virtual ~UserWallpaperDelegate() { |
+ } |
+ |
+ virtual const int GetUserWallpaperIndex() OVERRIDE{ |
+ chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
+ // Guest/incognito user or users haven't logged in (in log in screen) do |
flackr
2012/03/22 02:26:09
Fix sentence. I'm guessing you should say somethin
bshe
2012/03/22 02:48:11
You read my mind. :)
On 2012/03/22 02:26:09, flack
|
+ // not have an email address. |
+ if (user_manager->IsLoggedInAsGuest() || !user_manager->IsUserLoggedIn()) |
+ return ash::GetDefaultWallpaperIndex(); |
+ |
+ const chromeos::User& user = user_manager->GetLoggedInUser(); |
+ DCHECK(!user.email().empty()); |
+ int index = user_manager->GetUserWallpaper(user.email()); |
+ DCHECK(index >=0 && index < ash::GetWallpaperCount()); |
+ return index; |
+ } |
+}; |
+ |
+} // namespace |
+ |
+ash::UserWallpaperDelegate* CreateUserWallpaperDelegate() { |
+ return new chromeos::UserWallpaperDelegate(); |
+} |
+ |
DesktopBackgroundObserver::DesktopBackgroundObserver() { |
registrar_.Add( |
this, |
@@ -24,25 +55,13 @@ DesktopBackgroundObserver::DesktopBackgroundObserver() { |
DesktopBackgroundObserver::~DesktopBackgroundObserver() { |
} |
-int DesktopBackgroundObserver::GetUserWallpaperIndex() { |
- chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
- // Guest/incognito user do not have an email address. |
- if (user_manager->IsLoggedInAsGuest()) |
- return ash::GetDefaultWallpaperIndex(); |
- const chromeos::User& user = user_manager->GetLoggedInUser(); |
- DCHECK(!user.email().empty()); |
- int index = user_manager->GetUserWallpaper(user.email()); |
- DCHECK(index >=0 && index < ash::GetWallpaperCount()); |
- return index; |
-} |
- |
void DesktopBackgroundObserver::Observe(int type, |
const content::NotificationSource& source, |
const content::NotificationDetails& details) { |
switch (type) { |
case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { |
ash::Shell::GetInstance()->desktop_background_controller()-> |
- OnDesktopBackgroundChanged(GetUserWallpaperIndex()); |
+ OnDesktopBackgroundChanged(); |
break; |
} |
default: |