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> |
11 | 11 |
12 #include "ash/desktop_background/desktop_background_controller.h" | 12 #include "ash/desktop_background/desktop_background_controller.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "base/threading/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "chrome/browser/chromeos/login/users/avatar/user_image_loader.h" | 20 #include "chrome/browser/chromeos/login/users/avatar/user_image_loader.h" |
21 #include "chrome/browser/chromeos/login/users/user.h" | |
22 #include "chrome/browser/chromeos/settings/cros_settings.h" | 21 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 22 #include "components/user_manager/user.h" |
23 #include "components/user_manager/user_image/user_image.h" | 23 #include "components/user_manager/user_image/user_image.h" |
24 #include "content/public/browser/notification_observer.h" | 24 #include "content/public/browser/notification_observer.h" |
25 #include "content/public/browser/notification_registrar.h" | 25 #include "content/public/browser/notification_registrar.h" |
26 #include "third_party/icu/source/i18n/unicode/timezone.h" | 26 #include "third_party/icu/source/i18n/unicode/timezone.h" |
27 #include "ui/gfx/image/image_skia.h" | 27 #include "ui/gfx/image/image_skia.h" |
28 | 28 |
29 class PrefRegistrySimple; | 29 class PrefRegistrySimple; |
30 | 30 |
31 namespace base { | 31 namespace base { |
32 class CommandLine; | 32 class CommandLine; |
33 class SequencedTaskRunner; | 33 class SequencedTaskRunner; |
34 } | 34 } |
35 | 35 |
36 namespace user_manager { | 36 namespace user_manager { |
| 37 class User; |
37 class UserImage; | 38 class UserImage; |
38 } | 39 } |
39 | 40 |
40 namespace chromeos { | 41 namespace chromeos { |
41 | 42 |
42 struct WallpaperInfo { | 43 struct WallpaperInfo { |
43 // Online wallpaper URL or file name of migrated wallpaper. | 44 // Online wallpaper URL or file name of migrated wallpaper. |
44 std::string file; | 45 std::string file; |
45 ash::WallpaperLayout layout; | 46 ash::WallpaperLayout layout; |
46 User::WallpaperType type; | 47 user_manager::User::WallpaperType type; |
47 base::Time date; | 48 base::Time date; |
48 bool operator==(const WallpaperInfo& other) { | 49 bool operator==(const WallpaperInfo& other) { |
49 return (file == other.file) && (layout == other.layout) && | 50 return (file == other.file) && (layout == other.layout) && |
50 (type == other.type); | 51 (type == other.type); |
51 } | 52 } |
52 }; | 53 }; |
53 | 54 |
54 class MovableOnDestroyCallback; | 55 class MovableOnDestroyCallback; |
55 typedef scoped_ptr<MovableOnDestroyCallback> MovableOnDestroyCallbackHolder; | 56 typedef scoped_ptr<MovableOnDestroyCallback> MovableOnDestroyCallbackHolder; |
56 | 57 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 // Removes all |user_id| related wallpaper info and saved wallpapers. | 262 // Removes all |user_id| related wallpaper info and saved wallpapers. |
262 void RemoveUserWallpaperInfo(const std::string& user_id); | 263 void RemoveUserWallpaperInfo(const std::string& user_id); |
263 | 264 |
264 // Saves custom wallpaper to file, post task to generate thumbnail and updates | 265 // Saves custom wallpaper to file, post task to generate thumbnail and updates |
265 // local state preferences. If |update_wallpaper| is false, don't change | 266 // local state preferences. If |update_wallpaper| is false, don't change |
266 // wallpaper but only update cache. | 267 // wallpaper but only update cache. |
267 void SetCustomWallpaper(const std::string& user_id, | 268 void SetCustomWallpaper(const std::string& user_id, |
268 const std::string& user_id_hash, | 269 const std::string& user_id_hash, |
269 const std::string& file, | 270 const std::string& file, |
270 ash::WallpaperLayout layout, | 271 ash::WallpaperLayout layout, |
271 User::WallpaperType type, | 272 user_manager::User::WallpaperType type, |
272 const gfx::ImageSkia& image, | 273 const gfx::ImageSkia& image, |
273 bool update_wallpaper); | 274 bool update_wallpaper); |
274 | 275 |
275 // Use given files as new default wallpaper. | 276 // Use given files as new default wallpaper. |
276 // Reloads current wallpaper, if old default was loaded. | 277 // Reloads current wallpaper, if old default was loaded. |
277 // Current value of default_wallpaper_image_ is destroyed. | 278 // Current value of default_wallpaper_image_ is destroyed. |
278 // Sets default_wallpaper_image_ either to |small_wallpaper_image| or | 279 // Sets default_wallpaper_image_ either to |small_wallpaper_image| or |
279 // |large_wallpaper_image| depending on GetAppropriateResolution(). | 280 // |large_wallpaper_image| depending on GetAppropriateResolution(). |
280 void SetDefaultWallpaperPath( | 281 void SetDefaultWallpaperPath( |
281 const base::FilePath& customized_default_wallpaper_file_small, | 282 const base::FilePath& customized_default_wallpaper_file_small, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 friend class TestApi; | 349 friend class TestApi; |
349 friend class PendingWallpaper; | 350 friend class PendingWallpaper; |
350 friend class WallpaperManagerBrowserTest; | 351 friend class WallpaperManagerBrowserTest; |
351 friend class WallpaperManagerBrowserTestDefaultWallpaper; | 352 friend class WallpaperManagerBrowserTestDefaultWallpaper; |
352 friend class WallpaperManagerPolicyTest; | 353 friend class WallpaperManagerPolicyTest; |
353 | 354 |
354 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; | 355 typedef std::map<std::string, gfx::ImageSkia> CustomWallpaperMap; |
355 | 356 |
356 | 357 |
357 // Record data for User Metrics Analysis. | 358 // Record data for User Metrics Analysis. |
358 static void RecordUma(User::WallpaperType type, int index); | 359 static void RecordUma(user_manager::User::WallpaperType type, int index); |
359 | 360 |
360 // Saves original custom wallpaper to |path| (absolute path) on filesystem | 361 // Saves original custom wallpaper to |path| (absolute path) on filesystem |
361 // and starts resizing operation of the custom wallpaper if necessary. | 362 // and starts resizing operation of the custom wallpaper if necessary. |
362 static void SaveCustomWallpaper(const std::string& user_id_hash, | 363 static void SaveCustomWallpaper(const std::string& user_id_hash, |
363 const base::FilePath& path, | 364 const base::FilePath& path, |
364 ash::WallpaperLayout layout, | 365 ash::WallpaperLayout layout, |
365 scoped_ptr<gfx::ImageSkia> image); | 366 scoped_ptr<gfx::ImageSkia> image); |
366 | 367 |
367 // Moves custom wallpapers from |user_id| directory to |user_id_hash| | 368 // Moves custom wallpapers from |user_id| directory to |user_id_hash| |
368 // directory. | 369 // directory. |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 | 618 |
618 // Current decoded default image is stored in cache. | 619 // Current decoded default image is stored in cache. |
619 scoped_ptr<user_manager::UserImage> default_wallpaper_image_; | 620 scoped_ptr<user_manager::UserImage> default_wallpaper_image_; |
620 | 621 |
621 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 622 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
622 }; | 623 }; |
623 | 624 |
624 } // namespace chromeos | 625 } // namespace chromeos |
625 | 626 |
626 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ | 627 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ |
OLD | NEW |