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

Side by Side Diff: ash/common/wm_root_window_controller.cc

Issue 2620913003: Removes WmRootWindowController subclasses (Closed)
Patch Set: spelling Created 3 years, 11 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 | « ash/common/wm_root_window_controller.h ('k') | ash/mus/BUILD.gn » ('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 2016 The Chromium Authors. All rights reserved. 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 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 #include "ash/common/wm_root_window_controller.h" 5 #include "ash/common/wm_root_window_controller.h"
6 6
7 #include "ash/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/shelf/shelf_layout_manager.h" 9 #include "ash/common/shelf/shelf_layout_manager.h"
10 #include "ash/common/shelf/shelf_widget.h" 10 #include "ash/common/shelf/shelf_widget.h"
11 #include "ash/common/shelf/wm_shelf.h" 11 #include "ash/common/shelf/wm_shelf.h"
12 #include "ash/common/shell_delegate.h" 12 #include "ash/common/shell_delegate.h"
13 #include "ash/common/system/status_area_widget.h" 13 #include "ash/common/system/status_area_widget.h"
14 #include "ash/common/wallpaper/wallpaper_delegate.h" 14 #include "ash/common/wallpaper/wallpaper_delegate.h"
15 #include "ash/common/wallpaper/wallpaper_widget_controller.h" 15 #include "ash/common/wallpaper/wallpaper_widget_controller.h"
16 #include "ash/common/wm/always_on_top_controller.h" 16 #include "ash/common/wm/always_on_top_controller.h"
17 #include "ash/common/wm/container_finder.h" 17 #include "ash/common/wm/container_finder.h"
18 #include "ash/common/wm/dock/docked_window_layout_manager.h" 18 #include "ash/common/wm/dock/docked_window_layout_manager.h"
19 #include "ash/common/wm/lock_layout_manager.h" 19 #include "ash/common/wm/lock_layout_manager.h"
20 #include "ash/common/wm/panels/panel_layout_manager.h" 20 #include "ash/common/wm/panels/panel_layout_manager.h"
21 #include "ash/common/wm/root_window_layout_manager.h" 21 #include "ash/common/wm/root_window_layout_manager.h"
22 #include "ash/common/wm/system_modal_container_layout_manager.h" 22 #include "ash/common/wm/system_modal_container_layout_manager.h"
23 #include "ash/common/wm/window_state.h" 23 #include "ash/common/wm/window_state.h"
24 #include "ash/common/wm/wm_snap_to_pixel_layout_manager.h" 24 #include "ash/common/wm/wm_snap_to_pixel_layout_manager.h"
25 #include "ash/common/wm/workspace/workspace_layout_manager.h" 25 #include "ash/common/wm/workspace/workspace_layout_manager.h"
26 #include "ash/common/wm/workspace_controller.h" 26 #include "ash/common/wm/workspace_controller.h"
27 #include "ash/common/wm_shell.h" 27 #include "ash/common/wm_shell.h"
28 #include "ash/common/wm_window.h" 28 #include "ash/common/wm_window.h"
29 #include "ash/public/cpp/shell_window_ids.h" 29 #include "ash/public/cpp/shell_window_ids.h"
30 #include "ash/root_window_controller.h"
31 #include "ash/shell.h"
30 #include "base/memory/ptr_util.h" 32 #include "base/memory/ptr_util.h"
33 #include "ui/aura/env.h"
34 #include "ui/aura/mus/window_mus.h"
35 #include "ui/aura/mus/window_tree_client.h"
31 #include "ui/aura/window.h" 36 #include "ui/aura/window.h"
32 #include "ui/aura/window_event_dispatcher.h" 37 #include "ui/aura/window_event_dispatcher.h"
33 #include "ui/aura/window_tree_host.h" 38 #include "ui/aura/window_tree_host.h"
34 #include "ui/base/models/menu_model.h" 39 #include "ui/base/models/menu_model.h"
35 #include "ui/events/event_targeter.h" 40 #include "ui/events/event_targeter.h"
36 #include "ui/events/event_utils.h" 41 #include "ui/events/event_utils.h"
37 #include "ui/views/controls/menu/menu_model_adapter.h" 42 #include "ui/views/controls/menu/menu_model_adapter.h"
38 #include "ui/views/controls/menu/menu_runner.h" 43 #include "ui/views/controls/menu/menu_runner.h"
39 44
40 namespace ash { 45 namespace ash {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 window->SetShellWindowId(window_id); 149 window->SetShellWindowId(window_id);
145 window->SetName(name); 150 window->SetName(name);
146 parent->AddChild(window); 151 parent->AddChild(window);
147 if (window_id != kShellWindowId_UnparentedControlContainer) 152 if (window_id != kShellWindowId_UnparentedControlContainer)
148 window->Show(); 153 window->Show();
149 return window; 154 return window;
150 } 155 }
151 156
152 } // namespace 157 } // namespace
153 158
154 WmRootWindowController::WmRootWindowController(WmWindow* root) : root_(root) {} 159 WmRootWindowController::WmRootWindowController(
160 RootWindowController* root_window_controller,
161 WmWindow* root)
162 : root_window_controller_(root_window_controller), root_(root) {
163 DCHECK(root_window_controller_);
164 DCHECK(root_);
165 }
155 166
156 WmRootWindowController::~WmRootWindowController() { 167 WmRootWindowController::~WmRootWindowController() {
157 if (animating_wallpaper_widget_controller_.get()) 168 if (animating_wallpaper_widget_controller_.get())
158 animating_wallpaper_widget_controller_->StopAnimating(); 169 animating_wallpaper_widget_controller_->StopAnimating();
159 } 170 }
160 171
161 void WmRootWindowController::SetWallpaperWidgetController( 172 void WmRootWindowController::SetWallpaperWidgetController(
162 WallpaperWidgetController* controller) { 173 WallpaperWidgetController* controller) {
163 wallpaper_widget_controller_.reset(controller); 174 wallpaper_widget_controller_.reset(controller);
164 } 175 }
(...skipping 27 matching lines...) Expand all
192 WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked() 203 WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()
193 ? kShellWindowId_LockSystemModalContainer 204 ? kShellWindowId_LockSystemModalContainer
194 : kShellWindowId_SystemModalContainer; 205 : kShellWindowId_SystemModalContainer;
195 modal_container = GetContainer(modal_window_id); 206 modal_container = GetContainer(modal_window_id);
196 } 207 }
197 return modal_container ? static_cast<SystemModalContainerLayoutManager*>( 208 return modal_container ? static_cast<SystemModalContainerLayoutManager*>(
198 modal_container->GetLayoutManager()) 209 modal_container->GetLayoutManager())
199 : nullptr; 210 : nullptr;
200 } 211 }
201 212
213 bool WmRootWindowController::HasShelf() {
214 return GetShelf()->shelf_widget() != nullptr;
215 }
216
217 WmShelf* WmRootWindowController::GetShelf() {
218 return root_window_controller_->wm_shelf();
219 }
220
202 void WmRootWindowController::CreateShelf() { 221 void WmRootWindowController::CreateShelf() {
203 WmShelf* shelf = GetShelf(); 222 WmShelf* shelf = GetShelf();
204 if (shelf->IsShelfInitialized()) 223 if (shelf->IsShelfInitialized())
205 return; 224 return;
206 shelf->InitializeShelf(); 225 shelf->InitializeShelf();
207 226
208 if (panel_layout_manager_) 227 if (panel_layout_manager_)
209 panel_layout_manager_->SetShelf(shelf); 228 panel_layout_manager_->SetShelf(shelf);
210 if (docked_window_layout_manager_) { 229 if (docked_window_layout_manager_) {
211 docked_window_layout_manager_->SetShelf(shelf); 230 docked_window_layout_manager_->SetShelf(shelf);
(...skipping 18 matching lines...) Expand all
230 shelf->shelf_widget()->status_area_widget()->Show(); 249 shelf->shelf_widget()->status_area_widget()->Show();
231 } 250 }
232 251
233 SystemTray* WmRootWindowController::GetSystemTray() { 252 SystemTray* WmRootWindowController::GetSystemTray() {
234 ShelfWidget* shelf_widget = GetShelf()->shelf_widget(); 253 ShelfWidget* shelf_widget = GetShelf()->shelf_widget();
235 if (!shelf_widget || !shelf_widget->status_area_widget()) 254 if (!shelf_widget || !shelf_widget->status_area_widget())
236 return nullptr; 255 return nullptr;
237 return shelf_widget->status_area_widget()->system_tray(); 256 return shelf_widget->status_area_widget()->system_tray();
238 } 257 }
239 258
259 WmWindow* WmRootWindowController::GetWindow() {
260 return root_;
261 }
262
240 WmWindow* WmRootWindowController::GetContainer(int container_id) { 263 WmWindow* WmRootWindowController::GetContainer(int container_id) {
241 return root_->GetChildByShellWindowId(container_id); 264 return root_->GetChildByShellWindowId(container_id);
242 } 265 }
243 266
244 const WmWindow* WmRootWindowController::GetContainer(int container_id) const { 267 const WmWindow* WmRootWindowController::GetContainer(int container_id) const {
245 return root_->GetChildByShellWindowId(container_id); 268 return root_->GetChildByShellWindowId(container_id);
246 } 269 }
247 270
248 void WmRootWindowController::ConfigureWidgetInitParamsForContainer( 271 void WmRootWindowController::ConfigureWidgetInitParamsForContainer(
249 views::Widget* widget, 272 views::Widget* widget,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 317
295 menu_runner_.reset(new views::MenuRunner( 318 menu_runner_.reset(new views::MenuRunner(
296 menu_model_adapter_->CreateMenu(), 319 menu_model_adapter_->CreateMenu(),
297 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC)); 320 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC));
298 ignore_result( 321 ignore_result(
299 menu_runner_->RunMenuAt(wallpaper_widget_controller()->widget(), nullptr, 322 menu_runner_->RunMenuAt(wallpaper_widget_controller()->widget(), nullptr,
300 gfx::Rect(location_in_screen, gfx::Size()), 323 gfx::Rect(location_in_screen, gfx::Size()),
301 views::MENU_ANCHOR_TOPLEFT, source_type)); 324 views::MENU_ANCHOR_TOPLEFT, source_type));
302 } 325 }
303 326
304 void WmRootWindowController::OnInitialWallpaperAnimationStarted() {} 327 void WmRootWindowController::OnInitialWallpaperAnimationStarted() {
328 root_window_controller_->OnInitialWallpaperAnimationStarted();
329 }
305 330
306 void WmRootWindowController::OnWallpaperAnimationFinished( 331 void WmRootWindowController::OnWallpaperAnimationFinished(
307 views::Widget* widget) { 332 views::Widget* widget) {
333 root_window_controller_->OnWallpaperAnimationFinished(widget);
308 WmShell::Get()->wallpaper_delegate()->OnWallpaperAnimationFinished(); 334 WmShell::Get()->wallpaper_delegate()->OnWallpaperAnimationFinished();
309 // Only removes old component when wallpaper animation finished. If we 335 // Only removes old component when wallpaper animation finished. If we
310 // remove the old one before the new wallpaper is done fading in there will 336 // remove the old one before the new wallpaper is done fading in there will
311 // be a white flash during the animation. 337 // be a white flash during the animation.
312 if (animating_wallpaper_widget_controller()) { 338 if (animating_wallpaper_widget_controller()) {
313 WallpaperWidgetController* controller = 339 WallpaperWidgetController* controller =
314 animating_wallpaper_widget_controller()->GetController(true); 340 animating_wallpaper_widget_controller()->GetController(true);
315 DCHECK_EQ(controller->widget(), widget); 341 DCHECK_EQ(controller->widget(), widget);
316 // Release the old controller and close its wallpaper widget. 342 // Release the old controller and close its wallpaper widget.
317 SetWallpaperWidgetController(controller); 343 SetWallpaperWidgetController(controller);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 } 645 }
620 646
621 shelf->DestroyShelfWidget(); 647 shelf->DestroyShelfWidget();
622 648
623 // CloseChildWindows() may be called twice during the shutdown of ash 649 // CloseChildWindows() may be called twice during the shutdown of ash
624 // unittests. Avoid notifying WmShelf that the shelf has been destroyed twice. 650 // unittests. Avoid notifying WmShelf that the shelf has been destroyed twice.
625 if (shelf->IsShelfInitialized()) 651 if (shelf->IsShelfInitialized())
626 shelf->ShutdownShelf(); 652 shelf->ShutdownShelf();
627 } 653 }
628 654
655 bool WmRootWindowController::ShouldDestroyWindowInCloseChildWindows(
656 WmWindow* window) {
657 if (!WmWindowAura::GetAuraWindow(window)->owned_by_parent())
658 return false;
659
660 if (aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL)
661 return true;
662
663 aura::WindowMus* window_mus =
664 aura::WindowMus::Get(WmWindowAura::GetAuraWindow(window));
665 return Shell::window_tree_client()->WasCreatedByThisClient(window_mus) ||
666 Shell::window_tree_client()->IsRoot(window_mus);
667 }
668
629 void WmRootWindowController::OnMenuClosed() { 669 void WmRootWindowController::OnMenuClosed() {
630 menu_runner_.reset(); 670 menu_runner_.reset();
631 menu_model_adapter_.reset(); 671 menu_model_adapter_.reset();
632 menu_model_.reset(); 672 menu_model_.reset();
633 GetShelf()->UpdateVisibilityState(); 673 GetShelf()->UpdateVisibilityState();
634 } 674 }
635 675
636 } // namespace ash 676 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm_root_window_controller.h ('k') | ash/mus/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698