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 482fbb58141b87a34383da830123ebe18f7a3fc3..dbaedca904cb68cde2bd23aa83dac5979caf899d 100644 |
| --- a/ash/shelf/shelf_layout_manager.cc |
| +++ b/ash/shelf/shelf_layout_manager.cc |
| @@ -24,7 +24,10 @@ |
| #include "ash/shell.h" |
| #include "ash/shell_window_ids.h" |
| #include "ash/system/status_area_widget.h" |
| +#include "ash/wm/aura/wm_window_aura.h" |
| #include "ash/wm/common/window_state.h" |
| +#include "ash/wm/common/wm_root_window_controller.h" |
| +#include "ash/wm/common/wm_root_window_controller_observer.h" |
| #include "ash/wm/gestures/shelf_gesture_handler.h" |
| #include "ash/wm/lock_state_controller.h" |
| #include "ash/wm/mru_window_tracker.h" |
| @@ -183,6 +186,33 @@ class ShelfLayoutManager::UpdateShelfObserver |
| DISALLOW_COPY_AND_ASSIGN(UpdateShelfObserver); |
| }; |
| +// ShelfLayoutManager::RootWindowControllerObserverImpl ------------------------ |
| + |
| +// NOTE: OnShelfAlignmentChanged() is implemented by way of |
|
sky
2016/04/27 20:48:05
This is subtle and a bit unfortunate. But I think
|
| +// WmRootWindowControllerObserver to avoid ordering issues. The way |
| +// WmRootWindowControllerObserver is wired in means |
| +// WmRootWindowControllerObservers may be notified after ShellObservers. |
|
James Cook
2016/04/27 23:24:24
The part that I missed in thinking about this was
sky
2016/04/27 23:33:28
I copied what you have here.
|
| +// By making this code use a WmRootWindowControllerObservers we get sane |
| +// ordering (or at least ordering as we've always had it in ash). |
| +class ShelfLayoutManager::RootWindowControllerObserverImpl |
| + : public wm::WmRootWindowControllerObserver { |
| + public: |
| + explicit RootWindowControllerObserverImpl( |
| + ShelfLayoutManager* shelf_layout_manager) |
| + : shelf_layout_manager_(shelf_layout_manager) {} |
| + ~RootWindowControllerObserverImpl() override {} |
| + |
| + // WmRootWindowControllerObserver: |
| + void OnShelfAlignmentChanged() override { |
| + shelf_layout_manager_->LayoutShelf(); |
| + } |
| + |
| + private: |
| + ShelfLayoutManager* shelf_layout_manager_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RootWindowControllerObserverImpl); |
| +}; |
| + |
| // ShelfLayoutManager ---------------------------------------------------------- |
| ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf) |
| @@ -199,8 +229,13 @@ ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf) |
| gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), |
| update_shelf_observer_(NULL), |
| chromevox_panel_height_(0), |
| - duration_override_in_ms_(0) { |
| + duration_override_in_ms_(0), |
| + root_window_controller_observer_( |
| + new RootWindowControllerObserverImpl(this)) { |
| Shell::GetInstance()->AddShellObserver(this); |
| + wm::WmWindowAura::Get(root_window_) |
| + ->GetRootWindowController() |
| + ->AddObserver(root_window_controller_observer_.get()); |
| Shell::GetInstance()->lock_state_controller()->AddObserver(this); |
| aura::client::GetActivationClient(root_window_)->AddObserver(this); |
| Shell::GetInstance()->session_state_delegate()->AddSessionStateObserver(this); |
| @@ -215,6 +250,9 @@ ShelfLayoutManager::~ShelfLayoutManager() { |
| Shell::GetInstance()->lock_state_controller()->RemoveObserver(this); |
| Shell::GetInstance()-> |
| session_state_delegate()->RemoveSessionStateObserver(this); |
| + wm::WmWindowAura::Get(root_window_) |
| + ->GetRootWindowController() |
| + ->RemoveObserver(root_window_controller_observer_.get()); |
| } |
| void ShelfLayoutManager::PrepareForShutdown() { |
| @@ -477,10 +515,6 @@ void ShelfLayoutManager::OnLockStateChanged(bool locked) { |
| UpdateShelfVisibilityAfterLoginUIChange(); |
| } |
| -void ShelfLayoutManager::OnShelfAlignmentChanged(aura::Window* root_window) { |
| - LayoutShelf(); |
| -} |
| - |
| void ShelfLayoutManager::OnShelfAutoHideBehaviorChanged( |
| aura::Window* root_window) { |
| UpdateVisibilityState(); |