| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/desktop_background/desktop_background_resources.h" | 10 #include "ash/desktop_background/desktop_background_resources.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/timer.h" | 12 #include "base/timer.h" |
| 13 #include "chrome/browser/chromeos/login/user.h" |
| 13 #include "chrome/browser/chromeos/login/user_image.h" | 14 #include "chrome/browser/chromeos/login/user_image.h" |
| 14 #include "chrome/browser/chromeos/login/user_image_loader.h" | 15 #include "chrome/browser/chromeos/login/user_image_loader.h" |
| 15 #include "chrome/browser/chromeos/power/resume_observer.h" | 16 #include "chrome/browser/chromeos/power/resume_observer.h" |
| 16 #include "chrome/browser/chromeos/system/timezone_settings.h" | 17 #include "chrome/browser/chromeos/system/timezone_settings.h" |
| 17 #include "unicode/timezone.h" | 18 #include "unicode/timezone.h" |
| 18 | 19 |
| 20 class PrefService; |
| 21 |
| 19 namespace chromeos { | 22 namespace chromeos { |
| 20 | 23 |
| 21 // This class maintains wallpapers for users who have logged into this Chrome | 24 // This class maintains wallpapers for users who have logged into this Chrome |
| 22 // OS device. | 25 // OS device. |
| 23 class WallpaperManager: public system::TimezoneSettings::Observer, | 26 class WallpaperManager: public system::TimezoneSettings::Observer, |
| 24 public chromeos::ResumeObserver { | 27 public chromeos::ResumeObserver { |
| 25 public: | 28 public: |
| 26 static WallpaperManager* Get(); | 29 static WallpaperManager* Get(); |
| 27 | 30 |
| 28 WallpaperManager(); | 31 WallpaperManager(); |
| 29 | 32 |
| 33 // Registers wallpaper manager preferences. |
| 34 static void RegisterPrefs(PrefService* local_state); |
| 35 |
| 30 // Adds PowerManagerClient observer. It needs to be added after | 36 // Adds PowerManagerClient observer. It needs to be added after |
| 31 // PowerManagerClient initialized. | 37 // PowerManagerClient initialized. |
| 32 void AddPowerManagerClientObserver(); | 38 void AddPowerManagerClientObserver(); |
| 33 | 39 |
| 34 // Starts a one shot timer which calls BatchUpdateWallpaper at next midnight. | 40 // Starts a one shot timer which calls BatchUpdateWallpaper at next midnight. |
| 35 // Cancel any previous timer if any. | 41 // Cancel any previous timer if any. |
| 36 void RestartTimer(); | 42 void RestartTimer(); |
| 37 | 43 |
| 44 // Saves |username| selected wallpaper information to local state. |
| 45 void SaveUserWallpaperInfo(const std::string& username, |
| 46 const std::string& file_name, |
| 47 ash::WallpaperLayout layout, |
| 48 User::WallpaperType type); |
| 49 |
| 38 // Sets last selected user on user pod row. | 50 // Sets last selected user on user pod row. |
| 39 void SetLastSelectedUser(const std::string& last_selected_user); | 51 void SetLastSelectedUser(const std::string& last_selected_user); |
| 40 | 52 |
| 41 // Sets wallpaper to the image file |path| points to. | 53 // Sets wallpaper to the image file |path| points to. |
| 42 void SetWallpaperFromFile(std::string email, | 54 void SetWallpaperFromFilePath(const std::string& path, |
| 43 const std::string& path, | 55 ash::WallpaperLayout layout); |
| 44 ash::WallpaperLayout layout); | 56 |
| 57 // Sets wallpaper to |wallpaper|. |
| 58 void SetWallpaperFromImageSkia(const gfx::ImageSkia& wallpaper, |
| 59 ash::WallpaperLayout layout); |
| 45 | 60 |
| 46 // User was deselected at login screen, reset wallpaper if needed. | 61 // User was deselected at login screen, reset wallpaper if needed. |
| 47 void UserDeselected(); | 62 void UserDeselected(); |
| 48 | 63 |
| 49 private: | 64 private: |
| 50 virtual ~WallpaperManager(); | 65 virtual ~WallpaperManager(); |
| 51 | 66 |
| 52 void OnCustomWallpaperLoaded(const std::string& email, | |
| 53 ash::WallpaperLayout layout, | |
| 54 const UserImage& user_image); | |
| 55 | |
| 56 // Change the wallpapers for users who choose DAILY wallpaper type. Updates | 67 // Change the wallpapers for users who choose DAILY wallpaper type. Updates |
| 57 // current wallpaper if it changed. This function should be called at exactly | 68 // current wallpaper if it changed. This function should be called at exactly |
| 58 // at 0am if chromeos device is on. | 69 // at 0am if chromeos device is on. |
| 59 void BatchUpdateWallpaper(); | 70 void BatchUpdateWallpaper(); |
| 60 | 71 |
| 72 // Sets wallpaper to image in |user_image| with |layout|. |
| 73 void OnWallpaperLoaded(ash::WallpaperLayout layout, |
| 74 const UserImage& user_image); |
| 75 |
| 61 // Loads user image from its file. | 76 // Loads user image from its file. |
| 62 scoped_refptr<UserImageLoader> image_loader_; | 77 scoped_refptr<UserImageLoader> image_loader_; |
| 63 | 78 |
| 64 // Overridden from chromeos::ResumeObserver | 79 // Overridden from chromeos::ResumeObserver |
| 65 virtual void SystemResumed() OVERRIDE; | 80 virtual void SystemResumed() OVERRIDE; |
| 66 | 81 |
| 67 // Overridden from system::TimezoneSettings::Observer. | 82 // Overridden from system::TimezoneSettings::Observer. |
| 68 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE; | 83 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE; |
| 69 | 84 |
| 70 // The last selected user on user pod row. | 85 // The last selected user on user pod row. |
| 71 std::string last_selected_user_; | 86 std::string last_selected_user_; |
| 72 | 87 |
| 73 base::OneShotTimer<WallpaperManager> timer_; | 88 base::OneShotTimer<WallpaperManager> timer_; |
| 74 | 89 |
| 75 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 90 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
| 76 }; | 91 }; |
| 77 | 92 |
| 78 } // namespace chromeos | 93 } // namespace chromeos |
| 79 | 94 |
| 80 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 95 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
| OLD | NEW |