| Index: ash/common/shelf/wm_shelf.cc
|
| diff --git a/ash/common/shelf/wm_shelf.cc b/ash/common/shelf/wm_shelf.cc
|
| index d56d4cb312b9de209b3711624117a1fdd6f1d4a3..f7c6e7a04ebdec344bddca2565913dda3068f941 100644
|
| --- a/ash/common/shelf/wm_shelf.cc
|
| +++ b/ash/common/shelf/wm_shelf.cc
|
| @@ -2,7 +2,6 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "ash/common/shelf/shelf.h"
|
| #include "ash/common/shelf/shelf_delegate.h"
|
| #include "ash/common/shelf/shelf_item_delegate.h"
|
| #include "ash/common/shelf/shelf_layout_manager.h"
|
| @@ -25,30 +24,37 @@ WmShelf* WmShelf::ForWindow(WmWindow* window) {
|
| return window->GetRootWindowController()->GetShelf();
|
| }
|
|
|
| -void WmShelf::SetShelf(Shelf* shelf) {
|
| - DCHECK(!shelf_);
|
| - DCHECK(shelf);
|
| - shelf_ = shelf;
|
| +void WmShelf::SetShelfLayoutManager(ShelfLayoutManager* manager) {
|
| + DCHECK(!shelf_layout_manager_);
|
| + DCHECK(manager);
|
| + shelf_layout_manager_ = manager;
|
| + shelf_layout_manager_->AddObserver(this);
|
| + DCHECK(manager->shelf_widget());
|
| + shelf_widget_ = manager->shelf_widget();
|
| +}
|
| +
|
| +void WmShelf::InitializeShelf() {
|
| DCHECK(shelf_layout_manager_);
|
| + DCHECK(shelf_widget_);
|
| + DCHECK(!shelf_view_);
|
| + shelf_view_ = shelf_widget_->CreateShelfView();
|
| shelf_locking_manager_.reset(new ShelfLockingManager(this));
|
| // When the shelf is created the alignment is unlocked. Chrome will update the
|
| // alignment later from preferences.
|
| alignment_ = SHELF_ALIGNMENT_BOTTOM;
|
| + // NOTE: The delegate may access WmShelf.
|
| + WmShell::Get()->shelf_delegate()->OnShelfCreated(this);
|
| }
|
|
|
| -void WmShelf::ClearShelf() {
|
| - DCHECK(shelf_);
|
| +void WmShelf::ShutdownShelf() {
|
| + DCHECK(shelf_view_);
|
| shelf_locking_manager_.reset();
|
| - shelf_ = nullptr;
|
| + shelf_view_ = nullptr;
|
| + WmShell::Get()->shelf_delegate()->OnShelfDestroyed(this);
|
| }
|
|
|
| -void WmShelf::SetShelfLayoutManager(ShelfLayoutManager* manager) {
|
| - DCHECK(!shelf_layout_manager_);
|
| - DCHECK(manager);
|
| - shelf_layout_manager_ = manager;
|
| - shelf_layout_manager_->AddObserver(this);
|
| - DCHECK(manager->shelf_widget());
|
| - shelf_widget_ = manager->shelf_widget();
|
| +bool WmShelf::IsShelfInitialized() const {
|
| + return !!shelf_view_;
|
| }
|
|
|
| WmWindow* WmShelf::GetWindow() {
|
| @@ -60,6 +66,7 @@ WmWindow* WmShelf::GetWindow() {
|
|
|
| void WmShelf::SetAlignment(ShelfAlignment alignment) {
|
| DCHECK(shelf_layout_manager_);
|
| + DCHECK(shelf_locking_manager_);
|
|
|
| if (alignment_ == alignment)
|
| return;
|
| @@ -144,7 +151,7 @@ bool WmShelf::IsDimmed() const {
|
| }
|
|
|
| bool WmShelf::IsVisible() const {
|
| - return shelf_->shelf_widget()->IsShelfVisible();
|
| + return shelf_widget_->IsShelfVisible();
|
| }
|
|
|
| void WmShelf::UpdateVisibilityState() {
|
| @@ -249,7 +256,7 @@ ShelfLockingManager* WmShelf::GetShelfLockingManagerForTesting() {
|
| }
|
|
|
| ShelfView* WmShelf::GetShelfViewForTesting() {
|
| - return shelf_->shelf_view_for_testing();
|
| + return shelf_view_;
|
| }
|
|
|
| WmShelf::WmShelf() {}
|
|
|