| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_ | 5 #ifndef ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_ |
| 6 #define ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_ | 6 #define ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "ash/public/interfaces/wallpaper.mojom.h" | 11 #include "ash/public/interfaces/wallpaper.mojom.h" |
| 12 #include "ash/session/session_observer.h" | 12 #include "ash/session/session_observer.h" |
| 13 #include "ash/shell_observer.h" | 13 #include "ash/shell_observer.h" |
| 14 #include "ash/wm_display_observer.h" | 14 #include "ash/wm_display_observer.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
| 18 #include "components/wallpaper/wallpaper_color_calculator_observer.h" | 18 #include "components/wallpaper/wallpaper_color_calculator_observer.h" |
| 19 #include "components/wallpaper/wallpaper_layout.h" | 19 #include "components/wallpaper/wallpaper_layout.h" |
| 20 #include "components/wallpaper/wallpaper_resizer_observer.h" | 20 #include "components/wallpaper/wallpaper_resizer_observer.h" |
| 21 #include "mojo/public/cpp/bindings/binding_set.h" | 21 #include "mojo/public/cpp/bindings/binding_set.h" |
| 22 #include "ui/compositor/compositor_lock.h" |
| 22 #include "ui/gfx/color_analysis.h" | 23 #include "ui/gfx/color_analysis.h" |
| 23 #include "ui/gfx/image/image_skia.h" | 24 #include "ui/gfx/image/image_skia.h" |
| 24 | 25 |
| 25 namespace base { | 26 namespace base { |
| 26 class TaskRunner; | 27 class TaskRunner; |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace wallpaper { | 30 namespace wallpaper { |
| 30 class WallpaperColorCalculator; | 31 class WallpaperColorCalculator; |
| 31 class WallpaperResizer; | 32 class WallpaperResizer; |
| 32 } | 33 } |
| 33 | 34 |
| 34 namespace ash { | 35 namespace ash { |
| 35 | 36 |
| 36 class WallpaperControllerObserver; | 37 class WallpaperControllerObserver; |
| 37 | 38 |
| 38 // Controls the desktop background wallpaper: | 39 // Controls the desktop background wallpaper: |
| 39 // - Sets a wallpaper image and layout; | 40 // - Sets a wallpaper image and layout; |
| 40 // - Handles display change (add/remove display, configuration change etc); | 41 // - Handles display change (add/remove display, configuration change etc); |
| 41 // - Calculates prominent color for shelf; | 42 // - Calculates prominent color for shelf; |
| 42 // - Move wallpaper to locked container(s) when session state is not ACTIVE to | 43 // - Move wallpaper to locked container(s) when session state is not ACTIVE to |
| 43 // hide the user desktop and move it to unlocked container when session | 44 // hide the user desktop and move it to unlocked container when session |
| 44 // state is ACTIVE; | 45 // state is ACTIVE; |
| 45 class ASH_EXPORT WallpaperController | 46 class ASH_EXPORT WallpaperController |
| 46 : public NON_EXPORTED_BASE(mojom::WallpaperController), | 47 : public NON_EXPORTED_BASE(mojom::WallpaperController), |
| 47 public WmDisplayObserver, | 48 public WmDisplayObserver, |
| 48 public ShellObserver, | 49 public ShellObserver, |
| 49 public wallpaper::WallpaperResizerObserver, | 50 public wallpaper::WallpaperResizerObserver, |
| 50 public wallpaper::WallpaperColorCalculatorObserver, | 51 public wallpaper::WallpaperColorCalculatorObserver, |
| 51 public SessionObserver { | 52 public SessionObserver, |
| 53 public NON_EXPORTED_BASE(ui::CompositorLockClient) { |
| 52 public: | 54 public: |
| 53 enum WallpaperMode { WALLPAPER_NONE, WALLPAPER_IMAGE }; | 55 enum WallpaperMode { WALLPAPER_NONE, WALLPAPER_IMAGE }; |
| 54 | 56 |
| 55 // The value assigned to |prominent_color_| if extraction fails or the feature | 57 // The value assigned to |prominent_color_| if extraction fails or the feature |
| 56 // is disabled (e.g. command line, lock/login screens). | 58 // is disabled (e.g. command line, lock/login screens). |
| 57 static constexpr SkColor kInvalidColor = SK_ColorTRANSPARENT; | 59 static constexpr SkColor kInvalidColor = SK_ColorTRANSPARENT; |
| 58 | 60 |
| 59 explicit WallpaperController( | 61 explicit WallpaperController( |
| 60 const scoped_refptr<base::TaskRunner>& task_runner); | 62 const scoped_refptr<base::TaskRunner>& task_runner); |
| 61 ~WallpaperController() override; | 63 ~WallpaperController() override; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 bool ShouldCalculateColors() const; | 168 bool ShouldCalculateColors() const; |
| 167 | 169 |
| 168 // Move all wallpaper widgets to the locked container. | 170 // Move all wallpaper widgets to the locked container. |
| 169 // Returns true if the wallpaper moved. | 171 // Returns true if the wallpaper moved. |
| 170 bool MoveToLockedContainer(); | 172 bool MoveToLockedContainer(); |
| 171 | 173 |
| 172 // Move all wallpaper widgets to unlocked container. | 174 // Move all wallpaper widgets to unlocked container. |
| 173 // Returns true if the wallpaper moved. | 175 // Returns true if the wallpaper moved. |
| 174 bool MoveToUnlockedContainer(); | 176 bool MoveToUnlockedContainer(); |
| 175 | 177 |
| 178 // When wallpaper resizes, we can check which displays will be affected. For |
| 179 // simplicity, we only lock the compositor for the internal display. |
| 180 void GetInternalDisplayCompositorLock(); |
| 181 // CompositorLockClient: |
| 182 void CompositorLockTimedOut() override; |
| 183 |
| 176 bool locked_; | 184 bool locked_; |
| 177 | 185 |
| 178 WallpaperMode wallpaper_mode_; | 186 WallpaperMode wallpaper_mode_; |
| 179 | 187 |
| 180 // Wallpaper picker interface in chrome browser, used to open the picker. | 188 // Wallpaper picker interface in chrome browser, used to open the picker. |
| 181 mojom::WallpaperPickerPtr wallpaper_picker_; | 189 mojom::WallpaperPickerPtr wallpaper_picker_; |
| 182 | 190 |
| 183 // Bindings for the WallpaperController interface. | 191 // Bindings for the WallpaperController interface. |
| 184 mojo::BindingSet<mojom::WallpaperController> bindings_; | 192 mojo::BindingSet<mojom::WallpaperController> bindings_; |
| 185 | 193 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 197 gfx::Size current_max_display_size_; | 205 gfx::Size current_max_display_size_; |
| 198 | 206 |
| 199 base::OneShotTimer timer_; | 207 base::OneShotTimer timer_; |
| 200 | 208 |
| 201 int wallpaper_reload_delay_; | 209 int wallpaper_reload_delay_; |
| 202 | 210 |
| 203 scoped_refptr<base::TaskRunner> task_runner_; | 211 scoped_refptr<base::TaskRunner> task_runner_; |
| 204 | 212 |
| 205 ScopedSessionObserver scoped_session_observer_; | 213 ScopedSessionObserver scoped_session_observer_; |
| 206 | 214 |
| 215 std::unique_ptr<ui::CompositorLock> compositor_lock_; |
| 216 |
| 207 DISALLOW_COPY_AND_ASSIGN(WallpaperController); | 217 DISALLOW_COPY_AND_ASSIGN(WallpaperController); |
| 208 }; | 218 }; |
| 209 | 219 |
| 210 } // namespace ash | 220 } // namespace ash |
| 211 | 221 |
| 212 #endif // ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_ | 222 #endif // ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_ |
| OLD | NEW |