| 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 // Cache all logged in users' wallpapers to memory at login screen. It should |
| 135 // not compete with first wallpaper loading when boot up/initialize login |
| 136 // WebUI page. |
| 137 // There are two ways the first wallpaper might be loaded: |
| 138 // 1. Loaded on boot. Login WebUI waits for it. |
| 139 // 2. When flag --disable-boot-animation is passed. Login WebUI is loaded |
| 140 // right away and in 500ms after. Wallpaper started to load. |
| 141 // For case 2, should_cache_wallpaper_ is used to indicate if we need to |
| 142 // cache wallpapers on wallpaper animation finished. The cache operation |
| 143 // should be only executed once. |
| 144 void CacheAllUsersWallpapers(); |
| 145 |
| 146 // Caches |email|'s wallpaper to memory. |
| 147 void CacheUserWallpaper(const std::string& email); |
| 148 |
| 137 // Caches the decoded wallpaper to memory. | 149 // Caches the decoded wallpaper to memory. |
| 138 void CacheWallpaper(const std::string& email, const UserImage& wallpaper); | 150 void CacheWallpaper(const std::string& email, const UserImage& wallpaper); |
| 139 | 151 |
| 140 // Generates a 128x80 thumbnail and caches it. | 152 // Generates a 128x80 thumbnail and caches it. |
| 141 void CacheThumbnail(const std::string& email, | 153 void CacheThumbnail(const std::string& email, |
| 142 const gfx::ImageSkia& wallpaper); | 154 const gfx::ImageSkia& wallpaper); |
| 143 | 155 |
| 144 // Sets wallpaper to the decoded wallpaper. | 156 // Sets wallpaper to the decoded wallpaper. |
| 145 void FetchWallpaper(const std::string& email, | 157 void FetchWallpaper(const std::string& email, |
| 146 ash::WallpaperLayout layout, | 158 ash::WallpaperLayout layout, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 int current_user_wallpaper_index_; | 205 int current_user_wallpaper_index_; |
| 194 | 206 |
| 195 // Caches custom wallpapers of users. Accessed only on UI thread. | 207 // Caches custom wallpapers of users. Accessed only on UI thread. |
| 196 CustomWallpaperMap custom_wallpaper_cache_; | 208 CustomWallpaperMap custom_wallpaper_cache_; |
| 197 | 209 |
| 198 CustomWallpaperMap custom_wallpaper_thumbnail_cache_; | 210 CustomWallpaperMap custom_wallpaper_thumbnail_cache_; |
| 199 | 211 |
| 200 // The last selected user on user pod row. | 212 // The last selected user on user pod row. |
| 201 std::string last_selected_user_; | 213 std::string last_selected_user_; |
| 202 | 214 |
| 215 bool should_cache_wallpaper_; |
| 216 |
| 203 base::WeakPtrFactory<WallpaperManager> weak_factory_; | 217 base::WeakPtrFactory<WallpaperManager> weak_factory_; |
| 204 | 218 |
| 205 content::NotificationRegistrar registrar_; | 219 content::NotificationRegistrar registrar_; |
| 206 | 220 |
| 207 base::OneShotTimer<WallpaperManager> timer_; | 221 base::OneShotTimer<WallpaperManager> timer_; |
| 208 | 222 |
| 209 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 223 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
| 210 }; | 224 }; |
| 211 | 225 |
| 212 } // namespace chromeos | 226 } // namespace chromeos |
| 213 | 227 |
| 214 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 228 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
| OLD | NEW |