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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 // Returns filepath to save original custom wallpaper for the given user. | 85 // Returns filepath to save original custom wallpaper for the given user. |
86 FilePath GetOriginalWallpaperPathForUser(const std::string& username); | 86 FilePath GetOriginalWallpaperPathForUser(const std::string& username); |
87 | 87 |
88 // Returns small resolution custom wallpaper filepath for the given user when | 88 // Returns small resolution custom wallpaper filepath for the given user when |
89 // |is_small| is ture. Otherwise, returns large resolution custom wallpaper | 89 // |is_small| is ture. Otherwise, returns large resolution custom wallpaper |
90 // path. | 90 // path. |
91 FilePath GetWallpaperPathForUser(const std::string& username, | 91 FilePath GetWallpaperPathForUser(const std::string& username, |
92 bool is_small); | 92 bool is_small); |
93 | 93 |
94 // Gets the thumbnail of custom wallpaper from cache. | |
95 gfx::ImageSkia GetCustomWallpaperThumbnail(const std::string& email); | |
96 | |
97 // Gets wallpaper information of logged in user. | 94 // Gets wallpaper information of logged in user. |
98 bool GetLoggedInUserWallpaperInfo(WallpaperInfo* info); | 95 bool GetLoggedInUserWallpaperInfo(WallpaperInfo* info); |
99 | 96 |
100 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged | 97 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged |
101 // in, uses a solid color wallpaper. If logged in as a stub user, uses an | 98 // in, uses a solid color wallpaper. If logged in as a stub user, uses an |
102 // empty wallpaper. | 99 // empty wallpaper. |
103 void InitializeWallpaper(); | 100 void InitializeWallpaper(); |
104 | 101 |
105 // NotificationObserver overrides: | 102 // NotificationObserver overrides: |
106 virtual void Observe(int type, | 103 virtual void Observe(int type, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // 2. When flag --disable-boot-animation is passed. Login WebUI is loaded | 176 // 2. When flag --disable-boot-animation is passed. Login WebUI is loaded |
180 // right away and in 500ms after. Wallpaper started to load. | 177 // right away and in 500ms after. Wallpaper started to load. |
181 // For case 2, should_cache_wallpaper_ is used to indicate if we need to | 178 // For case 2, should_cache_wallpaper_ is used to indicate if we need to |
182 // cache wallpapers on wallpaper animation finished. The cache operation | 179 // cache wallpapers on wallpaper animation finished. The cache operation |
183 // should be only executed once. | 180 // should be only executed once. |
184 void CacheAllUsersWallpapers(); | 181 void CacheAllUsersWallpapers(); |
185 | 182 |
186 // Caches |email|'s wallpaper to memory. | 183 // Caches |email|'s wallpaper to memory. |
187 void CacheUserWallpaper(const std::string& email); | 184 void CacheUserWallpaper(const std::string& email); |
188 | 185 |
189 // Generates a 128x80 thumbnail and caches it. | |
190 void CacheThumbnail(const std::string& email, | |
191 scoped_ptr<gfx::ImageSkia> wallpaper); | |
192 | |
193 // Clears all obsolete wallpaper prefs from old version wallpaper pickers. | 186 // Clears all obsolete wallpaper prefs from old version wallpaper pickers. |
194 void ClearObsoleteWallpaperPrefs(); | 187 void ClearObsoleteWallpaperPrefs(); |
195 | 188 |
196 // Deletes a list of wallpaper files in |file_list|. | 189 // Deletes a list of wallpaper files in |file_list|. |
197 void DeleteWallpaperInList(const std::vector<FilePath>& file_list); | 190 void DeleteWallpaperInList(const std::vector<FilePath>& file_list); |
198 | 191 |
199 // Deletes all |email| related custom or converted wallpapers. | 192 // Deletes all |email| related custom or converted wallpapers. |
200 void DeleteUserWallpapers(const std::string& email); | 193 void DeleteUserWallpapers(const std::string& email); |
201 | 194 |
202 // Loads |email|'s wallpaper. When |update_wallpaper| is true, sets wallpaper | 195 // Loads |email|'s wallpaper. When |update_wallpaper| is true, sets wallpaper |
203 // to the loaded wallpaper. | 196 // to the loaded wallpaper. |
204 void LoadWallpaper(const std::string& email, | 197 void LoadWallpaper(const std::string& email, |
205 const WallpaperInfo& info, | 198 const WallpaperInfo& info, |
206 bool update_wallpaper); | 199 bool update_wallpaper); |
207 | 200 |
208 // Generates a 128x80 thumbnail. | |
209 void GenerateUserWallpaperThumbnail(const std::string& email, | |
210 User::WallpaperType type, | |
211 const gfx::ImageSkia& wallpaper); | |
212 | |
213 // Gets |email|'s custom wallpaper at |wallpaper_path|. Falls back on original | 201 // Gets |email|'s custom wallpaper at |wallpaper_path|. Falls back on original |
214 // custom wallpaper. When |update_wallpaper| is true, sets wallpaper to the | 202 // custom wallpaper. When |update_wallpaper| is true, sets wallpaper to the |
215 // loaded wallpaper. Must run on FILE thread. | 203 // loaded wallpaper. Must run on FILE thread. |
216 void GetCustomWallpaperInternal(const std::string& email, | 204 void GetCustomWallpaperInternal(const std::string& email, |
217 const WallpaperInfo& info, | 205 const WallpaperInfo& info, |
218 const FilePath& wallpaper_path, | 206 const FilePath& wallpaper_path, |
219 bool update_wallpaper); | 207 bool update_wallpaper); |
220 | 208 |
221 // Gets wallpaper information of |email| from Local State or memory. Returns | 209 // Gets wallpaper information of |email| from Local State or memory. Returns |
222 // false if wallpaper information is not found. | 210 // false if wallpaper information is not found. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 282 |
295 // Loads user wallpaper from its file. | 283 // Loads user wallpaper from its file. |
296 scoped_refptr<UserImageLoader> wallpaper_loader_; | 284 scoped_refptr<UserImageLoader> wallpaper_loader_; |
297 | 285 |
298 // Logged-in user wallpaper information. | 286 // Logged-in user wallpaper information. |
299 WallpaperInfo current_user_wallpaper_info_; | 287 WallpaperInfo current_user_wallpaper_info_; |
300 | 288 |
301 // Caches wallpapers of users. Accessed only on UI thread. | 289 // Caches wallpapers of users. Accessed only on UI thread. |
302 CustomWallpaperMap wallpaper_cache_; | 290 CustomWallpaperMap wallpaper_cache_; |
303 | 291 |
304 CustomWallpaperMap custom_wallpaper_thumbnail_cache_; | |
305 | |
306 // The last selected user on user pod row. | 292 // The last selected user on user pod row. |
307 std::string last_selected_user_; | 293 std::string last_selected_user_; |
308 | 294 |
309 bool should_cache_wallpaper_; | 295 bool should_cache_wallpaper_; |
310 | 296 |
311 base::WeakPtrFactory<WallpaperManager> weak_factory_; | 297 base::WeakPtrFactory<WallpaperManager> weak_factory_; |
312 | 298 |
313 content::NotificationRegistrar registrar_; | 299 content::NotificationRegistrar registrar_; |
314 | 300 |
315 base::OneShotTimer<WallpaperManager> timer_; | 301 base::OneShotTimer<WallpaperManager> timer_; |
316 | 302 |
317 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 303 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
318 }; | 304 }; |
319 | 305 |
320 } // namespace chromeos | 306 } // namespace chromeos |
321 | 307 |
322 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 308 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
OLD | NEW |