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

Side by Side Diff: ash/common/shelf/wm_shelf.cc

Issue 2293183002: ash: Remove ash::Shelf in favor of ash::WmShelf (Closed)
Patch Set: rebase again Created 4 years, 3 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/common/shelf/wm_shelf.h ('k') | ash/common/system/toast/toast_overlay.cc » ('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/common/shelf/shelf.h"
6 #include "ash/common/shelf/shelf_delegate.h" 5 #include "ash/common/shelf/shelf_delegate.h"
7 #include "ash/common/shelf/shelf_item_delegate.h" 6 #include "ash/common/shelf/shelf_item_delegate.h"
8 #include "ash/common/shelf/shelf_layout_manager.h" 7 #include "ash/common/shelf/shelf_layout_manager.h"
9 #include "ash/common/shelf/shelf_locking_manager.h" 8 #include "ash/common/shelf/shelf_locking_manager.h"
10 #include "ash/common/shelf/shelf_model.h" 9 #include "ash/common/shelf/shelf_model.h"
11 #include "ash/common/shelf/shelf_widget.h" 10 #include "ash/common/shelf/shelf_widget.h"
12 #include "ash/common/shelf/wm_shelf.h" 11 #include "ash/common/shelf/wm_shelf.h"
13 #include "ash/common/shelf/wm_shelf_observer.h" 12 #include "ash/common/shelf/wm_shelf_observer.h"
14 #include "ash/common/wm_lookup.h" 13 #include "ash/common/wm_lookup.h"
15 #include "ash/common/wm_root_window_controller.h" 14 #include "ash/common/wm_root_window_controller.h"
16 #include "ash/common/wm_shell.h" 15 #include "ash/common/wm_shell.h"
17 #include "ash/common/wm_window.h" 16 #include "ash/common/wm_window.h"
18 #include "base/logging.h" 17 #include "base/logging.h"
19 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
20 19
21 namespace ash { 20 namespace ash {
22 21
23 // static 22 // static
24 WmShelf* WmShelf::ForWindow(WmWindow* window) { 23 WmShelf* WmShelf::ForWindow(WmWindow* window) {
25 return window->GetRootWindowController()->GetShelf(); 24 return window->GetRootWindowController()->GetShelf();
26 } 25 }
27 26
28 void WmShelf::SetShelf(Shelf* shelf) {
29 DCHECK(!shelf_);
30 DCHECK(shelf);
31 shelf_ = shelf;
32 DCHECK(shelf_layout_manager_);
33 shelf_locking_manager_.reset(new ShelfLockingManager(this));
34 // When the shelf is created the alignment is unlocked. Chrome will update the
35 // alignment later from preferences.
36 alignment_ = SHELF_ALIGNMENT_BOTTOM;
37 }
38
39 void WmShelf::ClearShelf() {
40 DCHECK(shelf_);
41 shelf_locking_manager_.reset();
42 shelf_ = nullptr;
43 }
44
45 void WmShelf::SetShelfLayoutManager(ShelfLayoutManager* manager) { 27 void WmShelf::SetShelfLayoutManager(ShelfLayoutManager* manager) {
46 DCHECK(!shelf_layout_manager_); 28 DCHECK(!shelf_layout_manager_);
47 DCHECK(manager); 29 DCHECK(manager);
48 shelf_layout_manager_ = manager; 30 shelf_layout_manager_ = manager;
49 shelf_layout_manager_->AddObserver(this); 31 shelf_layout_manager_->AddObserver(this);
50 DCHECK(manager->shelf_widget()); 32 DCHECK(manager->shelf_widget());
51 shelf_widget_ = manager->shelf_widget(); 33 shelf_widget_ = manager->shelf_widget();
52 } 34 }
53 35
36 void WmShelf::InitializeShelf() {
37 DCHECK(shelf_layout_manager_);
38 DCHECK(shelf_widget_);
39 DCHECK(!shelf_view_);
40 shelf_view_ = shelf_widget_->CreateShelfView();
41 shelf_locking_manager_.reset(new ShelfLockingManager(this));
42 // When the shelf is created the alignment is unlocked. Chrome will update the
43 // alignment later from preferences.
44 alignment_ = SHELF_ALIGNMENT_BOTTOM;
45 // NOTE: The delegate may access WmShelf.
46 WmShell::Get()->shelf_delegate()->OnShelfCreated(this);
47 }
48
49 void WmShelf::ShutdownShelf() {
50 DCHECK(shelf_view_);
51 shelf_locking_manager_.reset();
52 shelf_view_ = nullptr;
53 WmShell::Get()->shelf_delegate()->OnShelfDestroyed(this);
54 }
55
56 bool WmShelf::IsShelfInitialized() const {
57 return !!shelf_view_;
58 }
59
54 WmWindow* WmShelf::GetWindow() { 60 WmWindow* WmShelf::GetWindow() {
55 // Use |shelf_layout_manager_| to access ShelfWidget because it is set before 61 // Use |shelf_layout_manager_| to access ShelfWidget because it is set before
56 // before the Shelf instance is available. 62 // before the Shelf instance is available.
57 return WmLookup::Get()->GetWindowForWidget( 63 return WmLookup::Get()->GetWindowForWidget(
58 shelf_layout_manager_->shelf_widget()); 64 shelf_layout_manager_->shelf_widget());
59 } 65 }
60 66
61 void WmShelf::SetAlignment(ShelfAlignment alignment) { 67 void WmShelf::SetAlignment(ShelfAlignment alignment) {
62 DCHECK(shelf_layout_manager_); 68 DCHECK(shelf_layout_manager_);
69 DCHECK(shelf_locking_manager_);
63 70
64 if (alignment_ == alignment) 71 if (alignment_ == alignment)
65 return; 72 return;
66 73
67 if (shelf_locking_manager_->is_locked() && 74 if (shelf_locking_manager_->is_locked() &&
68 alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) { 75 alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) {
69 shelf_locking_manager_->set_stored_alignment(alignment); 76 shelf_locking_manager_->set_stored_alignment(alignment);
70 return; 77 return;
71 } 78 }
72 79
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 144
138 WmDimmerView* WmShelf::CreateDimmerView(bool disable_animations_for_test) { 145 WmDimmerView* WmShelf::CreateDimmerView(bool disable_animations_for_test) {
139 return nullptr; 146 return nullptr;
140 } 147 }
141 148
142 bool WmShelf::IsDimmed() const { 149 bool WmShelf::IsDimmed() const {
143 return shelf_layout_manager_->shelf_widget()->GetDimsShelf(); 150 return shelf_layout_manager_->shelf_widget()->GetDimsShelf();
144 } 151 }
145 152
146 bool WmShelf::IsVisible() const { 153 bool WmShelf::IsVisible() const {
147 return shelf_->shelf_widget()->IsShelfVisible(); 154 return shelf_widget_->IsShelfVisible();
148 } 155 }
149 156
150 void WmShelf::UpdateVisibilityState() { 157 void WmShelf::UpdateVisibilityState() {
151 if (shelf_layout_manager_) 158 if (shelf_layout_manager_)
152 shelf_layout_manager_->UpdateVisibilityState(); 159 shelf_layout_manager_->UpdateVisibilityState();
153 } 160 }
154 161
155 ShelfVisibilityState WmShelf::GetVisibilityState() const { 162 ShelfVisibilityState WmShelf::GetVisibilityState() const {
156 return shelf_layout_manager_ ? shelf_layout_manager_->visibility_state() 163 return shelf_layout_manager_ ? shelf_layout_manager_->visibility_state()
157 : SHELF_HIDDEN; 164 : SHELF_HIDDEN;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 249
243 void WmShelf::SetVirtualKeyboardBoundsForTesting(const gfx::Rect& bounds) { 250 void WmShelf::SetVirtualKeyboardBoundsForTesting(const gfx::Rect& bounds) {
244 shelf_layout_manager_->OnKeyboardBoundsChanging(bounds); 251 shelf_layout_manager_->OnKeyboardBoundsChanging(bounds);
245 } 252 }
246 253
247 ShelfLockingManager* WmShelf::GetShelfLockingManagerForTesting() { 254 ShelfLockingManager* WmShelf::GetShelfLockingManagerForTesting() {
248 return shelf_locking_manager_.get(); 255 return shelf_locking_manager_.get();
249 } 256 }
250 257
251 ShelfView* WmShelf::GetShelfViewForTesting() { 258 ShelfView* WmShelf::GetShelfViewForTesting() {
252 return shelf_->shelf_view_for_testing(); 259 return shelf_view_;
253 } 260 }
254 261
255 WmShelf::WmShelf() {} 262 WmShelf::WmShelf() {}
256 263
257 WmShelf::~WmShelf() {} 264 WmShelf::~WmShelf() {}
258 265
259 void WmShelf::WillDeleteShelfLayoutManager() { 266 void WmShelf::WillDeleteShelfLayoutManager() {
260 DCHECK(shelf_layout_manager_); 267 DCHECK(shelf_layout_manager_);
261 shelf_layout_manager_->RemoveObserver(this); 268 shelf_layout_manager_->RemoveObserver(this);
262 shelf_layout_manager_ = nullptr; 269 shelf_layout_manager_ = nullptr;
(...skipping 11 matching lines...) Expand all
274 281
275 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, 282 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type,
276 BackgroundAnimatorChangeType change_type) { 283 BackgroundAnimatorChangeType change_type) {
277 if (background_type == GetBackgroundType()) 284 if (background_type == GetBackgroundType())
278 return; 285 return;
279 FOR_EACH_OBSERVER(WmShelfObserver, observers_, 286 FOR_EACH_OBSERVER(WmShelfObserver, observers_,
280 OnBackgroundTypeChanged(background_type, change_type)); 287 OnBackgroundTypeChanged(background_type, change_type));
281 } 288 }
282 289
283 } // namespace ash 290 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/wm_shelf.h ('k') | ash/common/system/toast/toast_overlay.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698