Index: ash/aura/wm_shelf_aura.cc |
diff --git a/ash/aura/wm_shelf_aura.cc b/ash/aura/wm_shelf_aura.cc |
index 2a4ddf5a21aa14a2ff43e7b9061847c6ba68a9c0..c5db74ba9cf1d9db4b52a408c330f0d7d9285ad6 100644 |
--- a/ash/aura/wm_shelf_aura.cc |
+++ b/ash/aura/wm_shelf_aura.cc |
@@ -13,16 +13,30 @@ |
namespace ash { |
-WmShelfAura::WmShelfAura(Shelf* shelf) |
- : shelf_(shelf), shelf_layout_manager_(shelf->shelf_layout_manager()) { |
+WmShelfAura::WmShelfAura() {} |
+ |
+WmShelfAura::~WmShelfAura() {} |
+ |
+void WmShelfAura::SetShelfLayoutManager( |
+ ShelfLayoutManager* shelf_layout_manager) { |
+ DCHECK(!shelf_layout_manager_); |
+ shelf_layout_manager_ = shelf_layout_manager; |
shelf_layout_manager_->AddObserver(this); |
+} |
+ |
+void WmShelfAura::SetShelf(Shelf* shelf) { |
+ DCHECK(!shelf_); |
+ shelf_ = shelf; |
shelf_->AddIconObserver(this); |
} |
-WmShelfAura::~WmShelfAura() { |
- shelf_->RemoveIconObserver(this); |
- if (shelf_layout_manager_) |
- shelf_layout_manager_->RemoveObserver(this); |
+void WmShelfAura::Shutdown() { |
+ if (shelf_) { |
+ shelf_->RemoveIconObserver(this); |
+ shelf_ = nullptr; |
+ } |
+ |
+ ResetShelfLayoutManager(); |
} |
// static |
@@ -30,6 +44,13 @@ Shelf* WmShelfAura::GetShelf(WmShelf* shelf) { |
return static_cast<WmShelfAura*>(shelf)->shelf_; |
} |
+void WmShelfAura::ResetShelfLayoutManager() { |
+ if (!shelf_layout_manager_) |
+ return; |
+ shelf_layout_manager_->RemoveObserver(this); |
+ shelf_layout_manager_ = nullptr; |
+} |
+ |
WmWindow* WmShelfAura::GetWindow() { |
return WmWindowAura::Get(shelf_->shelf_widget()->GetNativeView()); |
} |
@@ -69,8 +90,7 @@ void WmShelfAura::RemoveObserver(WmShelfObserver* observer) { |
} |
void WmShelfAura::WillDeleteShelfLayoutManager() { |
- shelf_layout_manager_->RemoveObserver(this); |
- shelf_layout_manager_ = nullptr; |
+ ResetShelfLayoutManager(); |
} |
void WmShelfAura::OnBackgroundUpdated( |