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

Side by Side Diff: ash/wm/aura/wm_globals_aura.cc

Issue 2035543004: Shuffles and renames ash/common/wm classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: random changes for chrome tests Created 4 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/wm/aura/wm_globals_aura.h"
6
7 #include "ash/common/wm/wm_activation_observer.h"
8 #include "ash/common/wm/wm_display_observer.h"
9 #include "ash/common/wm/wm_overview_mode_observer.h"
10 #include "ash/display/window_tree_host_manager.h"
11 #include "ash/session/session_state_delegate.h"
12 #include "ash/shell.h"
13 #include "ash/shell_delegate.h"
14 #include "ash/wm/aura/wm_window_aura.h"
15 #include "ash/wm/drag_window_resizer.h"
16 #include "ash/wm/mru_window_tracker.h"
17 #include "ash/wm/overview/window_selector_controller.h"
18 #include "ash/wm/window_util.h"
19 #include "base/memory/ptr_util.h"
20 #include "ui/aura/client/focus_client.h"
21 #include "ui/wm/public/activation_client.h"
22
23 namespace ash {
24 namespace wm {
25
26 WmGlobalsAura::WmGlobalsAura() {
27 WmGlobals::Set(this);
28 Shell::GetInstance()->AddShellObserver(this);
29 }
30
31 WmGlobalsAura::~WmGlobalsAura() {
32 WmGlobals::Set(nullptr);
33 if (added_activation_observer_) {
34 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())
35 ->RemoveObserver(this);
36 }
37 if (added_display_observer_)
38 Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this);
39
40 Shell::GetInstance()->RemoveShellObserver(this);
41 }
42
43 WmWindow* WmGlobalsAura::NewContainerWindow() {
44 aura::Window* aura_window = new aura::Window(nullptr);
45 aura_window->Init(ui::LAYER_NOT_DRAWN);
46 return WmWindowAura::Get(aura_window);
47 }
48
49 WmWindow* WmGlobalsAura::GetFocusedWindow() {
50 return WmWindowAura::Get(
51 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())
52 ->GetFocusedWindow());
53 }
54
55 WmWindow* WmGlobalsAura::GetActiveWindow() {
56 return WmWindowAura::Get(wm::GetActiveWindow());
57 }
58
59 WmWindow* WmGlobalsAura::GetPrimaryRootWindow() {
60 return WmWindowAura::Get(Shell::GetPrimaryRootWindow());
61 }
62
63 WmWindow* WmGlobalsAura::GetRootWindowForDisplayId(int64_t display_id) {
64 return WmWindowAura::Get(Shell::GetInstance()
65 ->window_tree_host_manager()
66 ->GetRootWindowForDisplayId(display_id));
67 }
68
69 WmWindow* WmGlobalsAura::GetRootWindowForNewWindows() {
70 return WmWindowAura::Get(Shell::GetTargetRootWindow());
71 }
72
73 std::vector<WmWindow*> WmGlobalsAura::GetMruWindowList() {
74 return WmWindowAura::FromAuraWindows(
75 Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList());
76 }
77
78 std::vector<WmWindow*> WmGlobalsAura::GetMruWindowListIgnoreModals() {
79 return WmWindowAura::FromAuraWindows(
80 Shell::GetInstance()->mru_window_tracker()->BuildWindowListIgnoreModal());
81 }
82
83 bool WmGlobalsAura::IsForceMaximizeOnFirstRun() {
84 return Shell::GetInstance()->delegate()->IsForceMaximizeOnFirstRun();
85 }
86
87 bool WmGlobalsAura::IsUserSessionBlocked() {
88 return Shell::GetInstance()->session_state_delegate()->IsUserSessionBlocked();
89 }
90
91 bool WmGlobalsAura::IsScreenLocked() {
92 return Shell::GetInstance()->session_state_delegate()->IsScreenLocked();
93 }
94
95 void WmGlobalsAura::LockCursor() {
96 Shell::GetInstance()->cursor_manager()->LockCursor();
97 }
98
99 void WmGlobalsAura::UnlockCursor() {
100 Shell::GetInstance()->cursor_manager()->UnlockCursor();
101 }
102
103 std::vector<WmWindow*> WmGlobalsAura::GetAllRootWindows() {
104 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
105 std::vector<WmWindow*> wm_windows(root_windows.size());
106 for (size_t i = 0; i < root_windows.size(); ++i)
107 wm_windows[i] = WmWindowAura::Get(root_windows[i]);
108 return wm_windows;
109 }
110
111 void WmGlobalsAura::RecordUserMetricsAction(WmUserMetricsAction action) {
112 return Shell::GetInstance()->metrics()->RecordUserMetricsAction(action);
113 }
114
115 std::unique_ptr<WindowResizer> WmGlobalsAura::CreateDragWindowResizer(
116 std::unique_ptr<WindowResizer> next_window_resizer,
117 wm::WindowState* window_state) {
118 return base::WrapUnique(
119 DragWindowResizer::Create(next_window_resizer.release(), window_state));
120 }
121
122 bool WmGlobalsAura::IsOverviewModeSelecting() {
123 WindowSelectorController* window_selector_controller =
124 Shell::GetInstance()->window_selector_controller();
125 return window_selector_controller &&
126 window_selector_controller->IsSelecting();
127 }
128
129 bool WmGlobalsAura::IsOverviewModeRestoringMinimizedWindows() {
130 WindowSelectorController* window_selector_controller =
131 Shell::GetInstance()->window_selector_controller();
132 return window_selector_controller &&
133 window_selector_controller->IsRestoringMinimizedWindows();
134 }
135
136 void WmGlobalsAura::AddActivationObserver(WmActivationObserver* observer) {
137 if (!added_activation_observer_) {
138 added_activation_observer_ = true;
139 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())
140 ->AddObserver(this);
141 }
142 activation_observers_.AddObserver(observer);
143 }
144
145 void WmGlobalsAura::RemoveActivationObserver(WmActivationObserver* observer) {
146 activation_observers_.RemoveObserver(observer);
147 }
148
149 void WmGlobalsAura::AddDisplayObserver(WmDisplayObserver* observer) {
150 if (!added_display_observer_) {
151 added_display_observer_ = true;
152 Shell::GetInstance()->window_tree_host_manager()->AddObserver(this);
153 }
154 display_observers_.AddObserver(observer);
155 }
156
157 void WmGlobalsAura::RemoveDisplayObserver(WmDisplayObserver* observer) {
158 display_observers_.RemoveObserver(observer);
159 }
160
161 void WmGlobalsAura::AddOverviewModeObserver(WmOverviewModeObserver* observer) {
162 overview_mode_observers_.AddObserver(observer);
163 }
164
165 void WmGlobalsAura::RemoveOverviewModeObserver(
166 WmOverviewModeObserver* observer) {
167 overview_mode_observers_.RemoveObserver(observer);
168 }
169
170 void WmGlobalsAura::OnWindowActivated(
171 aura::client::ActivationChangeObserver::ActivationReason reason,
172 aura::Window* gained_active,
173 aura::Window* lost_active) {
174 FOR_EACH_OBSERVER(WmActivationObserver, activation_observers_,
175 OnWindowActivated(WmWindowAura::Get(gained_active),
176 WmWindowAura::Get(lost_active)));
177 }
178
179 void WmGlobalsAura::OnAttemptToReactivateWindow(aura::Window* request_active,
180 aura::Window* actual_active) {
181 FOR_EACH_OBSERVER(
182 WmActivationObserver, activation_observers_,
183 OnAttemptToReactivateWindow(WmWindowAura::Get(request_active),
184 WmWindowAura::Get(actual_active)));
185 }
186
187 void WmGlobalsAura::OnDisplayConfigurationChanging() {
188 FOR_EACH_OBSERVER(WmDisplayObserver, display_observers_,
189 OnDisplayConfigurationChanging());
190 }
191
192 void WmGlobalsAura::OnDisplayConfigurationChanged() {
193 FOR_EACH_OBSERVER(WmDisplayObserver, display_observers_,
194 OnDisplayConfigurationChanged());
195 }
196
197 void WmGlobalsAura::OnOverviewModeEnded() {
198 FOR_EACH_OBSERVER(WmOverviewModeObserver, overview_mode_observers_,
199 OnOverviewModeEnded());
200 }
201
202 } // namespace wm
203 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698