OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
(...skipping 44 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 | 75 // Adds PowerManagerClient, TimeZoneSettings and CrosSettings observers. |
71 // added after PowerManagerClient has been initialized. | |
72 void AddObservers(); | 76 void AddObservers(); |
73 | 77 |
74 // Loads wallpaper asynchronously if the current wallpaper is not the | 78 // Loads wallpaper asynchronously if the current wallpaper is not the |
75 // wallpaper of logged in user. | 79 // wallpaper of logged in user. |
76 void EnsureLoggedInUserWallpaperLoaded(); | 80 void EnsureLoggedInUserWallpaperLoaded(); |
77 | 81 |
78 // Clears ONLINE and CUSTOM wallpaper cache. | 82 // Clears ONLINE and CUSTOM wallpaper cache. |
79 void ClearWallpaperCache(); | 83 void ClearWallpaperCache(); |
80 | 84 |
81 // Gets encoded wallpaper from cache. Returns true if success. | 85 // Gets encoded wallpaper from cache. Returns true if success. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 ash::WallpaperLayout layout); | 155 ash::WallpaperLayout layout); |
152 | 156 |
153 // Updates current wallpaper. It may switch the size of wallpaper based on the | 157 // Updates current wallpaper. It may switch the size of wallpaper based on the |
154 // current display's resolution. | 158 // current display's resolution. |
155 void UpdateWallpaper(); | 159 void UpdateWallpaper(); |
156 | 160 |
157 private: | 161 private: |
158 friend class WallpaperManagerBrowserTest; | 162 friend class WallpaperManagerBrowserTest; |
159 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; | 163 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; |
160 | 164 |
161 virtual ~WallpaperManager(); | |
162 | |
163 // The number of wallpapers have loaded. For test only. | 165 // The number of wallpapers have loaded. For test only. |
164 int loaded_wallpapers() const { return loaded_wallpapers_; } | 166 int loaded_wallpapers() const { return loaded_wallpapers_; } |
165 | 167 |
166 // Change the wallpapers for users who choose DAILY wallpaper type. Updates | 168 // Change the wallpapers for users who choose DAILY wallpaper type. Updates |
167 // current wallpaper if it changed. This function should be called at exactly | 169 // current wallpaper if it changed. This function should be called at exactly |
168 // at 0am if chromeos device is on. | 170 // at 0am if chromeos device is on. |
169 void BatchUpdateWallpaper(); | 171 void BatchUpdateWallpaper(); |
170 | 172 |
171 // Cache some (or all) logged in users' wallpapers to memory at login | 173 // Cache some (or all) logged in users' wallpapers to memory at login |
172 // screen. It should not compete with first wallpaper loading when boot | 174 // screen. It should not compete with first wallpaper loading when boot |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 // Old wallpaper names have a png extension name. However all new wallpapers | 262 // Old wallpaper names have a png extension name. However all new wallpapers |
261 // are saved in jpeg format. We have removed file extension to avoid | 263 // are saved in jpeg format. We have removed file extension to avoid |
262 // confusion in this CL (https://codereview.chromium.org/10950014). | 264 // confusion in this CL (https://codereview.chromium.org/10950014). |
263 // For wallpapers saved before it, we still need to append png extension to | 265 // For wallpapers saved before it, we still need to append png extension to |
264 // file name. | 266 // file name. |
265 void ValidateAndLoadWallpaper(const std::string& email, | 267 void ValidateAndLoadWallpaper(const std::string& email, |
266 const WallpaperInfo& info, | 268 const WallpaperInfo& info, |
267 bool update_wallpaper, | 269 bool update_wallpaper, |
268 const FilePath& wallpaper_path); | 270 const FilePath& wallpaper_path); |
269 | 271 |
| 272 // True if wallpaper manager is not observering other objects. |
| 273 bool no_observers_; |
| 274 |
270 // The number of loaded wallpapers. | 275 // The number of loaded wallpapers. |
271 int loaded_wallpapers_; | 276 int loaded_wallpapers_; |
272 | 277 |
273 // Sequence token associated with wallpaper operations. | 278 // Sequence token associated with wallpaper operations. |
274 base::SequencedWorkerPool::SequenceToken sequence_token_; | 279 base::SequencedWorkerPool::SequenceToken sequence_token_; |
275 | 280 |
276 // Wallpaper sequenced task runner. | 281 // Wallpaper sequenced task runner. |
277 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 282 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
278 | 283 |
279 // The file path of current loaded/loading custom/online wallpaper. | 284 // The file path of current loaded/loading custom/online wallpaper. |
(...skipping 18 matching lines...) Expand all Loading... |
298 content::NotificationRegistrar registrar_; | 303 content::NotificationRegistrar registrar_; |
299 | 304 |
300 base::OneShotTimer<WallpaperManager> timer_; | 305 base::OneShotTimer<WallpaperManager> timer_; |
301 | 306 |
302 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 307 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
303 }; | 308 }; |
304 | 309 |
305 } // namespace chromeos | 310 } // namespace chromeos |
306 | 311 |
307 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 312 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
OLD | NEW |