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

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

Issue 322233002: Remove more unretained (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
226 void SetCommandLineForTesting(base::CommandLine* command_line); 242 void SetCommandLineForTesting(base::CommandLine* command_line);
227 243
228 // Indicates imminent shutdown, allowing the WallpaperManager to remove any 244 // Indicates imminent shutdown, allowing the WallpaperManager to remove any
229 // observers it has registered. 245 // observers it has registered.
230 void Shutdown(); 246 void Shutdown();
231 247
232 // Adds PowerManagerClient, TimeZoneSettings and CrosSettings observers. 248 // Adds PowerManagerClient, TimeZoneSettings and CrosSettings observers.
233 void AddObservers(); 249 void AddObservers();
234 250
235 // Loads wallpaper asynchronously if the current wallpaper is not the 251 // Loads wallpaper asynchronously if the current wallpaper is not the
236 // wallpaper of logged in user. 252 // wallpaper of logged in user.
237 void EnsureLoggedInUserWallpaperLoaded(); 253 void EnsureLoggedInUserWallpaperLoaded();
238 254
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
245 // Gets wallpaper information of logged in user. 255 // Gets wallpaper information of logged in user.
246 bool GetLoggedInUserWallpaperInfo(WallpaperInfo* info); 256 bool GetLoggedInUserWallpaperInfo(WallpaperInfo* info);
247 257
248 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged 258 // Initializes wallpaper. If logged in, loads user's wallpaper. If not logged
249 // in, uses a solid color wallpaper. If logged in as a stub user, uses an 259 // in, uses a solid color wallpaper. If logged in as a stub user, uses an
250 // empty wallpaper. 260 // empty wallpaper.
251 void InitializeWallpaper(); 261 void InitializeWallpaper();
252 262
253 // NotificationObserver overrides: 263 // NotificationObserver overrides:
254 virtual void Observe(int type, 264 virtual void Observe(int type,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 // must be writable. 346 // must be writable.
337 void SetCustomizedDefaultWallpaper(const GURL& wallpaper_url, 347 void SetCustomizedDefaultWallpaper(const GURL& wallpaper_url,
338 const base::FilePath& downloaded_file, 348 const base::FilePath& downloaded_file,
339 const base::FilePath& resized_directory); 349 const base::FilePath& resized_directory);
340 350
341 // Returns queue size. 351 // Returns queue size.
342 size_t GetPendingListSizeForTesting() const; 352 size_t GetPendingListSizeForTesting() const;
343 353
344 private: 354 private:
345 friend class TestApi; 355 friend class TestApi;
356 friend class PendingWallpaper;
346 friend class WallpaperManagerBrowserTest; 357 friend class WallpaperManagerBrowserTest;
347 friend class WallpaperManagerBrowserTestDefaultWallpaper; 358 friend class WallpaperManagerBrowserTestDefaultWallpaper;
348 friend class WallpaperManagerPolicyTest; 359 friend class WallpaperManagerPolicyTest;
349 360
350 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; 361 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap;
351 362
352 // Initialize wallpaper for the specified user to default and saves this 363 // Initialize wallpaper for the specified user to default and saves this
353 // settings in local state. 364 // settings in local state.
354 void InitInitialUserWallpaper(const std::string& user_id, bool is_persistent); 365 void InitInitialUserWallpaper(const std::string& user_id, bool is_persistent);
355 366
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 410
400 // Loads |user_id|'s wallpaper. When |update_wallpaper| is true, sets 411 // Loads |user_id|'s wallpaper. When |update_wallpaper| is true, sets
401 // wallpaper to the loaded wallpaper. 412 // wallpaper to the loaded wallpaper.
402 void LoadWallpaper(const std::string& user_id, 413 void LoadWallpaper(const std::string& user_id,
403 const WallpaperInfo& info, 414 const WallpaperInfo& info,
404 bool update_wallpaper, 415 bool update_wallpaper,
405 MovableOnDestroyCallbackHolder on_finish); 416 MovableOnDestroyCallbackHolder on_finish);
406 417
407 // Moves custom wallpapers from |user_id| directory to |user_id_hash| 418 // Moves custom wallpapers from |user_id| directory to |user_id_hash|
408 // directory. 419 // directory.
409 void MoveCustomWallpapersOnWorker(const std::string& user_id, 420 static void MoveCustomWallpapersOnWorker(
410 const std::string& user_id_hash); 421 const std::string& user_id,
422 const std::string& user_id_hash,
423 base::WeakPtr<WallpaperManager> weak_ptr);
411 424
412 // Called when the original custom wallpaper is moved to the new place. 425 // Called when the original custom wallpaper is moved to the new place.
413 // Updates the corresponding user wallpaper info. 426 // Updates the corresponding user wallpaper info.
414 void MoveCustomWallpapersSuccess(const std::string& user_id, 427 void MoveCustomWallpapersSuccess(const std::string& user_id,
415 const std::string& user_id_hash); 428 const std::string& user_id_hash);
416 429
417 // Moves custom wallpaper to a new place. Email address was used as directory 430 // Moves custom wallpaper to a new place. Email address was used as directory
418 // name in the old system, this is not safe. New directory system uses 431 // name in the old system, this is not safe. New directory system uses
419 // user_id_hash instead of user_id. This must be called after user_id_hash is 432 // user_id_hash instead of user_id. This must be called after user_id_hash is
420 // ready. 433 // ready.
421 void MoveLoggedInUserCustomWallpaper(); 434 void MoveLoggedInUserCustomWallpaper();
422 435
423 // Gets |user_id|'s custom wallpaper at |wallpaper_path|. Falls back on 436 // Gets |user_id|'s custom wallpaper at |wallpaper_path|. Falls back on
424 // original custom wallpaper. When |update_wallpaper| is true, sets wallpaper 437 // original custom wallpaper. When |update_wallpaper| is true, sets wallpaper
425 // to the loaded wallpaper. Must run on wallpaper sequenced worker thread. 438 // to the loaded wallpaper. Must run on wallpaper sequenced worker thread.
426 void GetCustomWallpaperInternal(const std::string& user_id, 439 static void GetCustomWallpaperInternal(
427 const WallpaperInfo& info, 440 const std::string& user_id,
428 const base::FilePath& wallpaper_path, 441 const WallpaperInfo& info,
429 bool update_wallpaper, 442 const base::FilePath& wallpaper_path,
430 MovableOnDestroyCallbackHolder on_finish); 443 bool update_wallpaper,
444 MovableOnDestroyCallbackHolder on_finish,
445 base::WeakPtr<WallpaperManager> weak_ptr);
431 446
432 // Gets wallpaper information of |user_id| from Local State or memory. Returns 447 // Gets wallpaper information of |user_id| from Local State or memory. Returns
433 // false if wallpaper information is not found. 448 // false if wallpaper information is not found.
434 bool GetUserWallpaperInfo(const std::string& user_id, 449 bool GetUserWallpaperInfo(const std::string& user_id,
435 WallpaperInfo* info) const; 450 WallpaperInfo* info) const;
436 451
437 // Sets wallpaper to the decoded wallpaper if |update_wallpaper| is true. 452 // Sets wallpaper to the decoded wallpaper if |update_wallpaper| is true.
438 // Otherwise, cache wallpaper to memory if not logged in. (Takes a UserImage 453 // Otherwise, cache wallpaper to memory if not logged in. (Takes a UserImage
439 // because that's the callback interface provided by UserImageLoader.) 454 // because that's the callback interface provided by UserImageLoader.)
440 void OnWallpaperDecoded(const std::string& user_id, 455 void OnWallpaperDecoded(const std::string& user_id,
441 ash::WallpaperLayout layout, 456 ash::WallpaperLayout layout,
442 bool update_wallpaper, 457 bool update_wallpaper,
443 MovableOnDestroyCallbackHolder on_finish, 458 MovableOnDestroyCallbackHolder on_finish,
444 const UserImage& user_image); 459 const UserImage& user_image);
445 460
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). 461 // Creates new PendingWallpaper request (or updates currently pending).
457 void ScheduleSetUserWallpaper(const std::string& user_id, bool delayed); 462 void ScheduleSetUserWallpaper(const std::string& user_id, bool delayed);
458 463
459 // Sets wallpaper to default. 464 // Sets wallpaper to default.
460 void DoSetDefaultWallpaper( 465 void DoSetDefaultWallpaper(
461 const std::string& user_id, 466 const std::string& user_id,
462 MovableOnDestroyCallbackHolder on_finish); 467 MovableOnDestroyCallbackHolder on_finish);
463 468
464 // Starts to load wallpaper at |wallpaper_path|. If |wallpaper_path| is the 469 // 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. 470 // same as |current_wallpaper_path_|, do nothing. Must be called on UI thread.
(...skipping 30 matching lines...) Expand all
496 const base::FilePath& downloaded_file, 501 const base::FilePath& downloaded_file,
497 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files); 502 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files);
498 503
499 // Starts rescaling of customized wallpaper. 504 // Starts rescaling of customized wallpaper.
500 void OnCustomizedDefaultWallpaperDecoded( 505 void OnCustomizedDefaultWallpaperDecoded(
501 const GURL& wallpaper_url, 506 const GURL& wallpaper_url,
502 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files, 507 scoped_ptr<CustomizedWallpaperRescaledFiles> rescaled_files,
503 const UserImage& user_image); 508 const UserImage& user_image);
504 509
505 // Resize and save customized default wallpaper. 510 // Resize and save customized default wallpaper.
506 void ResizeCustomizedDefaultWallpaper( 511 static void ResizeCustomizedDefaultWallpaper(
507 scoped_ptr<gfx::ImageSkia> image, 512 scoped_ptr<gfx::ImageSkia> image,
508 const UserImage::RawImage& raw_image, 513 const UserImage::RawImage& raw_image,
509 const CustomizedWallpaperRescaledFiles* rescaled_files, 514 const CustomizedWallpaperRescaledFiles* rescaled_files,
510 bool* success, 515 bool* success,
511 gfx::ImageSkia* small_wallpaper_image, 516 gfx::ImageSkia* small_wallpaper_image,
512 gfx::ImageSkia* large_wallpaper_image); 517 gfx::ImageSkia* large_wallpaper_image);
513 518
514 // Check the result of ResizeCustomizedDefaultWallpaper and finally 519 // Check the result of ResizeCustomizedDefaultWallpaper and finally
515 // apply Customized Default Wallpaper. 520 // apply Customized Default Wallpaper.
516 void OnCustomizedDefaultWallpaperResized( 521 void OnCustomizedDefaultWallpaperResized(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 612
608 // Current decoded default image is stored in cache. 613 // Current decoded default image is stored in cache.
609 scoped_ptr<UserImage> default_wallpaper_image_; 614 scoped_ptr<UserImage> default_wallpaper_image_;
610 615
611 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); 616 DISALLOW_COPY_AND_ASSIGN(WallpaperManager);
612 }; 617 };
613 618
614 } // namespace chromeos 619 } // namespace chromeos
615 620
616 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ 621 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698