OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 static bool ResizeAndSaveWallpaper(const gfx::ImageSkia& image, | 216 static bool ResizeAndSaveWallpaper(const gfx::ImageSkia& image, |
217 const base::FilePath& path, | 217 const base::FilePath& path, |
218 ash::WallpaperLayout layout, | 218 ash::WallpaperLayout layout, |
219 int preferred_width, | 219 int preferred_width, |
220 int preferred_height, | 220 int preferred_height, |
221 gfx::ImageSkia* output_skia); | 221 gfx::ImageSkia* output_skia); |
222 | 222 |
223 // Returns the appropriate wallpaper resolution for all root windows. | 223 // Returns the appropriate wallpaper resolution for all root windows. |
224 static WallpaperResolution GetAppropriateResolution(); | 224 static WallpaperResolution GetAppropriateResolution(); |
225 | 225 |
226 // Returns custom wallpaper path. Append |sub_dir|, |user_id_hash| and |file| | |
227 // to custom wallpaper directory. | |
228 static base::FilePath GetCustomWallpaperPath(const char* sub_dir, | |
229 const std::string& user_id_hash, | |
230 const std::string& file); | |
231 | |
232 // Record data for User Metrics Analysis. | |
233 static void RecordUma(User::WallpaperType type, int index); | |
234 | |
235 // Saves original custom wallpaper to |path| (absolute path) on filesystem | |
236 // and starts resizing operation of the custom wallpaper if necessary. | |
237 static void SaveCustomWallpaper(const std::string& user_id_hash, | |
238 const base::FilePath& path, | |
239 ash::WallpaperLayout layout, | |
240 scoped_ptr<gfx::ImageSkia> image); | |
241 | |
242 void SetCommandLineForTesting(base::CommandLine* command_line); | 226 void SetCommandLineForTesting(base::CommandLine* command_line); |
243 | 227 |
244 // Indicates imminent shutdown, allowing the WallpaperManager to remove any | 228 // Indicates imminent shutdown, allowing the WallpaperManager to remove any |
245 // observers it has registered. | 229 // observers it has registered. |
246 void Shutdown(); | 230 void Shutdown(); |
247 | 231 |
248 // Adds PowerManagerClient, TimeZoneSettings and CrosSettings observers. | 232 // Adds PowerManagerClient, TimeZoneSettings and CrosSettings observers. |
249 void AddObservers(); | 233 void AddObservers(); |
250 | 234 |
251 // Loads wallpaper asynchronously if the current wallpaper is not the | 235 // Loads wallpaper asynchronously if the current wallpaper is not the |
252 // wallpaper of logged in user. | 236 // wallpaper of logged in user. |
253 void EnsureLoggedInUserWallpaperLoaded(); | 237 void EnsureLoggedInUserWallpaperLoaded(); |
254 | 238 |
| 239 // Returns custom wallpaper path. Append |sub_dir|, |user_id_hash| and |file| |
| 240 // to custom wallpaper directory. |
| 241 base::FilePath GetCustomWallpaperPath(const char* sub_dir, |
| 242 const std::string& user_id_hash, |
| 243 const std::string& file) const; |
| 244 |
255 // Gets wallpaper information of logged in user. | 245 // Gets wallpaper information of logged in user. |
256 bool GetLoggedInUserWallpaperInfo(WallpaperInfo* info); | 246 bool GetLoggedInUserWallpaperInfo(WallpaperInfo* info); |
257 | 247 |
258 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged | 248 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged |
259 // in, uses a solid color wallpaper. If logged in as a stub user, uses an | 249 // in, uses a solid color wallpaper. If logged in as a stub user, uses an |
260 // empty wallpaper. | 250 // empty wallpaper. |
261 void InitializeWallpaper(); | 251 void InitializeWallpaper(); |
262 | 252 |
263 // NotificationObserver overrides: | 253 // NotificationObserver overrides: |
264 virtual void Observe(int type, | 254 virtual void Observe(int type, |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 | 436 |
447 // Sets wallpaper to the decoded wallpaper if |update_wallpaper| is true. | 437 // Sets wallpaper to the decoded wallpaper if |update_wallpaper| is true. |
448 // Otherwise, cache wallpaper to memory if not logged in. (Takes a UserImage | 438 // Otherwise, cache wallpaper to memory if not logged in. (Takes a UserImage |
449 // because that's the callback interface provided by UserImageLoader.) | 439 // because that's the callback interface provided by UserImageLoader.) |
450 void OnWallpaperDecoded(const std::string& user_id, | 440 void OnWallpaperDecoded(const std::string& user_id, |
451 ash::WallpaperLayout layout, | 441 ash::WallpaperLayout layout, |
452 bool update_wallpaper, | 442 bool update_wallpaper, |
453 MovableOnDestroyCallbackHolder on_finish, | 443 MovableOnDestroyCallbackHolder on_finish, |
454 const UserImage& user_image); | 444 const UserImage& user_image); |
455 | 445 |
| 446 // Record data for User Metrics Analysis. |
| 447 void RecordUma(User::WallpaperType type, int index) const; |
| 448 |
| 449 // Saves original custom wallpaper to |path| (absolute path) on filesystem |
| 450 // and starts resizing operation of the custom wallpaper if necessary. |
| 451 void SaveCustomWallpaper(const std::string& user_id_hash, |
| 452 const base::FilePath& path, |
| 453 ash::WallpaperLayout layout, |
| 454 scoped_ptr<gfx::ImageSkia> image) const; |
| 455 |
456 // Creates new PendingWallpaper request (or updates currently pending). | 456 // Creates new PendingWallpaper request (or updates currently pending). |
457 void ScheduleSetUserWallpaper(const std::string& user_id, bool delayed); | 457 void ScheduleSetUserWallpaper(const std::string& user_id, bool delayed); |
458 | 458 |
459 // Sets wallpaper to default. | 459 // Sets wallpaper to default. |
460 void DoSetDefaultWallpaper( | 460 void DoSetDefaultWallpaper( |
461 const std::string& user_id, | 461 const std::string& user_id, |
462 MovableOnDestroyCallbackHolder on_finish); | 462 MovableOnDestroyCallbackHolder on_finish); |
463 | 463 |
464 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the | 464 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the |
465 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread. | 465 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread. |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 | 607 |
608 // Current decoded default image is stored in cache. | 608 // Current decoded default image is stored in cache. |
609 scoped_ptr<UserImage> default_wallpaper_image_; | 609 scoped_ptr<UserImage> default_wallpaper_image_; |
610 | 610 |
611 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 611 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
612 }; | 612 }; |
613 | 613 |
614 } // namespace chromeos | 614 } // namespace chromeos |
615 | 615 |
616 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ | 616 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ |
OLD | NEW |