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" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/threading/sequenced_worker_pool.h" | 14 #include "base/threading/sequenced_worker_pool.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "base/timer.h" | 16 #include "base/timer.h" |
17 #include "chrome/browser/chromeos/login/user.h" | 17 #include "chrome/browser/chromeos/login/user.h" |
18 #include "chrome/browser/chromeos/login/user_image.h" | 18 #include "chrome/browser/chromeos/login/user_image.h" |
19 #include "chrome/browser/chromeos/login/user_image_loader.h" | 19 #include "chrome/browser/chromeos/login/user_image_loader.h" |
20 #include "chrome/browser/chromeos/system/timezone_settings.h" | 20 #include "chrome/browser/chromeos/system/timezone_settings.h" |
| 21 #include "chromeos/dbus/power_manager_client.h" |
21 #include "chromeos/dbus/root_power_manager_observer.h" | 22 #include "chromeos/dbus/root_power_manager_observer.h" |
22 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
23 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
24 #include "third_party/icu/public/i18n/unicode/timezone.h" | 25 #include "third_party/icu/public/i18n/unicode/timezone.h" |
25 #include "ui/gfx/image/image_skia.h" | 26 #include "ui/gfx/image/image_skia.h" |
26 | 27 |
27 class PrefServiceSimple; | 28 class PrefServiceSimple; |
28 | 29 |
29 namespace base { | 30 namespace base { |
30 class SequencedTaskRunner; | 31 class SequencedTaskRunner; |
(...skipping 19 matching lines...) Expand all Loading... |
50 // Name of wallpaper sequence token. | 51 // Name of wallpaper sequence token. |
51 extern const char kWallpaperSequenceTokenName[]; | 52 extern const char kWallpaperSequenceTokenName[]; |
52 | 53 |
53 // File path suffices of resized small or large wallpaper. | 54 // File path suffices of resized small or large wallpaper. |
54 extern const char kSmallWallpaperSuffix[]; | 55 extern const char kSmallWallpaperSuffix[]; |
55 extern const char kLargeWallpaperSuffix[]; | 56 extern const char kLargeWallpaperSuffix[]; |
56 | 57 |
57 // This class maintains wallpapers for users who have logged into this Chrome | 58 // This class maintains wallpapers for users who have logged into this Chrome |
58 // OS device. | 59 // OS device. |
59 class WallpaperManager: public system::TimezoneSettings::Observer, | 60 class WallpaperManager: public system::TimezoneSettings::Observer, |
| 61 public chromeos::PowerManagerClient::Observer, |
60 public chromeos::RootPowerManagerObserver, | 62 public chromeos::RootPowerManagerObserver, |
61 public content::NotificationObserver { | 63 public content::NotificationObserver { |
62 public: | 64 public: |
63 static WallpaperManager* Get(); | 65 static WallpaperManager* Get(); |
64 | 66 |
65 WallpaperManager(); | 67 WallpaperManager(); |
66 | 68 |
67 // Registers wallpaper manager preferences. | 69 // Registers wallpaper manager preferences. |
68 static void RegisterPrefs(PrefServiceSimple* local_state); | 70 static void RegisterPrefs(PrefServiceSimple* local_state); |
69 | 71 |
70 // Adds RootPowerManagerClient and TimeZoneSettings observers. It needs to be | 72 // Adds PowerManagerClient and TimeZoneSettings observers. It needs to be |
71 // added after RootPowerManagerClient has been initialized. | 73 // added after PowerManagerClient has been initialized. |
72 void AddObservers(); | 74 void AddObservers(); |
73 | 75 |
74 // Loads wallpaper asynchronously if the current wallpaper is not the | 76 // Loads wallpaper asynchronously if the current wallpaper is not the |
75 // wallpaper of logged in user. | 77 // wallpaper of logged in user. |
76 void EnsureLoggedInUserWallpaperLoaded(); | 78 void EnsureLoggedInUserWallpaperLoaded(); |
77 | 79 |
78 // Clears ONLINE and CUSTOM wallpaper cache. | 80 // Clears ONLINE and CUSTOM wallpaper cache. |
79 void ClearWallpaperCache(); | 81 void ClearWallpaperCache(); |
80 | 82 |
81 // Gets encoded wallpaper from cache. Returns true if success. | 83 // Gets encoded wallpaper from cache. Returns true if success. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // Saves wallpaper image raw |data| to |path| (absolute path) in file system. | 244 // Saves wallpaper image raw |data| to |path| (absolute path) in file system. |
243 void SaveWallpaperInternal(const FilePath& path, const char* data, int size); | 245 void SaveWallpaperInternal(const FilePath& path, const char* data, int size); |
244 | 246 |
245 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the | 247 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the |
246 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread. | 248 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread. |
247 void StartLoad(const std::string& email, | 249 void StartLoad(const std::string& email, |
248 const WallpaperInfo& info, | 250 const WallpaperInfo& info, |
249 bool update_wallpaper, | 251 bool update_wallpaper, |
250 const FilePath& wallpaper_path); | 252 const FilePath& wallpaper_path); |
251 | 253 |
| 254 // Overridden from chromeos::PowerManagerObserver. |
| 255 virtual void SystemResumed(const base::TimeDelta& sleep_duration) OVERRIDE; |
| 256 |
252 // Overridden from chromeos::RootPowerManagerObserver. | 257 // Overridden from chromeos::RootPowerManagerObserver. |
| 258 // TODO(derat): Remove this once notifications are sent by powerd. |
253 virtual void OnResume(const base::TimeDelta& sleep_duration) OVERRIDE; | 259 virtual void OnResume(const base::TimeDelta& sleep_duration) OVERRIDE; |
254 | 260 |
255 // Overridden from system::TimezoneSettings::Observer. | 261 // Overridden from system::TimezoneSettings::Observer. |
256 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE; | 262 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE; |
257 | 263 |
258 // Validates |wallpaper path| and loads corresponding wallpaper. If | 264 // Validates |wallpaper path| and loads corresponding wallpaper. If |
259 // |wallpaper_path| is not valid, appends png extension to it before loading. | 265 // |wallpaper_path| is not valid, appends png extension to it before loading. |
260 // Old wallpaper names have a png extension name. However all new wallpapers | 266 // 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 | 267 // are saved in jpeg format. We have removed file extension to avoid |
262 // confusion in this CL (https://codereview.chromium.org/10950014). | 268 // confusion in this CL (https://codereview.chromium.org/10950014). |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 content::NotificationRegistrar registrar_; | 304 content::NotificationRegistrar registrar_; |
299 | 305 |
300 base::OneShotTimer<WallpaperManager> timer_; | 306 base::OneShotTimer<WallpaperManager> timer_; |
301 | 307 |
302 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 308 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
303 }; | 309 }; |
304 | 310 |
305 } // namespace chromeos | 311 } // namespace chromeos |
306 | 312 |
307 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 313 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
OLD | NEW |