Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: ash/aura/wm_shelf_aura.cc

Issue 2041583004: mash: Move WmShelfAura ownership to RootWindowController and init it earlier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@moveshelftypes
Patch Set: . Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/aura/wm_shelf_aura.h ('k') | ash/common/wm/workspace/workspace_layout_manager_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/aura/wm_shelf_aura.h" 5 #include "ash/aura/wm_shelf_aura.h"
6 6
7 #include "ash/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/shelf/wm_shelf_observer.h" 8 #include "ash/common/shelf/wm_shelf_observer.h"
9 #include "ash/common/wm_window.h" 9 #include "ash/common/wm_window.h"
10 #include "ash/shelf/shelf.h" 10 #include "ash/shelf/shelf.h"
11 #include "ash/shelf/shelf_layout_manager.h" 11 #include "ash/shelf/shelf_layout_manager.h"
12 #include "ui/views/widget/widget.h" 12 #include "ui/views/widget/widget.h"
13 13
14 namespace ash { 14 namespace ash {
15 15
16 WmShelfAura::WmShelfAura(Shelf* shelf) 16 WmShelfAura::WmShelfAura() {}
17 : shelf_(shelf), shelf_layout_manager_(shelf->shelf_layout_manager()) { 17
18 WmShelfAura::~WmShelfAura() {}
19
20 void WmShelfAura::SetShelfLayoutManager(
21 ShelfLayoutManager* shelf_layout_manager) {
22 DCHECK(!shelf_layout_manager_);
23 shelf_layout_manager_ = shelf_layout_manager;
18 shelf_layout_manager_->AddObserver(this); 24 shelf_layout_manager_->AddObserver(this);
25 }
26
27 void WmShelfAura::SetShelf(Shelf* shelf) {
28 DCHECK(!shelf_);
29 shelf_ = shelf;
19 shelf_->AddIconObserver(this); 30 shelf_->AddIconObserver(this);
20 } 31 }
21 32
22 WmShelfAura::~WmShelfAura() { 33 void WmShelfAura::Shutdown() {
23 shelf_->RemoveIconObserver(this); 34 if (shelf_) {
24 if (shelf_layout_manager_) 35 shelf_->RemoveIconObserver(this);
25 shelf_layout_manager_->RemoveObserver(this); 36 shelf_ = nullptr;
37 }
38
39 ResetShelfLayoutManager();
26 } 40 }
27 41
28 // static 42 // static
29 Shelf* WmShelfAura::GetShelf(WmShelf* shelf) { 43 Shelf* WmShelfAura::GetShelf(WmShelf* shelf) {
30 return static_cast<WmShelfAura*>(shelf)->shelf_; 44 return static_cast<WmShelfAura*>(shelf)->shelf_;
31 } 45 }
32 46
47 void WmShelfAura::ResetShelfLayoutManager() {
48 if (!shelf_layout_manager_)
49 return;
50 shelf_layout_manager_->RemoveObserver(this);
51 shelf_layout_manager_ = nullptr;
52 }
53
33 WmWindow* WmShelfAura::GetWindow() { 54 WmWindow* WmShelfAura::GetWindow() {
34 return WmWindowAura::Get(shelf_->shelf_widget()->GetNativeView()); 55 return WmWindowAura::Get(shelf_->shelf_widget()->GetNativeView());
35 } 56 }
36 57
37 ShelfAlignment WmShelfAura::GetAlignment() const { 58 ShelfAlignment WmShelfAura::GetAlignment() const {
38 return shelf_->alignment(); 59 return shelf_->alignment();
39 } 60 }
40 61
41 ShelfBackgroundType WmShelfAura::GetBackgroundType() const { 62 ShelfBackgroundType WmShelfAura::GetBackgroundType() const {
42 return shelf_->shelf_widget()->GetBackgroundType(); 63 return shelf_->shelf_widget()->GetBackgroundType();
(...skipping 19 matching lines...) Expand all
62 83
63 void WmShelfAura::AddObserver(WmShelfObserver* observer) { 84 void WmShelfAura::AddObserver(WmShelfObserver* observer) {
64 observers_.AddObserver(observer); 85 observers_.AddObserver(observer);
65 } 86 }
66 87
67 void WmShelfAura::RemoveObserver(WmShelfObserver* observer) { 88 void WmShelfAura::RemoveObserver(WmShelfObserver* observer) {
68 observers_.RemoveObserver(observer); 89 observers_.RemoveObserver(observer);
69 } 90 }
70 91
71 void WmShelfAura::WillDeleteShelfLayoutManager() { 92 void WmShelfAura::WillDeleteShelfLayoutManager() {
72 shelf_layout_manager_->RemoveObserver(this); 93 ResetShelfLayoutManager();
73 shelf_layout_manager_ = nullptr;
74 } 94 }
75 95
76 void WmShelfAura::OnBackgroundUpdated( 96 void WmShelfAura::OnBackgroundUpdated(
77 ShelfBackgroundType background_type, 97 ShelfBackgroundType background_type,
78 BackgroundAnimatorChangeType change_type) { 98 BackgroundAnimatorChangeType change_type) {
79 FOR_EACH_OBSERVER(WmShelfObserver, observers_, 99 FOR_EACH_OBSERVER(WmShelfObserver, observers_,
80 OnBackgroundUpdated(background_type, change_type)); 100 OnBackgroundUpdated(background_type, change_type));
81 } 101 }
82 102
83 void WmShelfAura::WillChangeVisibilityState(ShelfVisibilityState new_state) { 103 void WmShelfAura::WillChangeVisibilityState(ShelfVisibilityState new_state) {
84 FOR_EACH_OBSERVER(WmShelfObserver, observers_, 104 FOR_EACH_OBSERVER(WmShelfObserver, observers_,
85 WillChangeVisibilityState(new_state)); 105 WillChangeVisibilityState(new_state));
86 } 106 }
87 107
88 void WmShelfAura::OnShelfIconPositionsChanged() { 108 void WmShelfAura::OnShelfIconPositionsChanged() {
89 FOR_EACH_OBSERVER(WmShelfObserver, observers_, OnShelfIconPositionsChanged()); 109 FOR_EACH_OBSERVER(WmShelfObserver, observers_, OnShelfIconPositionsChanged());
90 } 110 }
91 111
92 } // namespace ash 112 } // namespace ash
OLDNEW
« no previous file with comments | « ash/aura/wm_shelf_aura.h ('k') | ash/common/wm/workspace/workspace_layout_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698