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 efb1a9349bd1d251c08d31fe361ec2314758efe3..d2bde3ec515e6e1ab5dbed142d43f9dbe232857e 100644 |
| --- a/ash/shelf/shelf_layout_manager.cc |
| +++ b/ash/shelf/shelf_layout_manager.cc |
| @@ -229,13 +229,18 @@ 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), |
| - root_window_controller_observer_( |
| - new RootWindowControllerObserverImpl(this)) { |
| + duration_override_in_ms_(0) { |
| Shell::GetInstance()->AddShellObserver(this); |
| - wm::WmWindowAura::Get(root_window_) |
| - ->GetRootWindowController() |
| - ->AddObserver(root_window_controller_observer_.get()); |
| + |
| + wm::WmRootWindowController* controller = |
| + wm::WmWindowAura::Get(root_window_)->GetRootWindowController(); |
| + if (controller) { |
| + root_window_controller_observer_.reset( |
| + new RootWindowControllerObserverImpl(this)); |
| + controller->AddObserver(root_window_controller_observer_.get()); |
| + } else { |
| + DCHECK(Shell::GetInstance()->in_mus()); |
|
sky
2016/04/28 15:23:12
What about wrapping this whole thing in !Shell::Ge
sadrul
2016/04/28 15:28:51
Done.
|
| + } |
| Shell::GetInstance()->lock_state_controller()->AddObserver(this); |
| aura::client::GetActivationClient(root_window_)->AddObserver(this); |
| Shell::GetInstance()->session_state_delegate()->AddSessionStateObserver(this); |
| @@ -250,9 +255,11 @@ 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()); |
| + if (root_window_controller_observer_) { |
| + wm::WmWindowAura::Get(root_window_) |
| + ->GetRootWindowController() |
| + ->RemoveObserver(root_window_controller_observer_.get()); |
| + } |
| } |
| void ShelfLayoutManager::PrepareForShutdown() { |