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 #include "ash/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/aura/aura_layout_manager_adapter.h" | 10 #include "ash/aura/aura_layout_manager_adapter.h" |
11 #include "ash/aura/wm_shelf_aura.h" | 11 #include "ash/aura/wm_shelf_aura.h" |
12 #include "ash/aura/wm_window_aura.h" | 12 #include "ash/aura/wm_window_aura.h" |
13 #include "ash/common/ash_constants.h" | 13 #include "ash/common/ash_constants.h" |
14 #include "ash/common/ash_switches.h" | 14 #include "ash/common/ash_switches.h" |
15 #include "ash/common/focus_cycler.h" | 15 #include "ash/common/focus_cycler.h" |
16 #include "ash/common/login_status.h" | 16 #include "ash/common/login_status.h" |
17 #include "ash/common/root_window_controller_common.h" | 17 #include "ash/common/root_window_controller_common.h" |
18 #include "ash/common/session/session_state_delegate.h" | 18 #include "ash/common/session/session_state_delegate.h" |
19 #include "ash/common/shelf/shelf.h" | |
20 #include "ash/common/shelf/shelf_delegate.h" | 19 #include "ash/common/shelf/shelf_delegate.h" |
21 #include "ash/common/shelf/shelf_layout_manager.h" | 20 #include "ash/common/shelf/shelf_layout_manager.h" |
22 #include "ash/common/shelf/shelf_types.h" | 21 #include "ash/common/shelf/shelf_types.h" |
23 #include "ash/common/shelf/shelf_widget.h" | 22 #include "ash/common/shelf/shelf_widget.h" |
24 #include "ash/common/shell_delegate.h" | 23 #include "ash/common/shell_delegate.h" |
25 #include "ash/common/shell_window_ids.h" | 24 #include "ash/common/shell_window_ids.h" |
26 #include "ash/common/system/status_area_layout_manager.h" | 25 #include "ash/common/system/status_area_layout_manager.h" |
27 #include "ash/common/system/status_area_widget.h" | 26 #include "ash/common/system/status_area_widget.h" |
28 #include "ash/common/system/tray/system_tray_delegate.h" | 27 #include "ash/common/system/tray/system_tray_delegate.h" |
29 #include "ash/common/wallpaper/wallpaper_delegate.h" | 28 #include "ash/common/wallpaper/wallpaper_delegate.h" |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 | 456 |
458 aura::Window* RootWindowController::GetContainer(int container_id) { | 457 aura::Window* RootWindowController::GetContainer(int container_id) { |
459 return GetRootWindow()->GetChildById(container_id); | 458 return GetRootWindow()->GetChildById(container_id); |
460 } | 459 } |
461 | 460 |
462 const aura::Window* RootWindowController::GetContainer(int container_id) const { | 461 const aura::Window* RootWindowController::GetContainer(int container_id) const { |
463 return ash_host_->AsWindowTreeHost()->window()->GetChildById(container_id); | 462 return ash_host_->AsWindowTreeHost()->window()->GetChildById(container_id); |
464 } | 463 } |
465 | 464 |
466 void RootWindowController::ShowShelf() { | 465 void RootWindowController::ShowShelf() { |
467 if (!shelf_) | 466 if (!wm_shelf_aura_->IsShelfCreated()) |
468 return; | 467 return; |
468 // TODO(jamescook): Move this into WmShelf. | |
469 shelf_widget_->SetShelfVisibility(true); | 469 shelf_widget_->SetShelfVisibility(true); |
470 shelf_widget_->status_area_widget()->Show(); | 470 shelf_widget_->status_area_widget()->Show(); |
471 } | 471 } |
472 | 472 |
473 void RootWindowController::CreateShelf() { | 473 void RootWindowController::CreateShelf() { |
474 if (shelf_) | 474 if (wm_shelf_aura_->IsShelfCreated()) |
475 return; | 475 return; |
476 ShelfView* shelf_view = shelf_widget_->CreateShelfView(); | 476 wm_shelf_aura_->CreateShelf(); |
477 | |
478 shelf_.reset( | |
479 new Shelf(wm_shelf_aura_.get(), shelf_view, shelf_widget_.get())); | |
480 shelf_widget_->set_shelf(shelf_.get()); | |
481 // Must be initialized before the delegate is notified because the delegate | |
482 // may try to access the WmShelf. | |
483 wm_shelf_aura_->SetShelf(shelf_.get()); | |
484 WmShell::Get()->shelf_delegate()->OnShelfCreated(wm_shelf_aura_.get()); | |
485 | 477 |
486 if (panel_layout_manager_) | 478 if (panel_layout_manager_) |
487 panel_layout_manager_->SetShelf(wm_shelf_aura_.get()); | 479 panel_layout_manager_->SetShelf(wm_shelf_aura_.get()); |
488 if (docked_layout_manager_) { | 480 if (docked_layout_manager_) { |
489 docked_layout_manager_->SetShelf(wm_shelf_aura_.get()); | 481 docked_layout_manager_->SetShelf(wm_shelf_aura_.get()); |
490 if (shelf_widget_->shelf_layout_manager()) | 482 if (shelf_widget_->shelf_layout_manager()) |
491 docked_layout_manager_->AddObserver( | 483 docked_layout_manager_->AddObserver( |
492 shelf_widget_->shelf_layout_manager()); | 484 shelf_widget_->shelf_layout_manager()); |
493 } | 485 } |
494 | 486 |
495 // Notify shell observers that the shelf has been created. | 487 // Notify shell observers that the shelf has been created. |
msw
2016/08/30 22:02:07
nit: I wonder if we can order this and PostCreateS
James Cook
2016/08/30 23:00:57
I'm going to do this in a follow-up CL. It turns o
| |
496 WmShell::Get()->NotifyShelfCreatedForRootWindow( | 488 WmShell::Get()->NotifyShelfCreatedForRootWindow( |
497 WmWindowAura::Get(GetRootWindow())); | 489 WmWindowAura::Get(GetRootWindow())); |
498 | 490 |
499 shelf_widget_->PostCreateShelf(); | 491 shelf_widget_->PostCreateShelf(); |
500 } | 492 } |
501 | 493 |
502 Shelf* RootWindowController::GetShelf() const { | |
503 return shelf_.get(); | |
504 } | |
505 | |
506 void RootWindowController::UpdateAfterLoginStatusChange(LoginStatus status) { | 494 void RootWindowController::UpdateAfterLoginStatusChange(LoginStatus status) { |
507 if (status != LoginStatus::NOT_LOGGED_IN) | 495 if (status != LoginStatus::NOT_LOGGED_IN) |
508 mouse_event_target_.reset(); | 496 mouse_event_target_.reset(); |
509 if (shelf_widget_->status_area_widget()) | 497 if (shelf_widget_->status_area_widget()) |
510 shelf_widget_->status_area_widget()->UpdateAfterLoginStatusChange(status); | 498 shelf_widget_->status_area_widget()->UpdateAfterLoginStatusChange(status); |
511 } | 499 } |
512 | 500 |
513 void RootWindowController::HandleInitialWallpaperAnimationStarted() { | 501 void RootWindowController::HandleInitialWallpaperAnimationStarted() { |
514 #if defined(OS_CHROMEOS) | 502 #if defined(OS_CHROMEOS) |
515 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 503 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
606 aura::Window* window = root_window->children()[0]; | 594 aura::Window* window = root_window->children()[0]; |
607 if (window->owned_by_parent()) { | 595 if (window->owned_by_parent()) { |
608 delete window; | 596 delete window; |
609 } else { | 597 } else { |
610 root_window->RemoveChild(window); | 598 root_window->RemoveChild(window); |
611 } | 599 } |
612 } | 600 } |
613 | 601 |
614 shelf_widget_.reset(); | 602 shelf_widget_.reset(); |
615 // CloseChildWindows may be called twice during the shutdown of ash unittests. | 603 // CloseChildWindows may be called twice during the shutdown of ash unittests. |
616 // Avoid notifying WmShelf that the Shelf instance has been destroyed twice. | 604 // Avoid notifying WmShelf that the shelf has been destroyed twice. |
617 if (wm_shelf_aura_->shelf()) | 605 if (wm_shelf_aura_->IsShelfCreated()) |
618 wm_shelf_aura_->ClearShelf(); | 606 wm_shelf_aura_->DestroyShelf(); |
619 shelf_.reset(); | |
620 } | 607 } |
621 | 608 |
622 void RootWindowController::MoveWindowsTo(aura::Window* dst) { | 609 void RootWindowController::MoveWindowsTo(aura::Window* dst) { |
623 // Clear the workspace controller, so it doesn't incorrectly update the shelf. | 610 // Clear the workspace controller, so it doesn't incorrectly update the shelf. |
624 root_window_controller_common_->DeleteWorkspaceController(); | 611 root_window_controller_common_->DeleteWorkspaceController(); |
625 ReparentAllWindows(GetRootWindow(), dst); | 612 ReparentAllWindows(GetRootWindow(), dst); |
626 } | 613 } |
627 | 614 |
628 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 615 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
629 return shelf_widget_->shelf_layout_manager(); | 616 return shelf_widget_->shelf_layout_manager(); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
952 aura::Window* primary_root_window = Shell::GetInstance() | 939 aura::Window* primary_root_window = Shell::GetInstance() |
953 ->window_tree_host_manager() | 940 ->window_tree_host_manager() |
954 ->GetPrimaryRootWindow(); | 941 ->GetPrimaryRootWindow(); |
955 return GetRootWindowSettings(primary_root_window)->controller; | 942 return GetRootWindowSettings(primary_root_window)->controller; |
956 } | 943 } |
957 | 944 |
958 return GetRootWindowSettings(root_window)->controller; | 945 return GetRootWindowSettings(root_window)->controller; |
959 } | 946 } |
960 | 947 |
961 } // namespace ash | 948 } // namespace ash |
OLD | NEW |