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_root_window_controller_aura.h" | 11 #include "ash/aura/wm_root_window_controller_aura.h" |
12 #include "ash/aura/wm_shelf_aura.h" | 12 #include "ash/aura/wm_shelf_aura.h" |
13 #include "ash/aura/wm_window_aura.h" | 13 #include "ash/aura/wm_window_aura.h" |
14 #include "ash/common/ash_constants.h" | 14 #include "ash/common/ash_constants.h" |
15 #include "ash/common/ash_switches.h" | 15 #include "ash/common/ash_switches.h" |
16 #include "ash/common/focus_cycler.h" | 16 #include "ash/common/focus_cycler.h" |
17 #include "ash/common/login_status.h" | 17 #include "ash/common/login_status.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_->IsShelfInitialized()) |
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_->IsShelfInitialized()) |
475 return; | 475 return; |
476 ShelfView* shelf_view = shelf_widget_->CreateShelfView(); | 476 wm_shelf_aura_->InitializeShelf(); |
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. |
| 488 // TODO(jamescook): Move this into WmShelf::InitializeShelf(). This will |
| 489 // require changing AttachedPanelWidgetTargeter's access to WmShelf. |
496 WmShell::Get()->NotifyShelfCreatedForRootWindow( | 490 WmShell::Get()->NotifyShelfCreatedForRootWindow( |
497 WmWindowAura::Get(GetRootWindow())); | 491 WmWindowAura::Get(GetRootWindow())); |
498 | 492 |
499 shelf_widget_->PostCreateShelf(); | 493 shelf_widget_->PostCreateShelf(); |
500 } | 494 } |
501 | 495 |
502 Shelf* RootWindowController::GetShelf() const { | |
503 return shelf_.get(); | |
504 } | |
505 | |
506 void RootWindowController::UpdateAfterLoginStatusChange(LoginStatus status) { | 496 void RootWindowController::UpdateAfterLoginStatusChange(LoginStatus status) { |
507 if (status != LoginStatus::NOT_LOGGED_IN) | 497 if (status != LoginStatus::NOT_LOGGED_IN) |
508 mouse_event_target_.reset(); | 498 mouse_event_target_.reset(); |
509 if (shelf_widget_->status_area_widget()) | 499 if (shelf_widget_->status_area_widget()) |
510 shelf_widget_->status_area_widget()->UpdateAfterLoginStatusChange(status); | 500 shelf_widget_->status_area_widget()->UpdateAfterLoginStatusChange(status); |
511 } | 501 } |
512 | 502 |
513 void RootWindowController::HandleInitialWallpaperAnimationStarted() { | 503 void RootWindowController::HandleInitialWallpaperAnimationStarted() { |
514 #if defined(OS_CHROMEOS) | 504 #if defined(OS_CHROMEOS) |
515 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 505 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]; | 596 aura::Window* window = root_window->children()[0]; |
607 if (window->owned_by_parent()) { | 597 if (window->owned_by_parent()) { |
608 delete window; | 598 delete window; |
609 } else { | 599 } else { |
610 root_window->RemoveChild(window); | 600 root_window->RemoveChild(window); |
611 } | 601 } |
612 } | 602 } |
613 | 603 |
614 shelf_widget_.reset(); | 604 shelf_widget_.reset(); |
615 // CloseChildWindows may be called twice during the shutdown of ash unittests. | 605 // CloseChildWindows may be called twice during the shutdown of ash unittests. |
616 // Avoid notifying WmShelf that the Shelf instance has been destroyed twice. | 606 // Avoid notifying WmShelf that the shelf has been destroyed twice. |
617 if (wm_shelf_aura_->shelf()) | 607 if (wm_shelf_aura_->IsShelfInitialized()) |
618 wm_shelf_aura_->ClearShelf(); | 608 wm_shelf_aura_->ShutdownShelf(); |
619 shelf_.reset(); | |
620 } | 609 } |
621 | 610 |
622 void RootWindowController::MoveWindowsTo(aura::Window* dst) { | 611 void RootWindowController::MoveWindowsTo(aura::Window* dst) { |
623 // Clear the workspace controller, so it doesn't incorrectly update the shelf. | 612 // Clear the workspace controller, so it doesn't incorrectly update the shelf. |
624 wm_root_window_controller_->DeleteWorkspaceController(); | 613 wm_root_window_controller_->DeleteWorkspaceController(); |
625 ReparentAllWindows(GetRootWindow(), dst); | 614 ReparentAllWindows(GetRootWindow(), dst); |
626 } | 615 } |
627 | 616 |
628 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 617 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
629 return shelf_widget_->shelf_layout_manager(); | 618 return shelf_widget_->shelf_layout_manager(); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 aura::Window* primary_root_window = Shell::GetInstance() | 942 aura::Window* primary_root_window = Shell::GetInstance() |
954 ->window_tree_host_manager() | 943 ->window_tree_host_manager() |
955 ->GetPrimaryRootWindow(); | 944 ->GetPrimaryRootWindow(); |
956 return GetRootWindowSettings(primary_root_window)->controller; | 945 return GetRootWindowSettings(primary_root_window)->controller; |
957 } | 946 } |
958 | 947 |
959 return GetRootWindowSettings(root_window)->controller; | 948 return GetRootWindowSettings(root_window)->controller; |
960 } | 949 } |
961 | 950 |
962 } // namespace ash | 951 } // namespace ash |
OLD | NEW |