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_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 // This class maintains wallpapers for users who have logged into this Chrome | 57 // This class maintains wallpapers for users who have logged into this Chrome |
58 // OS device. | 58 // OS device. |
59 class WallpaperManager: public system::TimezoneSettings::Observer, | 59 class WallpaperManager: public system::TimezoneSettings::Observer, |
60 public chromeos::PowerManagerClient::Observer, | 60 public chromeos::PowerManagerClient::Observer, |
61 public content::NotificationObserver { | 61 public content::NotificationObserver { |
62 public: | 62 public: |
63 static WallpaperManager* Get(); | 63 static WallpaperManager* Get(); |
64 | 64 |
65 WallpaperManager(); | 65 WallpaperManager(); |
| 66 virtual ~WallpaperManager(); |
| 67 |
| 68 // Indicates imminent shutdown, allowing the WallpaperManager to remove any |
| 69 // observers it has registered. |
| 70 void Shutdown(); |
66 | 71 |
67 // Registers wallpaper manager preferences. | 72 // Registers wallpaper manager preferences. |
68 static void RegisterPrefs(PrefServiceSimple* local_state); | 73 static void RegisterPrefs(PrefServiceSimple* local_state); |
69 | 74 |
70 // Adds PowerManagerClient and TimeZoneSettings observers. It needs to be | |
71 // added after PowerManagerClient has been initialized. | |
72 void AddObservers(); | |
73 | |
74 // Loads wallpaper asynchronously if the current wallpaper is not the | 75 // Loads wallpaper asynchronously if the current wallpaper is not the |
75 // wallpaper of logged in user. | 76 // wallpaper of logged in user. |
76 void EnsureLoggedInUserWallpaperLoaded(); | 77 void EnsureLoggedInUserWallpaperLoaded(); |
77 | 78 |
78 // Clears ONLINE and CUSTOM wallpaper cache. | 79 // Clears ONLINE and CUSTOM wallpaper cache. |
79 void ClearWallpaperCache(); | 80 void ClearWallpaperCache(); |
80 | 81 |
81 // Gets encoded wallpaper from cache. Returns true if success. | 82 // Gets encoded wallpaper from cache. Returns true if success. |
82 bool GetWallpaperFromCache(const std::string& email, | 83 bool GetWallpaperFromCache(const std::string& email, |
83 gfx::ImageSkia* wallpaper); | 84 gfx::ImageSkia* wallpaper); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 ash::WallpaperLayout layout); | 152 ash::WallpaperLayout layout); |
152 | 153 |
153 // Updates current wallpaper. It may switch the size of wallpaper based on the | 154 // Updates current wallpaper. It may switch the size of wallpaper based on the |
154 // current display's resolution. | 155 // current display's resolution. |
155 void UpdateWallpaper(); | 156 void UpdateWallpaper(); |
156 | 157 |
157 private: | 158 private: |
158 friend class WallpaperManagerBrowserTest; | 159 friend class WallpaperManagerBrowserTest; |
159 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; | 160 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; |
160 | 161 |
161 virtual ~WallpaperManager(); | |
162 | |
163 // The number of wallpapers have loaded. For test only. | 162 // The number of wallpapers have loaded. For test only. |
164 int loaded_wallpapers() const { return loaded_wallpapers_; } | 163 int loaded_wallpapers() const { return loaded_wallpapers_; } |
165 | 164 |
166 // Change the wallpapers for users who choose DAILY wallpaper type. Updates | 165 // Change the wallpapers for users who choose DAILY wallpaper type. Updates |
167 // current wallpaper if it changed. This function should be called at exactly | 166 // current wallpaper if it changed. This function should be called at exactly |
168 // at 0am if chromeos device is on. | 167 // at 0am if chromeos device is on. |
169 void BatchUpdateWallpaper(); | 168 void BatchUpdateWallpaper(); |
170 | 169 |
171 // Cache some (or all) logged in users' wallpapers to memory at login | 170 // Cache some (or all) logged in users' wallpapers to memory at login |
172 // screen. It should not compete with first wallpaper loading when boot | 171 // screen. It should not compete with first wallpaper loading when boot |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 content::NotificationRegistrar registrar_; | 297 content::NotificationRegistrar registrar_; |
299 | 298 |
300 base::OneShotTimer<WallpaperManager> timer_; | 299 base::OneShotTimer<WallpaperManager> timer_; |
301 | 300 |
302 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 301 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
303 }; | 302 }; |
304 | 303 |
305 } // namespace chromeos | 304 } // namespace chromeos |
306 | 305 |
307 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 306 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
OLD | NEW |