Chromium Code Reviews| 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/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
|
James Cook
2017/04/21 17:30:55
nit: still needed?
xiyuan
2017/04/21 18:09:35
Done.
| |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
| 19 #include "components/wallpaper/wallpaper_color_calculator_observer.h" | 19 #include "components/wallpaper/wallpaper_color_calculator_observer.h" |
| 20 #include "components/wallpaper/wallpaper_layout.h" | 20 #include "components/wallpaper/wallpaper_layout.h" |
| 21 #include "components/wallpaper/wallpaper_resizer_observer.h" | 21 #include "components/wallpaper/wallpaper_resizer_observer.h" |
| 22 #include "mojo/public/cpp/bindings/binding_set.h" | 22 #include "mojo/public/cpp/bindings/binding_set.h" |
| 23 #include "ui/gfx/color_analysis.h" | 23 #include "ui/gfx/color_analysis.h" |
| 24 #include "ui/gfx/image/image_skia.h" | 24 #include "ui/gfx/image/image_skia.h" |
| 25 | 25 |
| 26 namespace base { | 26 namespace base { |
| 27 class TaskRunner; | 27 class TaskRunner; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace wallpaper { | 30 namespace wallpaper { |
| 31 class WallpaperColorCalculator; | 31 class WallpaperColorCalculator; |
| 32 class WallpaperResizer; | 32 class WallpaperResizer; |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace ash { | 35 namespace ash { |
| 36 | 36 |
| 37 class WallpaperControllerObserver; | 37 class WallpaperControllerObserver; |
| 38 | 38 |
| 39 // Controls the desktop background wallpaper. | 39 // Controls the desktop background wallpaper. |
|
James Cook
2017/04/21 17:30:55
totally optional: Maybe add some docs about how wa
xiyuan
2017/04/21 18:09:35
Done.
| |
| 40 class ASH_EXPORT WallpaperController | 40 class ASH_EXPORT WallpaperController |
| 41 : public NON_EXPORTED_BASE(mojom::WallpaperController), | 41 : public NON_EXPORTED_BASE(mojom::WallpaperController), |
| 42 public WmDisplayObserver, | 42 public WmDisplayObserver, |
| 43 public ShellObserver, | 43 public ShellObserver, |
| 44 public wallpaper::WallpaperResizerObserver, | 44 public wallpaper::WallpaperResizerObserver, |
| 45 public wallpaper::WallpaperColorCalculatorObserver, | 45 public wallpaper::WallpaperColorCalculatorObserver, |
| 46 public SessionObserver { | 46 public SessionObserver { |
| 47 public: | 47 public: |
| 48 enum WallpaperMode { WALLPAPER_NONE, WALLPAPER_IMAGE }; | 48 enum WallpaperMode { WALLPAPER_NONE, WALLPAPER_IMAGE }; |
| 49 | 49 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 76 wallpaper::WallpaperLayout layout); | 76 wallpaper::WallpaperLayout layout); |
| 77 | 77 |
| 78 // Creates an empty wallpaper. Some tests require a wallpaper widget is ready | 78 // Creates an empty wallpaper. Some tests require a wallpaper widget is ready |
| 79 // when running. However, the wallpaper widgets are now created | 79 // when running. However, the wallpaper widgets are now created |
| 80 // asynchronously. If loading a real wallpaper, there are cases that these | 80 // asynchronously. If loading a real wallpaper, there are cases that these |
| 81 // tests crash because the required widget is not ready. This function | 81 // tests crash because the required widget is not ready. This function |
| 82 // synchronously creates an empty widget for those tests to prevent | 82 // synchronously creates an empty widget for those tests to prevent |
| 83 // crashes. An example test is SystemGestureEventFilterTest.ThreeFingerSwipe. | 83 // crashes. An example test is SystemGestureEventFilterTest.ThreeFingerSwipe. |
| 84 void CreateEmptyWallpaper(); | 84 void CreateEmptyWallpaper(); |
| 85 | 85 |
| 86 // Move all wallpaper widgets to the locked container. | |
| 87 // Returns true if the wallpaper moved. | |
| 88 bool MoveToLockedContainer(); | |
| 89 | |
| 90 // Move all wallpaper widgets to unlocked container. | |
| 91 // Returns true if the wallpaper moved. | |
| 92 bool MoveToUnlockedContainer(); | |
| 93 | |
| 94 // WmDisplayObserver: | 86 // WmDisplayObserver: |
| 95 void OnDisplayConfigurationChanged() override; | 87 void OnDisplayConfigurationChanged() override; |
| 96 | 88 |
| 97 // ShellObserver: | 89 // ShellObserver: |
| 98 void OnRootWindowAdded(WmWindow* root_window) override; | 90 void OnRootWindowAdded(WmWindow* root_window) override; |
| 99 | 91 |
| 100 // SessionObserver: | 92 // SessionObserver: |
| 101 void OnSessionStateChanged(session_manager::SessionState state) override; | 93 void OnSessionStateChanged(session_manager::SessionState state) override; |
| 102 | 94 |
| 103 // Returns the maximum size of all displays combined in native | 95 // Returns the maximum size of all displays combined in native |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 125 void SetWallpaper(const SkBitmap& wallpaper, | 117 void SetWallpaper(const SkBitmap& wallpaper, |
| 126 wallpaper::WallpaperLayout layout) override; | 118 wallpaper::WallpaperLayout layout) override; |
| 127 | 119 |
| 128 // WallpaperResizerObserver: | 120 // WallpaperResizerObserver: |
| 129 void OnWallpaperResized() override; | 121 void OnWallpaperResized() override; |
| 130 | 122 |
| 131 // WallpaperColorCalculatorObserver: | 123 // WallpaperColorCalculatorObserver: |
| 132 void OnColorCalculationComplete() override; | 124 void OnColorCalculationComplete() override; |
| 133 | 125 |
| 134 private: | 126 private: |
| 127 FRIEND_TEST_ALL_PREFIXES(WallpaperControllerTest, BasicReparenting); | |
| 128 FRIEND_TEST_ALL_PREFIXES(WallpaperControllerTest, | |
| 129 WallpaperMovementDuringUnlock); | |
| 135 friend class WallpaperControllerTest; | 130 friend class WallpaperControllerTest; |
| 136 | 131 |
| 137 // Creates a WallpaperWidgetController for |root_window|. | 132 // Creates a WallpaperWidgetController for |root_window|. |
| 138 void InstallDesktopController(WmWindow* root_window); | 133 void InstallDesktopController(WmWindow* root_window); |
| 139 | 134 |
| 140 // Creates a WallpaperWidgetController for all root windows. | 135 // Creates a WallpaperWidgetController for all root windows. |
| 141 void InstallDesktopControllerForAllWindows(); | 136 void InstallDesktopControllerForAllWindows(); |
| 142 | 137 |
| 143 // Moves the wallpaper to the specified container across all root windows. | 138 // Moves the wallpaper to the specified container across all root windows. |
| 144 // Returns true if a wallpaper moved. | 139 // Returns true if a wallpaper moved. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 158 // |observers_| of the value, either synchronously or asynchronously. In some | 153 // |observers_| of the value, either synchronously or asynchronously. In some |
| 159 // cases the wallpaper image will not actually be processed (e.g. user isn't | 154 // cases the wallpaper image will not actually be processed (e.g. user isn't |
| 160 // logged in, feature isn't enabled). | 155 // logged in, feature isn't enabled). |
| 161 // If an existing calculation is in progress it is destroyed. | 156 // If an existing calculation is in progress it is destroyed. |
| 162 void CalculateWallpaperColors(); | 157 void CalculateWallpaperColors(); |
| 163 | 158 |
| 164 // Returns false when the color extraction algorithm shouldn't be run based on | 159 // Returns false when the color extraction algorithm shouldn't be run based on |
| 165 // system state (e.g. wallpaper image, SessionState, etc.). | 160 // system state (e.g. wallpaper image, SessionState, etc.). |
| 166 bool ShouldCalculateColors() const; | 161 bool ShouldCalculateColors() const; |
| 167 | 162 |
| 163 // Move all wallpaper widgets to the locked container. | |
| 164 // Returns true if the wallpaper moved. | |
| 165 bool MoveToLockedContainer(); | |
| 166 | |
| 167 // Move all wallpaper widgets to unlocked container. | |
| 168 // Returns true if the wallpaper moved. | |
| 169 bool MoveToUnlockedContainer(); | |
| 170 | |
| 168 bool locked_; | 171 bool locked_; |
| 169 | 172 |
| 170 WallpaperMode wallpaper_mode_; | 173 WallpaperMode wallpaper_mode_; |
| 171 | 174 |
| 172 // Wallpaper picker interface in chrome browser, used to open the picker. | 175 // Wallpaper picker interface in chrome browser, used to open the picker. |
| 173 mojom::WallpaperPickerPtr wallpaper_picker_; | 176 mojom::WallpaperPickerPtr wallpaper_picker_; |
| 174 | 177 |
| 175 // Bindings for the WallpaperController interface. | 178 // Bindings for the WallpaperController interface. |
| 176 mojo::BindingSet<mojom::WallpaperController> bindings_; | 179 mojo::BindingSet<mojom::WallpaperController> bindings_; |
| 177 | 180 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 195 scoped_refptr<base::TaskRunner> task_runner_; | 198 scoped_refptr<base::TaskRunner> task_runner_; |
| 196 | 199 |
| 197 ScopedSessionObserver scoped_session_observer_; | 200 ScopedSessionObserver scoped_session_observer_; |
| 198 | 201 |
| 199 DISALLOW_COPY_AND_ASSIGN(WallpaperController); | 202 DISALLOW_COPY_AND_ASSIGN(WallpaperController); |
| 200 }; | 203 }; |
| 201 | 204 |
| 202 } // namespace ash | 205 } // namespace ash |
| 203 | 206 |
| 204 #endif // ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_ | 207 #endif // ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_ |
| OLD | NEW |