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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
331 // Enable surprise me wallpaper mode. | 346 // Enable surprise me wallpaper mode. |
332 void EnableSurpriseMe(); | 347 void EnableSurpriseMe(); |
333 | 348 |
| 349 // This is called from CustomizationDocument. |
| 350 // |resized_directory| is the directory where resized versions are stored and |
| 351 // must be writable. |
| 352 void SetCustomizedDefaultWallpaper(const GURL& wallpaper_url, |
| 353 const base::FilePath& downloaded_file, |
| 354 const base::FilePath& resized_directory); |
| 355 |
334 private: | 356 private: |
335 friend class TestApi; | 357 friend class TestApi; |
336 friend class WallpaperManagerBrowserTest; | 358 friend class WallpaperManagerBrowserTest; |
337 friend class WallpaperManagerBrowserTestDefaultWallpaper; | 359 friend class WallpaperManagerBrowserTestDefaultWallpaper; |
338 friend class WallpaperManagerPolicyTest; | 360 friend class WallpaperManagerPolicyTest; |
339 | 361 |
340 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; | 362 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; |
341 | 363 |
342 // Set |wallpaper| controlled by policy. | 364 // Set |wallpaper| controlled by policy. |
343 void SetPolicyControlledWallpaper(const std::string& user_id, | 365 void SetPolicyControlledWallpaper(const std::string& user_id, |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 PendingWallpaper* GetPendingWallpaper(const std::string& user_id, | 508 PendingWallpaper* GetPendingWallpaper(const std::string& user_id, |
487 bool delayed); | 509 bool delayed); |
488 | 510 |
489 // Calculate delay for next wallpaper load. | 511 // Calculate delay for next wallpaper load. |
490 // It is usually average wallpaper load time. | 512 // It is usually average wallpaper load time. |
491 // If last wallpaper load happened long ago, timeout should be reduced by | 513 // If last wallpaper load happened long ago, timeout should be reduced by |
492 // the time passed after last wallpaper load. So usual user experience results | 514 // the time passed after last wallpaper load. So usual user experience results |
493 // in zero delay. | 515 // in zero delay. |
494 base::TimeDelta GetWallpaperLoadDelay() const; | 516 base::TimeDelta GetWallpaperLoadDelay() const; |
495 | 517 |
| 518 // This is called after we check that supplied default wallpaper files exist. |
| 519 void SetCustomizedDefaultWallpaperAfterCheck( |
| 520 const GURL& wallpaper_url, |
| 521 const base::FilePath& downloaded_file, |
| 522 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files); |
| 523 |
| 524 // Starts rescaling of customized wallpaper. |
| 525 void OnCustomizedDefaultWallpaperDecoded( |
| 526 const GURL& wallpaper_url, |
| 527 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files, |
| 528 const UserImage& user_image); |
| 529 |
| 530 // Resize and save customized default wallpaper. |
| 531 void ResizeCustomizedDefaultWallpaper( |
| 532 scoped_ptr<gfx::ImageSkia> image, |
| 533 const UserImage::RawImage& raw_image, |
| 534 const CustomizedWallpaperRescaledFiles* rescaled_files, |
| 535 bool* success, |
| 536 gfx::ImageSkia* small_wallpaper_image, |
| 537 gfx::ImageSkia* large_wallpaper_image); |
| 538 |
| 539 // Check the result of ResizeCustomizedDefaultWallpaper and finally |
| 540 // apply Customized Default Wallpaper. |
| 541 void OnCustomizedDefaultWallpaperResized( |
| 542 const GURL& wallpaper_url, |
| 543 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files, |
| 544 scoped_ptr<bool> success, |
| 545 scoped_ptr<gfx::ImageSkia> small_wallpaper_image, |
| 546 scoped_ptr<gfx::ImageSkia> large_wallpaper_image); |
| 547 |
496 // Init |*default_*_wallpaper_file_| from given command line and | 548 // Init |*default_*_wallpaper_file_| from given command line and |
497 // clear |default_wallpaper_image_|. | 549 // clear |default_wallpaper_image_|. |
498 void SetDefaultWallpaperPathsFromCommandLine(base::CommandLine* command_line); | 550 void SetDefaultWallpaperPathsFromCommandLine(base::CommandLine* command_line); |
499 | 551 |
500 // Sets wallpaper to decoded default. | 552 // Sets wallpaper to decoded default. |
501 void OnDefaultWallpaperDecoded(const base::FilePath& path, | 553 void OnDefaultWallpaperDecoded(const base::FilePath& path, |
502 const ash::WallpaperLayout layout, | 554 const ash::WallpaperLayout layout, |
503 scoped_ptr<UserImage>* result, | 555 scoped_ptr<UserImage>* result, |
504 MovableOnDestroyCallbackHolder on_finish, | 556 MovableOnDestroyCallbackHolder on_finish, |
505 const UserImage& wallpaper); | 557 const UserImage& wallpaper); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 | 629 |
578 // Current decoded default image is stored in cache. | 630 // Current decoded default image is stored in cache. |
579 scoped_ptr<UserImage> default_wallpaper_image_; | 631 scoped_ptr<UserImage> default_wallpaper_image_; |
580 | 632 |
581 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 633 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
582 }; | 634 }; |
583 | 635 |
584 } // namespace chromeos | 636 } // namespace chromeos |
585 | 637 |
586 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ | 638 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ |
OLD | NEW |