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

Side by Side Diff: ash/wallpaper/wallpaper_controller.h

Issue 2832053003: cros: WallpaperController reparent based on session state (Closed)
Patch Set: rebase Created 3 years, 8 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 | ash/wallpaper/wallpaper_controller.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 (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"
16 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
17 #include "base/observer_list.h" 16 #include "base/observer_list.h"
18 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
19 #include "components/wallpaper/wallpaper_color_calculator_observer.h" 18 #include "components/wallpaper/wallpaper_color_calculator_observer.h"
20 #include "components/wallpaper/wallpaper_layout.h" 19 #include "components/wallpaper/wallpaper_layout.h"
21 #include "components/wallpaper/wallpaper_resizer_observer.h" 20 #include "components/wallpaper/wallpaper_resizer_observer.h"
22 #include "mojo/public/cpp/bindings/binding_set.h" 21 #include "mojo/public/cpp/bindings/binding_set.h"
23 #include "ui/gfx/color_analysis.h" 22 #include "ui/gfx/color_analysis.h"
24 #include "ui/gfx/image/image_skia.h" 23 #include "ui/gfx/image/image_skia.h"
25 24
26 namespace base { 25 namespace base {
27 class TaskRunner; 26 class TaskRunner;
28 } 27 }
29 28
30 namespace wallpaper { 29 namespace wallpaper {
31 class WallpaperColorCalculator; 30 class WallpaperColorCalculator;
32 class WallpaperResizer; 31 class WallpaperResizer;
33 } 32 }
34 33
35 namespace ash { 34 namespace ash {
36 35
37 class WallpaperControllerObserver; 36 class WallpaperControllerObserver;
38 37
39 // Controls the desktop background wallpaper. 38 // Controls the desktop background wallpaper:
39 // - Sets a wallpaper image and layout;
40 // - Handles display change (add/remove display, configuration change etc);
41 // - Calculates prominent color for shelf;
42 // - 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 // state is ACTIVE;
40 class ASH_EXPORT WallpaperController 45 class ASH_EXPORT WallpaperController
41 : public NON_EXPORTED_BASE(mojom::WallpaperController), 46 : public NON_EXPORTED_BASE(mojom::WallpaperController),
42 public WmDisplayObserver, 47 public WmDisplayObserver,
43 public ShellObserver, 48 public ShellObserver,
44 public wallpaper::WallpaperResizerObserver, 49 public wallpaper::WallpaperResizerObserver,
45 public wallpaper::WallpaperColorCalculatorObserver, 50 public wallpaper::WallpaperColorCalculatorObserver,
46 public SessionObserver { 51 public SessionObserver {
47 public: 52 public:
48 enum WallpaperMode { WALLPAPER_NONE, WALLPAPER_IMAGE }; 53 enum WallpaperMode { WALLPAPER_NONE, WALLPAPER_IMAGE };
49 54
(...skipping 26 matching lines...) Expand all
76 wallpaper::WallpaperLayout layout); 81 wallpaper::WallpaperLayout layout);
77 82
78 // Creates an empty wallpaper. Some tests require a wallpaper widget is ready 83 // Creates an empty wallpaper. Some tests require a wallpaper widget is ready
79 // when running. However, the wallpaper widgets are now created 84 // when running. However, the wallpaper widgets are now created
80 // asynchronously. If loading a real wallpaper, there are cases that these 85 // asynchronously. If loading a real wallpaper, there are cases that these
81 // tests crash because the required widget is not ready. This function 86 // tests crash because the required widget is not ready. This function
82 // synchronously creates an empty widget for those tests to prevent 87 // synchronously creates an empty widget for those tests to prevent
83 // crashes. An example test is SystemGestureEventFilterTest.ThreeFingerSwipe. 88 // crashes. An example test is SystemGestureEventFilterTest.ThreeFingerSwipe.
84 void CreateEmptyWallpaper(); 89 void CreateEmptyWallpaper();
85 90
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: 91 // WmDisplayObserver:
95 void OnDisplayConfigurationChanged() override; 92 void OnDisplayConfigurationChanged() override;
96 93
97 // ShellObserver: 94 // ShellObserver:
98 void OnRootWindowAdded(WmWindow* root_window) override; 95 void OnRootWindowAdded(WmWindow* root_window) override;
99 96
100 // SessionObserver: 97 // SessionObserver:
101 void OnSessionStateChanged(session_manager::SessionState state) override; 98 void OnSessionStateChanged(session_manager::SessionState state) override;
102 99
103 // Returns the maximum size of all displays combined in native 100 // Returns the maximum size of all displays combined in native
(...skipping 21 matching lines...) Expand all
125 void SetWallpaper(const SkBitmap& wallpaper, 122 void SetWallpaper(const SkBitmap& wallpaper,
126 wallpaper::WallpaperLayout layout) override; 123 wallpaper::WallpaperLayout layout) override;
127 124
128 // WallpaperResizerObserver: 125 // WallpaperResizerObserver:
129 void OnWallpaperResized() override; 126 void OnWallpaperResized() override;
130 127
131 // WallpaperColorCalculatorObserver: 128 // WallpaperColorCalculatorObserver:
132 void OnColorCalculationComplete() override; 129 void OnColorCalculationComplete() override;
133 130
134 private: 131 private:
132 FRIEND_TEST_ALL_PREFIXES(WallpaperControllerTest, BasicReparenting);
133 FRIEND_TEST_ALL_PREFIXES(WallpaperControllerTest,
134 WallpaperMovementDuringUnlock);
135 friend class WallpaperControllerTest; 135 friend class WallpaperControllerTest;
136 136
137 // Creates a WallpaperWidgetController for |root_window|. 137 // Creates a WallpaperWidgetController for |root_window|.
138 void InstallDesktopController(WmWindow* root_window); 138 void InstallDesktopController(WmWindow* root_window);
139 139
140 // Creates a WallpaperWidgetController for all root windows. 140 // Creates a WallpaperWidgetController for all root windows.
141 void InstallDesktopControllerForAllWindows(); 141 void InstallDesktopControllerForAllWindows();
142 142
143 // Moves the wallpaper to the specified container across all root windows. 143 // Moves the wallpaper to the specified container across all root windows.
144 // Returns true if a wallpaper moved. 144 // Returns true if a wallpaper moved.
(...skipping 13 matching lines...) Expand all
158 // |observers_| of the value, either synchronously or asynchronously. In some 158 // |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 159 // cases the wallpaper image will not actually be processed (e.g. user isn't
160 // logged in, feature isn't enabled). 160 // logged in, feature isn't enabled).
161 // If an existing calculation is in progress it is destroyed. 161 // If an existing calculation is in progress it is destroyed.
162 void CalculateWallpaperColors(); 162 void CalculateWallpaperColors();
163 163
164 // Returns false when the color extraction algorithm shouldn't be run based on 164 // Returns false when the color extraction algorithm shouldn't be run based on
165 // system state (e.g. wallpaper image, SessionState, etc.). 165 // system state (e.g. wallpaper image, SessionState, etc.).
166 bool ShouldCalculateColors() const; 166 bool ShouldCalculateColors() const;
167 167
168 // Move all wallpaper widgets to the locked container.
169 // Returns true if the wallpaper moved.
170 bool MoveToLockedContainer();
171
172 // Move all wallpaper widgets to unlocked container.
173 // Returns true if the wallpaper moved.
174 bool MoveToUnlockedContainer();
175
168 bool locked_; 176 bool locked_;
169 177
170 WallpaperMode wallpaper_mode_; 178 WallpaperMode wallpaper_mode_;
171 179
172 // Wallpaper picker interface in chrome browser, used to open the picker. 180 // Wallpaper picker interface in chrome browser, used to open the picker.
173 mojom::WallpaperPickerPtr wallpaper_picker_; 181 mojom::WallpaperPickerPtr wallpaper_picker_;
174 182
175 // Bindings for the WallpaperController interface. 183 // Bindings for the WallpaperController interface.
176 mojo::BindingSet<mojom::WallpaperController> bindings_; 184 mojo::BindingSet<mojom::WallpaperController> bindings_;
177 185
(...skipping 17 matching lines...) Expand all
195 scoped_refptr<base::TaskRunner> task_runner_; 203 scoped_refptr<base::TaskRunner> task_runner_;
196 204
197 ScopedSessionObserver scoped_session_observer_; 205 ScopedSessionObserver scoped_session_observer_;
198 206
199 DISALLOW_COPY_AND_ASSIGN(WallpaperController); 207 DISALLOW_COPY_AND_ASSIGN(WallpaperController);
200 }; 208 };
201 209
202 } // namespace ash 210 } // namespace ash
203 211
204 #endif // ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_ 212 #endif // ASH_WALLPAPER_WALLPAPER_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | ash/wallpaper/wallpaper_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698