Chromium Code Reviews| Index: ash/shelf/shelf_layout_manager.cc |
| diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc |
| index ba25161f0dfb774a87381a75981d3c666fb6054a..d0f49d3672bb82e40889c8cb684dbb25febbcfb3 100644 |
| --- a/ash/shelf/shelf_layout_manager.cc |
| +++ b/ash/shelf/shelf_layout_manager.cc |
| @@ -26,7 +26,6 @@ |
| #include "ash/common/wm_window.h" |
| #include "ash/shelf/shelf.h" |
| #include "ash/shelf/shelf_layout_manager_observer.h" |
| -#include "ash/wm/workspace_controller.h" |
| #include "base/auto_reset.h" |
| #include "base/i18n/rtl.h" |
| #include "ui/compositor/layer.h" |
| @@ -144,7 +143,6 @@ class ShelfLayoutManager::RootWindowControllerObserverImpl |
| ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf_widget) |
| : updating_bounds_(false), |
| shelf_widget_(shelf_widget), |
| - workspace_controller_(NULL), |
| window_overlaps_shelf_(false), |
| mouse_over_shelf_when_auto_hide_timer_started_(false), |
| gesture_drag_status_(GESTURE_DRAG_NONE), |
| @@ -174,7 +172,6 @@ ShelfLayoutManager::~ShelfLayoutManager() { |
| void ShelfLayoutManager::PrepareForShutdown() { |
| in_shutdown_ = true; |
| - set_workspace_controller(nullptr); |
| // Stop observing changes to avoid updating a partially destructed shelf. |
| WmShell::Get()->RemoveActivationObserver(this); |
| } |
| @@ -228,9 +225,10 @@ ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() { |
| } |
| void ShelfLayoutManager::UpdateVisibilityState() { |
| - // Bail out early when there is no |workspace_controller_|, which happens |
| - // during shutdown after PrepareForShutdown. Also bail before a shelf exists. |
| - if (!workspace_controller_ || !shelf_widget_->shelf()) |
| + WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); |
| + WmRootWindowController* controller = shelf_window->GetRootWindowController(); |
|
James Cook
2016/08/12 01:52:50
optional: I liked the old name better, |controller
msw
2016/08/12 04:01:57
Acknowledged; I'll leave it as-is.
|
| + // Bail out early before the shelf is initialized or after it is destroyed. |
| + if (!controller || !shelf_widget_->shelf() || in_shutdown_) |
| return; |
| if (state_.is_screen_locked || state_.is_adding_user_screen) { |
| @@ -241,7 +239,7 @@ void ShelfLayoutManager::UpdateVisibilityState() { |
| // TODO(zelidrag): Verify shelf drag animation still shows on the device |
| // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. |
| wm::WorkspaceWindowState window_state( |
| - workspace_controller_->GetWindowState()); |
| + controller->GetWorkspaceWindowState()); |
| switch (window_state) { |
| case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: { |
| if (IsShelfHiddenForFullscreen()) { |
| @@ -465,15 +463,14 @@ ShelfLayoutManager::TargetBounds::TargetBounds() |
| ShelfLayoutManager::TargetBounds::~TargetBounds() {} |
| void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { |
| - if (!shelf_widget_->GetNativeView()) |
| - return; |
| - |
| State state; |
| state.visibility_state = visibility_state; |
| state.auto_hide_state = CalculateAutoHideState(visibility_state); |
| - state.window_state = workspace_controller_ |
| - ? workspace_controller_->GetWindowState() |
| - : wm::WORKSPACE_WINDOW_STATE_DEFAULT; |
| + |
| + WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); |
| + WmRootWindowController* controller = shelf_window->GetRootWindowController(); |
| + state.window_state = controller ? controller->GetWorkspaceWindowState() |
| + : wm::WORKSPACE_WINDOW_STATE_DEFAULT; |
| // Preserve the log in screen states. |
| state.is_adding_user_screen = state_.is_adding_user_screen; |
| state.is_screen_locked = state_.is_screen_locked; |