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..24f5d65490690d8a2369bbcff1a43fcd90a7d2a1 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() { |
flackr
2012/03/22 03:19:10
Only use explicit for single argument constructors
bshe
2012/03/22 05:21:16
Done.
|
+ } |
+ |
+ virtual ~UserWallpaperDelegate() { |
+ } |
+ |
+ virtual const int GetUserWallpaperIndex() OVERRIDE{ |
Ben Goodger (Google)
2012/03/22 03:23:16
nit: space before {
bshe
2012/03/22 05:21:16
Done.
|
+ chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
+ // If at login screen or logged in as a guest/incognito user, then use the |
+ // default wallpaper. |
+ 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; |
+ } |
+}; |
Ben Goodger (Google)
2012/03/22 03:23:16
private:
DISALLOW_COPY_AND...
bshe
2012/03/22 05:21:16
Done.
|
+ |
+} // 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: |