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" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 WallpaperManager(); | 39 WallpaperManager(); |
40 | 40 |
41 // Registers wallpaper manager preferences. | 41 // Registers wallpaper manager preferences. |
42 static void RegisterPrefs(PrefService* local_state); | 42 static void RegisterPrefs(PrefService* local_state); |
43 | 43 |
44 // Adds PowerManagerClient and TimeZoneSettings observers. It needs to be | 44 // Adds PowerManagerClient and TimeZoneSettings observers. It needs to be |
45 // added after PowerManagerClient initialized. | 45 // added after PowerManagerClient initialized. |
46 void AddObservers(); | 46 void AddObservers(); |
47 | 47 |
48 // Caches |email|'s wallpaper to memory if it is custom wallpaper. | |
49 void CacheIfCustomWallpaper(const std::string& email); | |
50 | |
51 // Loads wallpaper asynchronously if the current wallpaper is not the | 48 // Loads wallpaper asynchronously if the current wallpaper is not the |
52 // wallpaper of logged in user. | 49 // wallpaper of logged in user. |
53 void EnsureLoggedInUserWallpaperLoaded(); | 50 void EnsureLoggedInUserWallpaperLoaded(); |
54 | 51 |
55 // Fetches |email|'s wallpaper from local disk. | 52 // Fetches |email|'s wallpaper from local disk. |
56 void FetchCustomWallpaper(const std::string& email); | 53 void FetchCustomWallpaper(const std::string& email); |
57 | 54 |
58 // Gets encoded custom wallpaper from cache. Returns true if success. | 55 // Gets encoded custom wallpaper from cache. Returns true if success. |
59 bool GetCustomWallpaperFromCache(const std::string& email, | 56 bool GetCustomWallpaperFromCache(const std::string& email, |
60 gfx::ImageSkia* wallpaper); | 57 gfx::ImageSkia* wallpaper); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 private: | 124 private: |
128 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; | 125 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; |
129 | 126 |
130 virtual ~WallpaperManager(); | 127 virtual ~WallpaperManager(); |
131 | 128 |
132 // Change the wallpapers for users who choose DAILY wallpaper type. Updates | 129 // Change the wallpapers for users who choose DAILY wallpaper type. Updates |
133 // current wallpaper if it changed. This function should be called at exactly | 130 // current wallpaper if it changed. This function should be called at exactly |
134 // at 0am if chromeos device is on. | 131 // at 0am if chromeos device is on. |
135 void BatchUpdateWallpaper(); | 132 void BatchUpdateWallpaper(); |
136 | 133 |
| 134 void CacheAllUsersWallpapers(); |
| 135 |
| 136 // Caches |email|'s wallpaper to memory. |
| 137 void CacheUserWallpaper(const std::string& email); |
| 138 |
137 // Caches the decoded wallpaper to memory. | 139 // Caches the decoded wallpaper to memory. |
138 void CacheWallpaper(const std::string& email, const UserImage& wallpaper); | 140 void CacheWallpaper(const std::string& email, const UserImage& wallpaper); |
139 | 141 |
140 // Generates a 128x80 thumbnail and caches it. | 142 // Generates a 128x80 thumbnail and caches it. |
141 void CacheThumbnail(const std::string& email, | 143 void CacheThumbnail(const std::string& email, |
142 const gfx::ImageSkia& wallpaper); | 144 const gfx::ImageSkia& wallpaper); |
143 | 145 |
144 // Sets wallpaper to the decoded wallpaper. | 146 // Sets wallpaper to the decoded wallpaper. |
145 void FetchWallpaper(const std::string& email, | 147 void FetchWallpaper(const std::string& email, |
146 ash::WallpaperLayout layout, | 148 ash::WallpaperLayout layout, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 int current_user_wallpaper_index_; | 195 int current_user_wallpaper_index_; |
194 | 196 |
195 // Caches custom wallpapers of users. Accessed only on UI thread. | 197 // Caches custom wallpapers of users. Accessed only on UI thread. |
196 CustomWallpaperMap custom_wallpaper_cache_; | 198 CustomWallpaperMap custom_wallpaper_cache_; |
197 | 199 |
198 CustomWallpaperMap custom_wallpaper_thumbnail_cache_; | 200 CustomWallpaperMap custom_wallpaper_thumbnail_cache_; |
199 | 201 |
200 // The last selected user on user pod row. | 202 // The last selected user on user pod row. |
201 std::string last_selected_user_; | 203 std::string last_selected_user_; |
202 | 204 |
| 205 bool should_cache_wallpaper_; |
| 206 |
203 base::WeakPtrFactory<WallpaperManager> weak_factory_; | 207 base::WeakPtrFactory<WallpaperManager> weak_factory_; |
204 | 208 |
205 content::NotificationRegistrar registrar_; | 209 content::NotificationRegistrar registrar_; |
206 | 210 |
207 base::OneShotTimer<WallpaperManager> timer_; | 211 base::OneShotTimer<WallpaperManager> timer_; |
208 | 212 |
209 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 213 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
210 }; | 214 }; |
211 | 215 |
212 } // namespace chromeos | 216 } // namespace chromeos |
213 | 217 |
214 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 218 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
OLD | NEW |