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

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

Issue 1929023002: Refactors WindowResizers to use ash/wm/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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/wm/aura/wm_shelf_aura.h" 5 #include "ash/wm/aura/wm_shelf_aura.h"
6 6
7 #include "ash/shelf/shelf.h" 7 #include "ash/shelf/shelf.h"
8 #include "ash/shelf/shelf_layout_manager.h" 8 #include "ash/shelf/shelf_layout_manager.h"
9 #include "ash/wm/aura/wm_window_aura.h"
9 #include "ash/wm/common/shelf/wm_shelf_observer.h" 10 #include "ash/wm/common/shelf/wm_shelf_observer.h"
10 #include "ash/wm/common/wm_window.h" 11 #include "ash/wm/common/wm_window.h"
11 #include "ui/views/widget/widget.h" 12 #include "ui/views/widget/widget.h"
12 13
13 namespace ash { 14 namespace ash {
14 namespace wm { 15 namespace wm {
15 16
16 WmShelfAura::WmShelfAura(Shelf* shelf) 17 WmShelfAura::WmShelfAura(Shelf* shelf)
17 : shelf_(shelf), shelf_layout_manager_(shelf->shelf_layout_manager()) { 18 : shelf_(shelf), shelf_layout_manager_(shelf->shelf_layout_manager()) {
18 shelf_layout_manager_->AddObserver(this); 19 shelf_layout_manager_->AddObserver(this);
20 shelf_->AddIconObserver(this);
19 } 21 }
20 22
21 WmShelfAura::~WmShelfAura() { 23 WmShelfAura::~WmShelfAura() {
24 shelf_->RemoveIconObserver(this);
22 if (shelf_layout_manager_) 25 if (shelf_layout_manager_)
23 shelf_layout_manager_->RemoveObserver(this); 26 shelf_layout_manager_->RemoveObserver(this);
24 } 27 }
25 28
29 // static
30 Shelf* WmShelfAura::GetShelf(WmShelf* shelf) {
31 return static_cast<WmShelfAura*>(shelf)->shelf_;
32 }
33
26 WmWindow* WmShelfAura::GetWindow() { 34 WmWindow* WmShelfAura::GetWindow() {
27 return WmWindow::Get(shelf_->shelf_widget()); 35 return WmWindow::Get(shelf_->shelf_widget());
28 } 36 }
29 37
30 ShelfAlignment WmShelfAura::GetAlignment() { 38 ShelfAlignment WmShelfAura::GetAlignment() const {
31 return shelf_->alignment(); 39 return shelf_->alignment();
32 } 40 }
33 41
34 ShelfBackgroundType WmShelfAura::GetBackgroundType() { 42 ShelfBackgroundType WmShelfAura::GetBackgroundType() const {
35 return shelf_->shelf_widget()->GetBackgroundType(); 43 return shelf_->shelf_widget()->GetBackgroundType();
36 } 44 }
37 45
38 void WmShelfAura::UpdateVisibilityState() { 46 void WmShelfAura::UpdateVisibilityState() {
39 shelf_->shelf_layout_manager()->UpdateVisibilityState(); 47 shelf_->shelf_layout_manager()->UpdateVisibilityState();
40 } 48 }
41 49
50 ShelfVisibilityState WmShelfAura::GetVisibilityState() const {
51 return shelf_layout_manager_ ? shelf_layout_manager_->visibility_state()
52 : SHELF_HIDDEN;
53 }
54
55 void WmShelfAura::UpdateIconPositionForWindow(WmWindow* window) {
56 shelf_->UpdateIconPositionForWindow(WmWindowAura::GetAuraWindow(window));
57 }
58
59 gfx::Rect WmShelfAura::GetScreenBoundsOfItemIconForWindow(
60 wm::WmWindow* window) {
61 return shelf_->GetScreenBoundsOfItemIconForWindow(
62 WmWindowAura::GetAuraWindow(window));
63 }
64
42 void WmShelfAura::AddObserver(WmShelfObserver* observer) { 65 void WmShelfAura::AddObserver(WmShelfObserver* observer) {
43 observers_.AddObserver(observer); 66 observers_.AddObserver(observer);
44 } 67 }
45 68
46 void WmShelfAura::RemoveObserver(WmShelfObserver* observer) { 69 void WmShelfAura::RemoveObserver(WmShelfObserver* observer) {
47 observers_.RemoveObserver(observer); 70 observers_.RemoveObserver(observer);
48 } 71 }
49 72
50 void WmShelfAura::WillDeleteShelf() { 73 void WmShelfAura::WillDeleteShelf() {
51 shelf_layout_manager_->RemoveObserver(this); 74 shelf_layout_manager_->RemoveObserver(this);
52 shelf_layout_manager_ = nullptr; 75 shelf_layout_manager_ = nullptr;
53 } 76 }
54 77
55 void WmShelfAura::OnBackgroundUpdated( 78 void WmShelfAura::OnBackgroundUpdated(
56 wm::ShelfBackgroundType background_type, 79 wm::ShelfBackgroundType background_type,
57 BackgroundAnimatorChangeType change_type) { 80 BackgroundAnimatorChangeType change_type) {
58 FOR_EACH_OBSERVER(WmShelfObserver, observers_, 81 FOR_EACH_OBSERVER(WmShelfObserver, observers_,
59 OnBackgroundUpdated(background_type, change_type)); 82 OnBackgroundUpdated(background_type, change_type));
60 } 83 }
61 84
85 void WmShelfAura::WillChangeVisibilityState(ShelfVisibilityState new_state) {
86 FOR_EACH_OBSERVER(WmShelfObserver, observers_,
87 WillChangeVisibilityState(new_state));
88 }
89
90 void WmShelfAura::OnShelfIconPositionsChanged() {
91 FOR_EACH_OBSERVER(WmShelfObserver, observers_, OnShelfIconPositionsChanged());
92 }
93
62 } // namespace wm 94 } // namespace wm
63 } // namespace ash 95 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698