OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 const gfx::ImageSkia& image); | 105 const gfx::ImageSkia& image); |
106 | 106 |
107 void ClearDisposableWallpaperCache(); | 107 void ClearDisposableWallpaperCache(); |
108 | 108 |
109 private: | 109 private: |
110 WallpaperManager* wallpaper_manager_; // not owned | 110 WallpaperManager* wallpaper_manager_; // not owned |
111 | 111 |
112 DISALLOW_COPY_AND_ASSIGN(TestApi); | 112 DISALLOW_COPY_AND_ASSIGN(TestApi); |
113 }; | 113 }; |
114 | 114 |
| 115 // This should be public to allow access from functions in anonymous |
| 116 // namespace. |
| 117 class CustomizedWallpaperRescaledFiles; |
| 118 |
115 class Observer { | 119 class Observer { |
116 public: | 120 public: |
117 virtual ~Observer() {} | 121 virtual ~Observer() {} |
118 virtual void OnWallpaperAnimationFinished(const std::string& user_id) = 0; | 122 virtual void OnWallpaperAnimationFinished(const std::string& user_id) = 0; |
119 virtual void OnUpdateWallpaperForTesting() {} | 123 virtual void OnUpdateWallpaperForTesting() {} |
120 }; | 124 }; |
121 | 125 |
122 // This is "wallpaper either scheduled to load, or loading right now". | 126 // This is "wallpaper either scheduled to load, or loading right now". |
123 // | 127 // |
124 // While enqueued, it defines moment in the future, when it will be loaded. | 128 // While enqueued, it defines moment in the future, when it will be loaded. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 // local state preferences. If |update_wallpaper| is false, don't change | 263 // local state preferences. If |update_wallpaper| is false, don't change |
260 // wallpaper but only update cache. | 264 // wallpaper but only update cache. |
261 void SetCustomWallpaper(const std::string& user_id, | 265 void SetCustomWallpaper(const std::string& user_id, |
262 const std::string& user_id_hash, | 266 const std::string& user_id_hash, |
263 const std::string& file, | 267 const std::string& file, |
264 ash::WallpaperLayout layout, | 268 ash::WallpaperLayout layout, |
265 User::WallpaperType type, | 269 User::WallpaperType type, |
266 const UserImage& wallpaper, | 270 const UserImage& wallpaper, |
267 bool update_wallpaper); | 271 bool update_wallpaper); |
268 | 272 |
| 273 // Use given files as new default wallpaper. |
| 274 // Reloads current wallpaper, if old default was loaded. |
| 275 // Current value of default_wallpaper_image_ is destroyed. |
| 276 // Sets default_wallpaper_image_ either to |small_wallpaper_image| or |
| 277 // |large_wallpaper_image| depending on GetAppropriateResolution(). |
| 278 void SetDefaultWallpaperPath( |
| 279 const base::FilePath& customized_default_wallpaper_file_small, |
| 280 scoped_ptr<gfx::ImageSkia> small_wallpaper_image, |
| 281 const base::FilePath& customized_default_wallpaper_file_large, |
| 282 scoped_ptr<gfx::ImageSkia> large_wallpaper_image); |
| 283 |
269 // Sets wallpaper to default wallpaper (asynchronously with zero delay). | 284 // Sets wallpaper to default wallpaper (asynchronously with zero delay). |
270 void SetDefaultWallpaperNow(const std::string& user_id); | 285 void SetDefaultWallpaperNow(const std::string& user_id); |
271 | 286 |
272 // Sets wallpaper to default wallpaper (asynchronously with default delay). | 287 // Sets wallpaper to default wallpaper (asynchronously with default delay). |
273 void SetDefaultWallpaperDelayed(const std::string& user_id); | 288 void SetDefaultWallpaperDelayed(const std::string& user_id); |
274 | 289 |
275 // Initialize wallpaper for the specified user to default and saves this | 290 // Initialize wallpaper for the specified user to default and saves this |
276 // settings in local state. | 291 // settings in local state. |
277 void InitInitialUserWallpaper(const std::string& user_id, | 292 void InitInitialUserWallpaper(const std::string& user_id, |
278 bool is_persistent); | 293 bool is_persistent); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 336 |
322 // Called when the policy-set wallpaper has been fetched. Initiates decoding | 337 // Called when the policy-set wallpaper has been fetched. Initiates decoding |
323 // of the JPEG |data| with a callback to SetPolicyControlledWallpaper(). | 338 // of the JPEG |data| with a callback to SetPolicyControlledWallpaper(). |
324 void OnPolicyFetched(const std::string& policy, | 339 void OnPolicyFetched(const std::string& policy, |
325 const std::string& user_id, | 340 const std::string& user_id, |
326 scoped_ptr<std::string> data); | 341 scoped_ptr<std::string> data); |
327 | 342 |
328 // Returns the appropriate wallpaper resolution for all root windows. | 343 // Returns the appropriate wallpaper resolution for all root windows. |
329 static WallpaperResolution GetAppropriateResolution(); | 344 static WallpaperResolution GetAppropriateResolution(); |
330 | 345 |
| 346 // This is called from CustomizationDocument. |
| 347 // |resized_directory| is the directory where resized versions are stored and |
| 348 // must be writable. |
| 349 void SetCustomizedDefaultWallpaper(const GURL& wallpaper_url, |
| 350 const base::FilePath& downloaded_file, |
| 351 const base::FilePath& resized_directory); |
| 352 |
331 private: | 353 private: |
332 friend class TestApi; | 354 friend class TestApi; |
333 friend class WallpaperManagerBrowserTest; | 355 friend class WallpaperManagerBrowserTest; |
334 friend class WallpaperManagerBrowserTestDefaultWallpaper; | 356 friend class WallpaperManagerBrowserTestDefaultWallpaper; |
335 friend class WallpaperManagerPolicyTest; | 357 friend class WallpaperManagerPolicyTest; |
336 | 358 |
337 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; | 359 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; |
338 | 360 |
339 // Set |wallpaper| controlled by policy. | 361 // Set |wallpaper| controlled by policy. |
340 void SetPolicyControlledWallpaper(const std::string& user_id, | 362 void SetPolicyControlledWallpaper(const std::string& user_id, |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 PendingWallpaper* GetPendingWallpaper(const std::string& user_id, | 505 PendingWallpaper* GetPendingWallpaper(const std::string& user_id, |
484 bool delayed); | 506 bool delayed); |
485 | 507 |
486 // Calculate delay for next wallpaper load. | 508 // Calculate delay for next wallpaper load. |
487 // It is usually average wallpaper load time. | 509 // It is usually average wallpaper load time. |
488 // If last wallpaper load happened long ago, timeout should be reduced by | 510 // If last wallpaper load happened long ago, timeout should be reduced by |
489 // the time passed after last wallpaper load. So usual user experience results | 511 // the time passed after last wallpaper load. So usual user experience results |
490 // in zero delay. | 512 // in zero delay. |
491 base::TimeDelta GetWallpaperLoadDelay() const; | 513 base::TimeDelta GetWallpaperLoadDelay() const; |
492 | 514 |
| 515 // This is called after we check that supplied default wallpaper files exist. |
| 516 void SetCustomizedDefaultWallpaperAfterCheck( |
| 517 const GURL& wallpaper_url, |
| 518 const base::FilePath& downloaded_file, |
| 519 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files); |
| 520 |
| 521 // Starts rescaling of customized wallpaper. |
| 522 void OnCustomizedDefaultWallpaperDecoded( |
| 523 const GURL& wallpaper_url, |
| 524 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files, |
| 525 const UserImage& user_image); |
| 526 |
| 527 // Resize and save customized default wallpaper. |
| 528 void ResizeCustomizedDefaultWallpaper( |
| 529 scoped_ptr<gfx::ImageSkia> image, |
| 530 const UserImage::RawImage& raw_image, |
| 531 const CustomizedWallpaperRescaledFiles* rescaled_files, |
| 532 bool* success, |
| 533 gfx::ImageSkia* small_wallpaper_image, |
| 534 gfx::ImageSkia* large_wallpaper_image); |
| 535 |
| 536 // Check the result of ResizeCustomizedDefaultWallpaper and finally |
| 537 // apply Customized Default Wallpaper. |
| 538 void OnCustomizedDefaultWallpaperResized( |
| 539 const GURL& wallpaper_url, |
| 540 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files, |
| 541 scoped_ptr<bool> success, |
| 542 scoped_ptr<gfx::ImageSkia> small_wallpaper_image, |
| 543 scoped_ptr<gfx::ImageSkia> large_wallpaper_image); |
| 544 |
493 // Init |*default_*_wallpaper_file_| from given command line and | 545 // Init |*default_*_wallpaper_file_| from given command line and |
494 // clear |default_wallpaper_image_|. | 546 // clear |default_wallpaper_image_|. |
495 void SetDefaultWallpaperPathsFromCommandLine(base::CommandLine* command_line); | 547 void SetDefaultWallpaperPathsFromCommandLine(base::CommandLine* command_line); |
496 | 548 |
497 // Sets wallpaper to decoded default. | 549 // Sets wallpaper to decoded default. |
498 void OnDefaultWallpaperDecoded(const base::FilePath& path, | 550 void OnDefaultWallpaperDecoded(const base::FilePath& path, |
499 const ash::WallpaperLayout layout, | 551 const ash::WallpaperLayout layout, |
500 scoped_ptr<UserImage>* result, | 552 scoped_ptr<UserImage>* result, |
501 MovableOnDestroyCallbackHolder on_finish, | 553 MovableOnDestroyCallbackHolder on_finish, |
502 const UserImage& wallpaper); | 554 const UserImage& wallpaper); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 | 626 |
575 // Current decoded default image is stored in cache. | 627 // Current decoded default image is stored in cache. |
576 scoped_ptr<UserImage> default_wallpaper_image_; | 628 scoped_ptr<UserImage> default_wallpaper_image_; |
577 | 629 |
578 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 630 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
579 }; | 631 }; |
580 | 632 |
581 } // namespace chromeos | 633 } // namespace chromeos |
582 | 634 |
583 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 635 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
OLD | NEW |