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 SaveUserWallpaperInfos(const std::string& username, | |
Nikita (slow)
2012/07/23 22:06:47
s/Infos/Info/
bshe
2012/07/24 16:21:10
Done.
| |
46 std::string file_name, | |
Nikita (slow)
2012/07/23 22:06:47
std::string&
bshe
2012/07/24 16:21:10
Done.
| |
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(ash::WallpaperLayout layout, | |
Nikita (slow)
2012/07/23 22:06:47
Please bring signature closer to SetWallpaperFromF
bshe
2012/07/24 16:21:10
Done.
| |
59 const gfx::ImageSkia& wallpaper); | |
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 void OnWallpaperLoaded(ash::WallpaperLayout layout, | |
Nikita (slow)
2012/07/23 22:06:47
Please add comment
bshe
2012/07/24 16:21:10
Done.
| |
73 const UserImage& user_image); | |
74 | |
61 // Loads user image from its file. | 75 // Loads user image from its file. |
62 scoped_refptr<UserImageLoader> image_loader_; | 76 scoped_refptr<UserImageLoader> image_loader_; |
63 | 77 |
64 // Overridden from chromeos::ResumeObserver | 78 // Overridden from chromeos::ResumeObserver |
65 virtual void SystemResumed() OVERRIDE; | 79 virtual void SystemResumed() OVERRIDE; |
66 | 80 |
67 // Overridden from system::TimezoneSettings::Observer. | 81 // Overridden from system::TimezoneSettings::Observer. |
68 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE; | 82 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE; |
69 | 83 |
70 // The last selected user on user pod row. | 84 // The last selected user on user pod row. |
71 std::string last_selected_user_; | 85 std::string last_selected_user_; |
72 | 86 |
73 base::OneShotTimer<WallpaperManager> timer_; | 87 base::OneShotTimer<WallpaperManager> timer_; |
74 | 88 |
75 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 89 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
76 }; | 90 }; |
77 | 91 |
78 } // namespace chromeos | 92 } // namespace chromeos |
79 | 93 |
80 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 94 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
OLD | NEW |