OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/background/desktop_background_observer.h" |
| 6 |
| 7 #include "ash/shell.h" |
| 8 #include "ash/desktop_background/desktop_background_controller.h" |
| 9 #include "ash/desktop_background/desktop_background_resources.h" |
| 10 #include "base/logging.h" |
| 11 #include "chrome/browser/chromeos/login/user_manager.h" |
| 12 #include "chrome/common/chrome_notification_types.h" |
| 13 #include "content/public/browser/notification_service.h" |
| 14 |
| 15 namespace chromeos { |
| 16 |
| 17 DesktopBackgroundObserver::DesktopBackgroundObserver() { |
| 18 registrar_.Add( |
| 19 this, |
| 20 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
| 21 content::NotificationService::AllSources()); |
| 22 } |
| 23 |
| 24 DesktopBackgroundObserver::~DesktopBackgroundObserver() { |
| 25 } |
| 26 |
| 27 int DesktopBackgroundObserver::GetUserWallpaperIndex() { |
| 28 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
| 29 const chromeos::User& user = user_manager->GetLoggedInUser(); |
| 30 DCHECK(!user.email().empty()); |
| 31 int index = user_manager->GetUserWallpaper(user.email()); |
| 32 DCHECK(index >=0 && index < ash::GetWallpaperCount()); |
| 33 return index; |
| 34 } |
| 35 |
| 36 void DesktopBackgroundObserver::Observe(int type, |
| 37 const content::NotificationSource& source, |
| 38 const content::NotificationDetails& details) { |
| 39 switch (type) { |
| 40 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { |
| 41 ash::Shell::GetInstance()->desktop_background_controller()-> |
| 42 OnDesktopBackgroundChanged(GetUserWallpaperIndex()); |
| 43 break; |
| 44 } |
| 45 default: |
| 46 NOTREACHED(); |
| 47 } |
| 48 } |
| 49 |
| 50 } // namespace chromeos |
OLD | NEW |