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

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: Add image-loading class to small pods container 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
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 "ash/shelf/shelf_constants.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/ref_counted_memory.h" 15 #include "base/memory/ref_counted_memory.h"
15 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
16 #include "base/scoped_observer.h" 17 #include "base/scoped_observer.h"
17 #include "chrome/browser/chromeos/customization/customization_wallpaper_download er.h" 18 #include "chrome/browser/chromeos/customization/customization_wallpaper_download er.h"
18 #include "chrome/browser/chromeos/settings/cros_settings.h" 19 #include "chrome/browser/chromeos/settings/cros_settings.h"
19 #include "components/user_manager/user.h" 20 #include "components/user_manager/user.h"
20 #include "components/user_manager/user_image/user_image.h" 21 #include "components/user_manager/user_image/user_image.h"
21 #include "components/user_manager/user_manager.h" 22 #include "components/user_manager/user_manager.h"
23 #include "components/wallpaper/wallpaper_color_calculator.h"
24 #include "components/wallpaper/wallpaper_color_calculator_observer.h"
22 #include "components/wallpaper/wallpaper_layout.h" 25 #include "components/wallpaper/wallpaper_layout.h"
23 #include "components/wallpaper/wallpaper_manager_base.h" 26 #include "components/wallpaper/wallpaper_manager_base.h"
24 #include "content/public/browser/notification_observer.h" 27 #include "content/public/browser/notification_observer.h"
25 #include "content/public/browser/notification_registrar.h" 28 #include "content/public/browser/notification_registrar.h"
26 #include "mojo/public/cpp/bindings/binding.h" 29 #include "mojo/public/cpp/bindings/binding.h"
27 #include "ui/aura/window_observer.h" 30 #include "ui/aura/window_observer.h"
31 #include "ui/gfx/color_utils.h"
28 #include "ui/gfx/image/image_skia.h" 32 #include "ui/gfx/image/image_skia.h"
29 #include "ui/wm/public/activation_change_observer.h" 33 #include "ui/wm/public/activation_change_observer.h"
30 #include "ui/wm/public/activation_client.h" 34 #include "ui/wm/public/activation_client.h"
31 35
32 namespace chromeos { 36 namespace chromeos {
33 37
34 class WallpaperManager 38 class WallpaperManager
35 : public wallpaper::WallpaperManagerBase, 39 : public wallpaper::WallpaperManagerBase,
36 public ash::mojom::WallpaperPicker, 40 public ash::mojom::WallpaperPicker,
37 public content::NotificationObserver, 41 public content::NotificationObserver,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 void UserChangedChildStatus(user_manager::User* user) override; 110 void UserChangedChildStatus(user_manager::User* user) override;
107 111
108 // wm::ActivationChangeObserver: 112 // wm::ActivationChangeObserver:
109 void OnWindowActivated(ActivationReason reason, 113 void OnWindowActivated(ActivationReason reason,
110 aura::Window* gained_active, 114 aura::Window* gained_active,
111 aura::Window* lost_active) override; 115 aura::Window* lost_active) override;
112 116
113 // aura::WindowObserver: 117 // aura::WindowObserver:
114 void OnWindowDestroying(aura::Window* window) override; 118 void OnWindowDestroying(aura::Window* window) override;
115 119
120 // Setting a non-NULL observer indicates that color calculation is needed
jdufault 2017/06/10 03:05:59 nit: non-null
Wenzhao (Colin) Zang 2017/06/12 21:10:58 Done.
121 // when a wallpaper is set.
jdufault 2017/06/10 03:05:59 Generally, try to avoid encoding state information
Wenzhao (Colin) Zang 2017/06/12 21:10:58 Done.
122 void SetLoginOverlayCalculatorObserver(
jdufault 2017/06/10 03:05:59 These functions should go above the overrides (ove
jdufault 2017/06/10 03:05:59 This should follow the standard AddObserver/Remove
Wenzhao (Colin) Zang 2017/06/12 21:10:58 Done.
Wenzhao (Colin) Zang 2017/06/12 21:10:58 Done.
123 wallpaper::WallpaperColorCalculatorObserver*);
jdufault 2017/06/10 03:05:59 Set a variable name here.
Wenzhao (Colin) Zang 2017/06/12 21:10:58 Done.
124
125 // Must be called after color calculation succeeds. Get the actual colors
126 // which will be used in login screen based on the prominent color.
127 void getLoginOverlayColors(std::string* dm_color,
jdufault 2017/06/10 03:05:59 nit: Out parameters should have out_ prefix.
jdufault 2017/06/10 03:05:59 nit: get -> Get
Wenzhao (Colin) Zang 2017/06/12 21:10:57 Done.
Wenzhao (Colin) Zang 2017/06/12 21:10:57 Done.
128 std::string* scroll_color,
129 std::string* background_color);
130
116 private: 131 private:
117 friend class TestApi; 132 friend class TestApi;
118 friend class WallpaperManagerBrowserTest; 133 friend class WallpaperManagerBrowserTest;
119 friend class WallpaperManagerBrowserTestDefaultWallpaper; 134 friend class WallpaperManagerBrowserTestDefaultWallpaper;
120 friend class WallpaperManagerPolicyTest; 135 friend class WallpaperManagerPolicyTest;
121 136
122 WallpaperManager(); 137 WallpaperManager();
123 138
124 // Returns modifiable PendingWallpaper. 139 // Returns modifiable PendingWallpaper.
125 // Returns pending_inactive_ or creates new PendingWallpaper if necessary. 140 // Returns pending_inactive_ or creates new PendingWallpaper if necessary.
(...skipping 26 matching lines...) Expand all
152 // device wallpaper policy setting. 167 // device wallpaper policy setting.
153 void OnCheckDeviceWallpaperMatchHash(const AccountId& account_id, 168 void OnCheckDeviceWallpaperMatchHash(const AccountId& account_id,
154 const std::string& url, 169 const std::string& url,
155 const std::string& hash, 170 const std::string& hash,
156 bool match); 171 bool match);
157 // This is called when the device wallpaper is decoded successfully. 172 // This is called when the device wallpaper is decoded successfully.
158 void OnDeviceWallpaperDecoded( 173 void OnDeviceWallpaperDecoded(
159 const AccountId& account_id, 174 const AccountId& account_id,
160 std::unique_ptr<user_manager::UserImage> user_image); 175 std::unique_ptr<user_manager::UserImage> user_image);
161 176
177 // If the calculator observer is not NULL, calculate a prominent color based
jdufault 2017/06/10 03:05:59 nit: NULL -> null
Wenzhao (Colin) Zang 2017/06/12 21:10:58 Done.
178 // on the wallpaper image. An existing calculation in progress (if any) will
179 // be destroyed first.
180 void CalculateProminentColor(const gfx::ImageSkia& image);
181
162 // wallpaper::WallpaperManagerBase: 182 // wallpaper::WallpaperManagerBase:
163 void InitializeRegisteredDeviceWallpaper() override; 183 void InitializeRegisteredDeviceWallpaper() override;
164 bool GetUserWallpaperInfo(const AccountId& account_id, 184 bool GetUserWallpaperInfo(const AccountId& account_id,
165 wallpaper::WallpaperInfo* info) const override; 185 wallpaper::WallpaperInfo* info) const override;
166 // Returns true if the device wallpaper should be set for the account. 186 // Returns true if the device wallpaper should be set for the account.
167 bool ShouldSetDeviceWallpaper(const AccountId& account_id, 187 bool ShouldSetDeviceWallpaper(const AccountId& account_id,
168 std::string* url, 188 std::string* url,
169 std::string* hash) override; 189 std::string* hash) override;
170 base::FilePath GetDeviceWallpaperDir() override; 190 base::FilePath GetDeviceWallpaperDir() override;
171 base::FilePath GetDeviceWallpaperFilePath() override; 191 base::FilePath GetDeviceWallpaperFilePath() override;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 PendingList loading_; 253 PendingList loading_;
234 254
235 content::NotificationRegistrar registrar_; 255 content::NotificationRegistrar registrar_;
236 256
237 ScopedObserver<wm::ActivationClient, wm::ActivationChangeObserver> 257 ScopedObserver<wm::ActivationClient, wm::ActivationChangeObserver>
238 activation_client_observer_; 258 activation_client_observer_;
239 ScopedObserver<aura::Window, aura::WindowObserver> window_observer_; 259 ScopedObserver<aura::Window, aura::WindowObserver> window_observer_;
240 260
241 base::WeakPtrFactory<WallpaperManager> weak_factory_; 261 base::WeakPtrFactory<WallpaperManager> weak_factory_;
242 262
263 std::unique_ptr<wallpaper::WallpaperColorCalculator> color_calculator_;
264
265 wallpaper::WallpaperColorCalculatorObserver*
266 login_overlay_calculator_observer_;
267
243 DISALLOW_COPY_AND_ASSIGN(WallpaperManager); 268 DISALLOW_COPY_AND_ASSIGN(WallpaperManager);
244 }; 269 };
245 270
246 } // namespace chromeos 271 } // namespace chromeos
247 272
248 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_ 273 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_WALLPAPER_WALLPAPER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698