| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "ash/public/interfaces/wallpaper.mojom.h" | 12 #include "ash/public/interfaces/wallpaper.mojom.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "chrome/browser/chromeos/settings/cros_settings.h" | 16 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 17 #include "components/user_manager/user.h" | 17 #include "components/user_manager/user.h" |
| 18 #include "components/user_manager/user_image/user_image.h" | 18 #include "components/user_manager/user_image/user_image.h" |
| 19 #include "components/user_manager/user_manager.h" | 19 #include "components/user_manager/user_manager.h" |
| 20 #include "components/wallpaper/wallpaper_layout.h" | 20 #include "components/wallpaper/wallpaper_layout.h" |
| 21 #include "components/wallpaper/wallpaper_manager_base.h" | 21 #include "components/wallpaper/wallpaper_manager_base.h" |
| 22 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
| 23 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
| 24 #include "mojo/public/cpp/bindings/binding_set.h" | 24 #include "mojo/public/cpp/bindings/binding.h" |
| 25 #include "ui/gfx/image/image_skia.h" | 25 #include "ui/gfx/image/image_skia.h" |
| 26 | 26 |
| 27 namespace chromeos { | 27 namespace chromeos { |
| 28 | 28 |
| 29 class WallpaperManager | 29 class WallpaperManager |
| 30 : public wallpaper::WallpaperManagerBase, | 30 : public wallpaper::WallpaperManagerBase, |
| 31 public ash::mojom::WallpaperManager, | 31 public ash::mojom::WallpaperPicker, |
| 32 public content::NotificationObserver, | 32 public content::NotificationObserver, |
| 33 public user_manager::UserManager::UserSessionStateObserver { | 33 public user_manager::UserManager::UserSessionStateObserver { |
| 34 public: | 34 public: |
| 35 class PendingWallpaper; | 35 class PendingWallpaper; |
| 36 | 36 |
| 37 ~WallpaperManager() override; | 37 ~WallpaperManager() override; |
| 38 | 38 |
| 39 // Creates an instance of Wallpaper Manager. If there is no instance, create | 39 // Creates an instance of Wallpaper Manager. If there is no instance, create |
| 40 // one. Otherwise, returns the existing instance. | 40 // one. Otherwise, returns the existing instance. |
| 41 static void Initialize(); | 41 static void Initialize(); |
| 42 | 42 |
| 43 // Gets pointer to singleton WallpaperManager instance. | 43 // Gets pointer to singleton WallpaperManager instance. |
| 44 static WallpaperManager* Get(); | 44 static WallpaperManager* Get(); |
| 45 | 45 |
| 46 // Deletes the existing instance of WallpaperManager. Allows the | 46 // Deletes the existing instance of WallpaperManager. Allows the |
| 47 // WallpaperManager to remove any observers it has registered. | 47 // WallpaperManager to remove any observers it has registered. |
| 48 static void Shutdown(); | 48 static void Shutdown(); |
| 49 | 49 |
| 50 // Binds the mojom::WallpaperManager interface request to this object. | |
| 51 void BindRequest(ash::mojom::WallpaperManagerRequest request); | |
| 52 | |
| 53 // wallpaper::WallpaperManagerBase: | 50 // wallpaper::WallpaperManagerBase: |
| 54 WallpaperResolution GetAppropriateResolution() override; | 51 WallpaperResolution GetAppropriateResolution() override; |
| 55 void AddObservers() override; | 52 void AddObservers() override; |
| 56 void EnsureLoggedInUserWallpaperLoaded() override; | 53 void EnsureLoggedInUserWallpaperLoaded() override; |
| 57 void InitializeWallpaper() override; | 54 void InitializeWallpaper() override; |
| 58 void RemoveUserWallpaperInfo(const AccountId& account_id) override; | 55 void RemoveUserWallpaperInfo(const AccountId& account_id) override; |
| 59 void OnPolicyFetched(const std::string& policy, | 56 void OnPolicyFetched(const std::string& policy, |
| 60 const AccountId& account_id, | 57 const AccountId& account_id, |
| 61 std::unique_ptr<std::string> data) override; | 58 std::unique_ptr<std::string> data) override; |
| 62 void SetCustomWallpaper(const AccountId& account_id, | 59 void SetCustomWallpaper(const AccountId& account_id, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 78 bool delayed) override; | 75 bool delayed) override; |
| 79 void SetWallpaperFromImageSkia(const AccountId& account_id, | 76 void SetWallpaperFromImageSkia(const AccountId& account_id, |
| 80 const gfx::ImageSkia& image, | 77 const gfx::ImageSkia& image, |
| 81 wallpaper::WallpaperLayout layout, | 78 wallpaper::WallpaperLayout layout, |
| 82 bool update_wallpaper) override; | 79 bool update_wallpaper) override; |
| 83 void UpdateWallpaper(bool clear_cache) override; | 80 void UpdateWallpaper(bool clear_cache) override; |
| 84 size_t GetPendingListSizeForTesting() const override; | 81 size_t GetPendingListSizeForTesting() const override; |
| 85 wallpaper::WallpaperFilesId GetFilesId( | 82 wallpaper::WallpaperFilesId GetFilesId( |
| 86 const AccountId& account_id) const override; | 83 const AccountId& account_id) const override; |
| 87 | 84 |
| 88 // ash::mojom::WallpaperManager: | 85 // ash::mojom::WallpaperPicker: |
| 89 void Open() override; | 86 void Open() override; |
| 90 | 87 |
| 91 // content::NotificationObserver: | 88 // content::NotificationObserver: |
| 92 void Observe(int type, | 89 void Observe(int type, |
| 93 const content::NotificationSource& source, | 90 const content::NotificationSource& source, |
| 94 const content::NotificationDetails& details) override; | 91 const content::NotificationDetails& details) override; |
| 95 | 92 |
| 96 // user_manager::UserManager::UserSessionStateObserver: | 93 // user_manager::UserManager::UserSessionStateObserver: |
| 97 void UserChangedChildStatus(user_manager::User* user) override; | 94 void UserChangedChildStatus(user_manager::User* user) override; |
| 98 | 95 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 const base::FilePath& path, | 153 const base::FilePath& path, |
| 157 const wallpaper::WallpaperLayout layout, | 154 const wallpaper::WallpaperLayout layout, |
| 158 wallpaper::MovableOnDestroyCallbackHolder on_finish, | 155 wallpaper::MovableOnDestroyCallbackHolder on_finish, |
| 159 std::unique_ptr<user_manager::UserImage>* result_out) override; | 156 std::unique_ptr<user_manager::UserImage>* result_out) override; |
| 160 void SetDefaultWallpaperPath( | 157 void SetDefaultWallpaperPath( |
| 161 const base::FilePath& customized_default_wallpaper_file_small, | 158 const base::FilePath& customized_default_wallpaper_file_small, |
| 162 std::unique_ptr<gfx::ImageSkia> small_wallpaper_image, | 159 std::unique_ptr<gfx::ImageSkia> small_wallpaper_image, |
| 163 const base::FilePath& customized_default_wallpaper_file_large, | 160 const base::FilePath& customized_default_wallpaper_file_large, |
| 164 std::unique_ptr<gfx::ImageSkia> large_wallpaper_image) override; | 161 std::unique_ptr<gfx::ImageSkia> large_wallpaper_image) override; |
| 165 | 162 |
| 166 mojo::BindingSet<ash::mojom::WallpaperManager> bindings_; | 163 mojo::Binding<ash::mojom::WallpaperPicker> binding_; |
| 167 | 164 |
| 168 std::unique_ptr<CrosSettings::ObserverSubscription> | 165 std::unique_ptr<CrosSettings::ObserverSubscription> |
| 169 show_user_name_on_signin_subscription_; | 166 show_user_name_on_signin_subscription_; |
| 170 | 167 |
| 171 // Pointer to last inactive (waiting) entry of 'loading_' list. | 168 // Pointer to last inactive (waiting) entry of 'loading_' list. |
| 172 // NULL when there is no inactive request. | 169 // NULL when there is no inactive request. |
| 173 PendingWallpaper* pending_inactive_; | 170 PendingWallpaper* pending_inactive_; |
| 174 | 171 |
| 175 // Owns PendingWallpaper. | 172 // Owns PendingWallpaper. |
| 176 // PendingWallpaper deletes itself from here on load complete. | 173 // PendingWallpaper deletes itself from here on load complete. |
| 177 // All pending will be finally deleted on destroy. | 174 // All pending will be finally deleted on destroy. |
| 178 typedef std::vector<scoped_refptr<PendingWallpaper>> PendingList; | 175 typedef std::vector<scoped_refptr<PendingWallpaper>> PendingList; |
| 179 PendingList loading_; | 176 PendingList loading_; |
| 180 | 177 |
| 181 content::NotificationRegistrar registrar_; | 178 content::NotificationRegistrar registrar_; |
| 182 | 179 |
| 183 base::WeakPtrFactory<WallpaperManager> weak_factory_; | 180 base::WeakPtrFactory<WallpaperManager> weak_factory_; |
| 184 | 181 |
| 185 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); | 182 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); |
| 186 }; | 183 }; |
| 187 | 184 |
| 188 } // namespace chromeos | 185 } // namespace chromeos |
| 189 | 186 |
| 190 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ | 187 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ |
| OLD | NEW |