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

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

Issue 2931063004: Extract colors from wallpaper and dynamically update login screen overlay (Closed)
Patch Set: Will clean up this CL when crbug.com/733709 is fixed Created 3 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
« 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 <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 "base/scoped_observer.h" 16 #include "base/scoped_observer.h"
17 #include "chrome/browser/chromeos/customization/customization_wallpaper_download er.h" 17 #include "chrome/browser/chromeos/customization/customization_wallpaper_download er.h"
18 #include "chrome/browser/chromeos/settings/cros_settings.h" 18 #include "chrome/browser/chromeos/settings/cros_settings.h"
19 #include "components/user_manager/user.h" 19 #include "components/user_manager/user.h"
20 #include "components/user_manager/user_image/user_image.h" 20 #include "components/user_manager/user_image/user_image.h"
21 #include "components/user_manager/user_manager.h" 21 #include "components/user_manager/user_manager.h"
22 #include "components/wallpaper/wallpaper_color_calculator.h"
23 #include "components/wallpaper/wallpaper_color_calculator_observer.h"
22 #include "components/wallpaper/wallpaper_layout.h" 24 #include "components/wallpaper/wallpaper_layout.h"
23 #include "components/wallpaper/wallpaper_manager_base.h" 25 #include "components/wallpaper/wallpaper_manager_base.h"
24 #include "content/public/browser/notification_observer.h" 26 #include "content/public/browser/notification_observer.h"
25 #include "content/public/browser/notification_registrar.h" 27 #include "content/public/browser/notification_registrar.h"
26 #include "mojo/public/cpp/bindings/binding.h" 28 #include "mojo/public/cpp/bindings/binding.h"
27 #include "ui/aura/window_observer.h" 29 #include "ui/aura/window_observer.h"
28 #include "ui/gfx/image/image_skia.h" 30 #include "ui/gfx/image/image_skia.h"
29 #include "ui/wm/public/activation_change_observer.h" 31 #include "ui/wm/public/activation_change_observer.h"
30 #include "ui/wm/public/activation_client.h" 32 #include "ui/wm/public/activation_client.h"
31 33
32 namespace chromeos { 34 namespace chromeos {
33 35
34 class WallpaperManager 36 class WallpaperManager
35 : public wallpaper::WallpaperManagerBase, 37 : public wallpaper::WallpaperManagerBase,
36 public ash::mojom::WallpaperPicker, 38 public ash::mojom::WallpaperPicker,
37 public content::NotificationObserver, 39 public content::NotificationObserver,
38 public user_manager::UserManager::UserSessionStateObserver, 40 public user_manager::UserManager::UserSessionStateObserver,
39 public wm::ActivationChangeObserver, 41 public wm::ActivationChangeObserver,
40 public aura::WindowObserver { 42 public aura::WindowObserver,
43 public wallpaper::WallpaperColorCalculatorObserver {
41 public: 44 public:
42 class PendingWallpaper; 45 class PendingWallpaper;
43 46
44 ~WallpaperManager() override; 47 ~WallpaperManager() override;
45 48
46 // Creates an instance of Wallpaper Manager. If there is no instance, create 49 // Expects there is no instance of WallpaperManager and create one.
47 // one. Otherwise, returns the existing instance.
48 static void Initialize(); 50 static void Initialize();
49 51
50 // Gets pointer to singleton WallpaperManager instance. 52 // Gets pointer to singleton WallpaperManager instance.
51 static WallpaperManager* Get(); 53 static WallpaperManager* Get();
52 54
53 // Deletes the existing instance of WallpaperManager. Allows the 55 // Deletes the existing instance of WallpaperManager. Allows the
54 // WallpaperManager to remove any observers it has registered. 56 // WallpaperManager to remove any observers it has registered.
55 static void Shutdown(); 57 static void Shutdown();
56 58
59 // Checks whether the instance exists. In general, please refrain from using
60 // this function. Use Get() directly when needing to access the singleton.
61 // TODO(crbug.com/733709): Remove this function when color calculation for
62 // login screen is moved elsewhere.
63 static bool HasInstance();
64
57 // Returns if the image is in the pending list. |image_id| can be obtained 65 // Returns if the image is in the pending list. |image_id| can be obtained
58 // from gfx::ImageSkia by using WallpaperResizer::GetImageId(). 66 // from gfx::ImageSkia by using WallpaperResizer::GetImageId().
59 bool IsPendingWallpaper(uint32_t image_id); 67 bool IsPendingWallpaper(uint32_t image_id);
60 68
69 // Calculates a prominent color based on the wallpaper image and notifies
70 // |observers_| of the value. An existing calculation in progress (if any)
71 // will be destroyed first.
72 void CalculateProminentColor(const gfx::ImageSkia& image);
73
74 base::Optional<SkColor> prominent_color() const { return prominent_color_; }
75
61 // wallpaper::WallpaperManagerBase: 76 // wallpaper::WallpaperManagerBase:
62 WallpaperResolution GetAppropriateResolution() override; 77 WallpaperResolution GetAppropriateResolution() override;
63 void AddObservers() override; 78 void AddObservers() override;
64 void EnsureLoggedInUserWallpaperLoaded() override; 79 void EnsureLoggedInUserWallpaperLoaded() override;
65 void InitializeWallpaper() override; 80 void InitializeWallpaper() override;
66 void RemoveUserWallpaperInfo(const AccountId& account_id) override; 81 void RemoveUserWallpaperInfo(const AccountId& account_id) override;
67 void OnPolicyFetched(const std::string& policy, 82 void OnPolicyFetched(const std::string& policy,
68 const AccountId& account_id, 83 const AccountId& account_id,
69 std::unique_ptr<std::string> data) override; 84 std::unique_ptr<std::string> data) override;
70 void SetCustomWallpaper(const AccountId& account_id, 85 void SetCustomWallpaper(const AccountId& account_id,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 void UserChangedChildStatus(user_manager::User* user) override; 121 void UserChangedChildStatus(user_manager::User* user) override;
107 122
108 // wm::ActivationChangeObserver: 123 // wm::ActivationChangeObserver:
109 void OnWindowActivated(ActivationReason reason, 124 void OnWindowActivated(ActivationReason reason,
110 aura::Window* gained_active, 125 aura::Window* gained_active,
111 aura::Window* lost_active) override; 126 aura::Window* lost_active) override;
112 127
113 // aura::WindowObserver: 128 // aura::WindowObserver:
114 void OnWindowDestroying(aura::Window* window) override; 129 void OnWindowDestroying(aura::Window* window) override;
115 130
131 // wallpaper::WallpaperColorCalculatorObserver:
132 void OnColorCalculationComplete() override;
133
116 private: 134 private:
117 friend class TestApi; 135 friend class TestApi;
118 friend class WallpaperManagerBrowserTest; 136 friend class WallpaperManagerBrowserTest;
119 friend class WallpaperManagerBrowserTestDefaultWallpaper; 137 friend class WallpaperManagerBrowserTestDefaultWallpaper;
120 friend class WallpaperManagerPolicyTest; 138 friend class WallpaperManagerPolicyTest;
121 139
122 WallpaperManager(); 140 WallpaperManager();
123 141
124 // Returns modifiable PendingWallpaper. 142 // Returns modifiable PendingWallpaper.
125 // Returns pending_inactive_ or creates new PendingWallpaper if necessary. 143 // Returns pending_inactive_ or creates new PendingWallpaper if necessary.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // All pending will be finally deleted on destroy. 249 // All pending will be finally deleted on destroy.
232 typedef std::vector<scoped_refptr<PendingWallpaper>> PendingList; 250 typedef std::vector<scoped_refptr<PendingWallpaper>> PendingList;
233 PendingList loading_; 251 PendingList loading_;
234 252
235 content::NotificationRegistrar registrar_; 253 content::NotificationRegistrar registrar_;
236 254
237 ScopedObserver<wm::ActivationClient, wm::ActivationChangeObserver> 255 ScopedObserver<wm::ActivationClient, wm::ActivationChangeObserver>
238 activation_client_observer_; 256 activation_client_observer_;
239 ScopedObserver<aura::Window, aura::WindowObserver> window_observer_; 257 ScopedObserver<aura::Window, aura::WindowObserver> window_observer_;
240 258
259 // The prominent color extracted from the current wallpaper. It doesn't have
260 // value if color extraction fails.
261 base::Optional<SkColor> prominent_color_;
262
263 // TODO(crbug.com/733709): Remove color calculation here when the old signin
264 // screen implementation is deprecated.
265 std::unique_ptr<wallpaper::WallpaperColorCalculator> color_calculator_;
266
241 base::WeakPtrFactory<WallpaperManager> weak_factory_; 267 base::WeakPtrFactory<WallpaperManager> weak_factory_;
242 268
243 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); 269 DISALLOW_COPY_AND_ASSIGN(WallpaperManager);
244 }; 270 };
245 271
246 } // namespace chromeos 272 } // namespace chromeos
247 273
248 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ 274 #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