Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: chrome/browser/chromeos/login/wallpaper_manager.h

Issue 236013002: Apply default wallpaper from customization manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: After-review. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // exist. 401 // exist.
380 void EnsureCustomWallpaperDirectories(const std::string& user_id_hash); 402 void EnsureCustomWallpaperDirectories(const std::string& user_id_hash);
381 403
382 // Gets the CommandLine representing the current process's command line. 404 // Gets the CommandLine representing the current process's command line.
383 base::CommandLine* GetCommandLine(); 405 base::CommandLine* GetCommandLine();
384 406
385 // Initialize wallpaper of registered device after device policy is trusted. 407 // Initialize wallpaper of registered device after device policy is trusted.
386 // Note that before device is enrolled, it proceeds with untrusted setting. 408 // Note that before device is enrolled, it proceeds with untrusted setting.
387 void InitializeRegisteredDeviceWallpaper(); 409 void InitializeRegisteredDeviceWallpaper();
388 410
389 // Loads |user_id|'s wallpaper. When |update_wallpaper| is true, sets
390 // wallpaper to the loaded wallpaper. 411 // wallpaper to the loaded wallpaper.
Daniel Erat 2014/04/15 03:06:30 you accidentally deleted the line above this one,
Alexander Alekseev 2014/04/15 22:47:31 Done.
391 void LoadWallpaper(const std::string& user_id, 412 void LoadWallpaper(const std::string& user_id,
392 const WallpaperInfo& info, 413 const WallpaperInfo& info,
393 bool update_wallpaper, 414 bool update_wallpaper,
394 MovableOnDestroyCallbackHolder on_finish); 415 MovableOnDestroyCallbackHolder on_finish);
395 416
396 // Moves custom wallpapers from |user_id| directory to |user_id_hash| 417 // Moves custom wallpapers from |user_id| directory to |user_id_hash|
397 // directory. 418 // directory.
398 void MoveCustomWallpapersOnWorker(const std::string& user_id, 419 void MoveCustomWallpapersOnWorker(const std::string& user_id,
399 const std::string& user_id_hash); 420 const std::string& user_id_hash);
400 421
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 PendingWallpaper* GetPendingWallpaper(const std::string& user_id, 504 PendingWallpaper* GetPendingWallpaper(const std::string& user_id,
484 bool delayed); 505 bool delayed);
485 506
486 // Calculate delay for next wallpaper load. 507 // Calculate delay for next wallpaper load.
487 // It is usually average wallpaper load time. 508 // It is usually average wallpaper load time.
488 // If last wallpaper load happened long ago, timeout should be reduced by 509 // 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 510 // the time passed after last wallpaper load. So usual user experience results
490 // in zero delay. 511 // in zero delay.
491 base::TimeDelta GetWallpaperLoadDelay() const; 512 base::TimeDelta GetWallpaperLoadDelay() const;
492 513
514 // This is called after we check that supplied default wallpaper files exist.
515 void SetCustomizedDefaultWallpaperAfterCheck(
516 const GURL& wallpaper_url,
517 const base::FilePath& downloaded_file,
518 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files);
519
520 // Starts rescaling of customized wallpaper.
521 void OnCustomizedDefaultWallpaperDecoded(
522 const GURL& wallpaper_url,
523 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files,
524 const UserImage& user_image);
525
526 // Resize and save customized default wallpaper.
527 void ResizeCustomizedDefaultWallpaper(
528 scoped_ptr<gfx::ImageSkia> image,
529 const UserImage::RawImage& raw_image,
530 const CustomizedWallpaperRescaledFiles* rescaled_files,
531 bool* success,
532 gfx::ImageSkia* small_wallpaper_image,
533 gfx::ImageSkia* large_wallpaper_image);
534
535 // Check the result of ResizeCustomizedDefaultWallpaper and finally
536 // apply Customized Default Wallpaper.
537 void OnCustomizedDefaultWallpaperResized(
538 const GURL& wallpaper_url,
539 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files,
540 scoped_ptr<bool> success,
541 scoped_ptr<gfx::ImageSkia> small_wallpaper_image,
542 scoped_ptr<gfx::ImageSkia> large_wallpaper_image);
543
493 // Init |*default_*_wallpaper_file_| from given command line and 544 // Init |*default_*_wallpaper_file_| from given command line and
494 // clear |default_wallpaper_image_|. 545 // clear |default_wallpaper_image_|.
495 void SetDefaultWallpaperPathsFromCommandLine(base::CommandLine* command_line); 546 void SetDefaultWallpaperPathsFromCommandLine(base::CommandLine* command_line);
496 547
497 // Sets wallpaper to decoded default. 548 // Sets wallpaper to decoded default.
498 void OnDefaultWallpaperDecoded(const base::FilePath& path, 549 void OnDefaultWallpaperDecoded(const base::FilePath& path,
499 const ash::WallpaperLayout layout, 550 const ash::WallpaperLayout layout,
500 scoped_ptr<UserImage>* result, 551 scoped_ptr<UserImage>* result,
501 MovableOnDestroyCallbackHolder on_finish, 552 MovableOnDestroyCallbackHolder on_finish,
502 const UserImage& wallpaper); 553 const UserImage& wallpaper);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 625
575 // Current decoded default image is stored in cache. 626 // Current decoded default image is stored in cache.
576 scoped_ptr<UserImage> default_wallpaper_image_; 627 scoped_ptr<UserImage> default_wallpaper_image_;
577 628
578 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); 629 DISALLOW_COPY_AND_ASSIGN(WallpaperManager);
579 }; 630 };
580 631
581 } // namespace chromeos 632 } // namespace chromeos
582 633
583 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_ 634 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WALLPAPER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698