Chromium Code Reviews| Index: ash/root_window_controller.cc |
| diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc |
| index dcb3babbc376cccba406109e18b8e8ef81ed3a43..d4f7980e7df4e34b3daefd22e7661c8fa4abfcb9 100644 |
| --- a/ash/root_window_controller.cc |
| +++ b/ash/root_window_controller.cc |
| @@ -12,7 +12,9 @@ |
| #include "ash/display/display_controller.h" |
| #include "ash/display/display_manager.h" |
| #include "ash/focus_cycler.h" |
| -#include "ash/shelf_types.h" |
| +#include "ash/shelf/shelf_layout_manager.h" |
| +#include "ash/shelf/shelf_types.h" |
| +#include "ash/shelf/shelf_widget.h" |
| #include "ash/shell.h" |
| #include "ash/shell_delegate.h" |
| #include "ash/shell_factory.h" |
| @@ -25,7 +27,6 @@ |
| #include "ash/wm/property_util.h" |
| #include "ash/wm/root_window_layout_manager.h" |
| #include "ash/wm/screen_dimmer.h" |
| -#include "ash/wm/shelf_layout_manager.h" |
| #include "ash/wm/stacking_controller.h" |
| #include "ash/wm/status_area_layout_manager.h" |
| #include "ash/wm/system_background_controller.h" |
| @@ -165,7 +166,6 @@ namespace internal { |
| RootWindowController::RootWindowController(aura::RootWindow* root_window) |
| : root_window_(root_window), |
| root_window_layout_(NULL), |
| - status_area_widget_(NULL), |
| shelf_(NULL), |
| panel_layout_manager_(NULL) { |
| SetRootWindowController(root_window, this); |
| @@ -216,13 +216,6 @@ void RootWindowController::Shutdown() { |
| root_window_->PrepareForShutdown(); |
| system_background_.reset(); |
| - |
| - // Launcher widget has an InputMethodBridge that references to |
| - // |input_method_filter_|'s |input_method_|. So explicitly release |
| - // |launcher_| before |input_method_filter_|. And this needs to be |
| - // after we delete all containers in case there are still live |
| - // browser windows which access LauncherModel during close. |
| - launcher_.reset(); |
| } |
| SystemModalContainerLayoutManager* |
| @@ -272,34 +265,14 @@ void RootWindowController::InitLayoutManagers() { |
| } |
| void RootWindowController::InitForPrimaryDisplay() { |
| - DCHECK(!status_area_widget_); |
| + DCHECK(!shelf_); |
| + aura::Window* shelf_container = |
| + GetContainer(ash::internal::kShellWindowId_ShelfContainer); |
| + // todo (harrym) remove when status area is view. |
|
Mr4D (OOO till 08-26)
2013/02/27 19:42:51
// TODO(harrym): remove..
Harry McCleave
2013/03/01 04:31:19
Done.
|
| aura::Window* status_container = |
| GetContainer(ash::internal::kShellWindowId_StatusContainer); |
| - // Initialize Primary RootWindow specific items. |
| - status_area_widget_ = new internal::StatusAreaWidget(status_container); |
| - status_area_widget_->CreateTrayViews(); |
| - // Login screen manages status area visibility by itself. |
| - ShellDelegate* shell_delegate = Shell::GetInstance()->delegate(); |
| - if (shell_delegate->IsSessionStarted()) |
| - status_area_widget_->Show(); |
| - |
| - Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_); |
| - |
| - internal::ShelfLayoutManager* shelf_layout_manager = |
| - new internal::ShelfLayoutManager(status_area_widget_); |
| - GetContainer(internal::kShellWindowId_LauncherContainer)-> |
| - SetLayoutManager(shelf_layout_manager); |
| - shelf_ = shelf_layout_manager; |
| - |
| - internal::StatusAreaLayoutManager* status_area_layout_manager = |
| - new internal::StatusAreaLayoutManager(shelf_layout_manager); |
| - GetContainer(internal::kShellWindowId_StatusContainer)-> |
| - SetLayoutManager(status_area_layout_manager); |
| - |
| - shelf_layout_manager->set_workspace_controller( |
| - workspace_controller()); |
| - |
| - workspace_controller()->SetShelf(shelf_); |
| + shelf_ = new ash::ShelfWidget( |
|
Mr4D (OOO till 08-26)
2013/02/27 19:42:51
I am fairly certain that shelf_ should be a scoped
Harry McCleave
2013/03/01 04:31:19
Done.
|
| + shelf_container, status_container, workspace_controller()); |
| if (Shell::IsLauncherPerDisplayEnabled() || |
| root_window_ == Shell::GetPrimaryRootWindow()) { |
| @@ -313,8 +286,8 @@ void RootWindowController::InitForPrimaryDisplay() { |
| panel_container->SetLayoutManager(panel_layout_manager_); |
| } |
| - if (shell_delegate->IsUserLoggedIn()) |
| - CreateLauncher(); |
| + if (Shell::GetInstance()->delegate()->IsUserLoggedIn()) |
| + shelf_->CreateLauncher(); |
| } |
| void RootWindowController::CreateContainers() { |
| @@ -343,50 +316,28 @@ void RootWindowController::CreateSystemBackground( |
| #endif |
| } |
| -void RootWindowController::CreateLauncher() { |
| - if (launcher_.get()) |
| - return; |
| - |
| - aura::Window* default_container = |
| - GetContainer(internal::kShellWindowId_DefaultContainer); |
| - // Get the delegate first to make sure the launcher model is created. |
| - LauncherDelegate* launcher_delegate = |
| - Shell::GetInstance()->GetLauncherDelegate(); |
| - launcher_.reset(new Launcher(Shell::GetInstance()->launcher_model(), |
| - launcher_delegate, |
| - default_container, |
| - shelf_)); |
| - |
| - launcher_->SetFocusCycler(Shell::GetInstance()->focus_cycler()); |
| - shelf_->SetLauncher(launcher_.get()); |
| - |
| - if (panel_layout_manager_) |
| - panel_layout_manager_->SetLauncher(launcher_.get()); |
| - |
| - ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
| - if (delegate) |
| - launcher_->SetVisible(delegate->IsSessionStarted()); |
| - launcher_->widget()->Show(); |
| +void RootWindowController::OnLauncherCreated() { |
| + panel_layout_manager_->SetLauncher(shelf_->launcher()); |
| } |
| void RootWindowController::ShowLauncher() { |
| - if (!launcher_.get()) |
| + if (!shelf_->launcher()) |
| return; |
| - launcher_->SetVisible(true); |
| - status_area_widget_->Show(); |
| + shelf_->launcher()->SetVisible(true); |
| + shelf_->status_area_widget()->Show(); |
| } |
| void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { |
| // TODO(oshima): remove if when launcher per display is enabled by |
| // default. |
| if (shelf_) |
| - shelf_->UpdateVisibilityState(); |
| + shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
| } |
| void RootWindowController::UpdateAfterLoginStatusChange( |
| user::LoginStatus status) { |
| - if (status_area_widget_) |
| - status_area_widget_->UpdateAfterLoginStatusChange(status); |
| + if (shelf_->status_area_widget()) |
| + shelf_->status_area_widget()->UpdateAfterLoginStatusChange(status); |
| } |
| void RootWindowController::HandleInitialDesktopBackgroundAnimationStarted() { |
| @@ -406,21 +357,18 @@ void RootWindowController::HandleDesktopBackgroundVisible() { |
| } |
| void RootWindowController::CloseChildWindows() { |
| - // The status area needs to be shut down before the windows are destroyed. |
| - if (status_area_widget_) { |
| - status_area_widget_->Shutdown(); |
| - status_area_widget_ = NULL; |
| - } |
| - |
| // panel_layout_manager_ needs to be shut down before windows are destroyed. |
| if (panel_layout_manager_) { |
| panel_layout_manager_->Shutdown(); |
| panel_layout_manager_ = NULL; |
| } |
| - // Closing the windows frees the workspace controller. |
| - if (shelf_) |
| - shelf_->set_workspace_controller(NULL); |
| + // todo(HarryM) remove when Status Area Widget is a child view. |
| + if (shelf_ && shelf_->status_area_widget()) |
| + shelf_->status_area_widget()->Shutdown(); |
| + |
| + if (shelf_ && shelf_->shelf_layout_manager()) |
| + shelf_->shelf_layout_manager()->set_workspace_controller(NULL); |
| // Close background widget first as it depends on tooltip. |
| root_window_->SetProperty(kDesktopController, |
| @@ -435,8 +383,8 @@ void RootWindowController::CloseChildWindows() { |
| aura::Window* child = root_window_->children()[0]; |
| delete child; |
| } |
| - launcher_.reset(); |
| - // All containers are deleted, so reset shelf_. |
| + |
| + // All containers have been deleted, including shelf. |
| shelf_ = NULL; |
| } |
| @@ -474,13 +422,14 @@ void RootWindowController::MoveWindowsTo(aura::RootWindow* dst) { |
| activation_client->ActivateWindow(active); |
| } |
| } |
|
Mr4D (OOO till 08-26)
2013/02/27 19:42:51
empty line here
Harry McCleave
2013/03/01 04:31:19
Done.
|
| - |
| +ShelfLayoutManager* RootWindowController::shelf_layout_manager() const { |
| + return shelf_ ? shelf_->shelf_layout_manager() : NULL; |
| +} |
|
Mr4D (OOO till 08-26)
2013/02/27 19:42:51
empty line again
Harry McCleave
2013/03/01 04:31:19
Done.
|
| SystemTray* RootWindowController::GetSystemTray() { |
| // We assume in throughout the code that this will not return NULL. If code |
| // triggers this for valid reasons, it should test status_area_widget first. |
| - internal::StatusAreaWidget* status_area = status_area_widget(); |
| - CHECK(status_area); |
| - return status_area->system_tray(); |
| + CHECK(shelf_ && shelf_->status_area_widget()); |
| + return shelf_->status_area_widget()->system_tray(); |
| } |
| void RootWindowController::ShowContextMenu( |
| @@ -508,24 +457,7 @@ void RootWindowController::ShowContextMenu( |
| } |
| void RootWindowController::UpdateShelfVisibility() { |
| - shelf_->UpdateVisibilityState(); |
| -} |
| - |
| -void RootWindowController::SetShelfAutoHideBehavior( |
| - ShelfAutoHideBehavior behavior) { |
| - shelf_->SetAutoHideBehavior(behavior); |
| -} |
| - |
| -ShelfAutoHideBehavior RootWindowController::GetShelfAutoHideBehavior() const { |
| - return shelf_->auto_hide_behavior(); |
| -} |
| - |
| -bool RootWindowController::SetShelfAlignment(ShelfAlignment alignment) { |
| - return shelf_->SetAlignment(alignment); |
| -} |
| - |
| -ShelfAlignment RootWindowController::GetShelfAlignment() { |
| - return shelf_->GetAlignment(); |
| + shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
| } |
| bool RootWindowController::IsImmersiveMode() const { |
| @@ -609,7 +541,7 @@ void RootWindowController::CreateContainersInRootWindow( |
| SetUsesScreenCoordinates(panel_container); |
| aura::Window* launcher_container = |
| - CreateContainer(kShellWindowId_LauncherContainer, |
| + CreateContainer(kShellWindowId_ShelfContainer, |
| "LauncherContainer", |
| non_lock_screen_containers); |
| SetUsesScreenCoordinates(launcher_container); |