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

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

Issue 2177663002: mash: Move ownership of ShelfDelegate to WmShell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix wallpaper tests again Created 4 years, 5 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/shelf/shelf.h ('k') | ash/shelf/shelf_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/shelf/shelf.h" 5 #include "ash/shelf/shelf.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "ash/aura/wm_window_aura.h" 10 #include "ash/aura/wm_window_aura.h"
11 #include "ash/common/shelf/shelf_delegate.h"
11 #include "ash/common/shelf/shelf_item_delegate.h" 12 #include "ash/common/shelf/shelf_item_delegate.h"
12 #include "ash/common/shelf/shelf_model.h" 13 #include "ash/common/shelf/shelf_model.h"
13 #include "ash/common/shelf/shelf_navigator.h" 14 #include "ash/common/shelf/shelf_navigator.h"
14 #include "ash/common/shelf/wm_shelf_util.h" 15 #include "ash/common/shelf/wm_shelf_util.h"
15 #include "ash/common/shell_window_ids.h" 16 #include "ash/common/shell_window_ids.h"
17 #include "ash/common/wm_shell.h"
16 #include "ash/root_window_controller.h" 18 #include "ash/root_window_controller.h"
17 #include "ash/screen_util.h" 19 #include "ash/screen_util.h"
18 #include "ash/shelf/shelf_delegate.h"
19 #include "ash/shelf/shelf_layout_manager.h" 20 #include "ash/shelf/shelf_layout_manager.h"
20 #include "ash/shelf/shelf_util.h" 21 #include "ash/shelf/shelf_util.h"
21 #include "ash/shelf/shelf_view.h" 22 #include "ash/shelf/shelf_view.h"
22 #include "ash/shell.h" 23 #include "ash/shell.h"
23 #include "ash/wm/window_properties.h" 24 #include "ash/wm/window_properties.h"
24 #include "ui/aura/window.h" 25 #include "ui/aura/window.h"
25 #include "ui/aura/window_event_dispatcher.h" 26 #include "ui/aura/window_event_dispatcher.h"
26 #include "ui/aura/window_observer.h" 27 #include "ui/aura/window_observer.h"
27 #include "ui/compositor/layer.h" 28 #include "ui/compositor/layer.h"
28 #include "ui/gfx/canvas.h" 29 #include "ui/gfx/canvas.h"
29 #include "ui/gfx/image/image.h" 30 #include "ui/gfx/image/image.h"
30 #include "ui/gfx/image/image_skia_operations.h" 31 #include "ui/gfx/image/image_skia_operations.h"
31 #include "ui/gfx/skbitmap_operations.h" 32 #include "ui/gfx/skbitmap_operations.h"
32 #include "ui/views/accessible_pane_view.h" 33 #include "ui/views/accessible_pane_view.h"
33 #include "ui/views/widget/widget.h" 34 #include "ui/views/widget/widget.h"
34 #include "ui/views/widget/widget_delegate.h" 35 #include "ui/views/widget/widget_delegate.h"
35 #include "ui/wm/public/activation_client.h" 36 #include "ui/wm/public/activation_client.h"
36 37
37 namespace ash { 38 namespace ash {
38 39
39 const char Shelf::kNativeViewName[] = "ShelfView"; 40 const char Shelf::kNativeViewName[] = "ShelfView";
40 41
41 Shelf::Shelf(ShelfModel* shelf_model, 42 Shelf::Shelf(ShelfModel* shelf_model,
42 ShelfDelegate* shelf_delegate,
43 WmShelf* wm_shelf, 43 WmShelf* wm_shelf,
44 ShelfWidget* shelf_widget) 44 ShelfWidget* shelf_widget)
45 : delegate_(shelf_delegate), 45 : wm_shelf_(wm_shelf),
46 wm_shelf_(wm_shelf),
47 shelf_widget_(shelf_widget), 46 shelf_widget_(shelf_widget),
48 shelf_view_(new ShelfView(shelf_model, delegate_, wm_shelf, this)), 47 shelf_view_(new ShelfView(shelf_model,
48 WmShell::Get()->shelf_delegate(),
49 wm_shelf,
50 this)),
49 shelf_locking_manager_(wm_shelf) { 51 shelf_locking_manager_(wm_shelf) {
50 DCHECK(wm_shelf_); 52 DCHECK(wm_shelf_);
51 shelf_view_->Init(); 53 shelf_view_->Init();
52 shelf_widget_->GetContentsView()->AddChildView(shelf_view_); 54 shelf_widget_->GetContentsView()->AddChildView(shelf_view_);
53 shelf_widget_->GetNativeView()->SetName(kNativeViewName); 55 shelf_widget_->GetNativeView()->SetName(kNativeViewName);
54 } 56 }
55 57
56 Shelf::~Shelf() { 58 Shelf::~Shelf() {
57 delegate_->OnShelfDestroyed(this); 59 WmShell::Get()->shelf_delegate()->OnShelfDestroyed(this);
58 } 60 }
59 61
60 // static 62 // static
61 Shelf* Shelf::ForPrimaryDisplay() { 63 Shelf* Shelf::ForPrimaryDisplay() {
62 return Shelf::ForWindow(Shell::GetPrimaryRootWindow()); 64 return Shelf::ForWindow(Shell::GetPrimaryRootWindow());
63 } 65 }
64 66
65 // static 67 // static
66 Shelf* Shelf::ForWindow(const aura::Window* window) { 68 Shelf* Shelf::ForWindow(const aura::Window* window) {
67 ShelfWidget* shelf_widget = 69 ShelfWidget* shelf_widget =
68 RootWindowController::ForWindow(window)->shelf_widget(); 70 RootWindowController::ForWindow(window)->shelf_widget();
69 return shelf_widget ? shelf_widget->shelf() : nullptr; 71 return shelf_widget ? shelf_widget->shelf() : nullptr;
70 } 72 }
71 73
72 void Shelf::SetAlignment(ShelfAlignment alignment) { 74 void Shelf::SetAlignment(ShelfAlignment alignment) {
73 if (alignment_ == alignment) 75 if (alignment_ == alignment)
74 return; 76 return;
75 77
76 if (shelf_locking_manager_.is_locked() && 78 if (shelf_locking_manager_.is_locked() &&
77 alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) { 79 alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) {
78 shelf_locking_manager_.set_stored_alignment(alignment); 80 shelf_locking_manager_.set_stored_alignment(alignment);
79 return; 81 return;
80 } 82 }
81 83
82 alignment_ = alignment; 84 alignment_ = alignment;
83 shelf_view_->OnShelfAlignmentChanged(); 85 shelf_view_->OnShelfAlignmentChanged();
84 shelf_widget_->OnShelfAlignmentChanged(); 86 shelf_widget_->OnShelfAlignmentChanged();
85 delegate_->OnShelfAlignmentChanged(this); 87 WmShell::Get()->shelf_delegate()->OnShelfAlignmentChanged(this);
86 Shell::GetInstance()->OnShelfAlignmentChanged( 88 Shell::GetInstance()->OnShelfAlignmentChanged(
87 WmWindowAura::Get(shelf_widget_->GetNativeWindow()->GetRootWindow())); 89 WmWindowAura::Get(shelf_widget_->GetNativeWindow()->GetRootWindow()));
88 // ShelfLayoutManager will resize the shelf. 90 // ShelfLayoutManager will resize the shelf.
89 } 91 }
90 92
91 bool Shelf::IsHorizontalAlignment() const { 93 bool Shelf::IsHorizontalAlignment() const {
92 return ::ash::IsHorizontalAlignment(alignment_); 94 return ::ash::IsHorizontalAlignment(alignment_);
93 } 95 }
94 96
95 void Shelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) { 97 void Shelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) {
96 if (auto_hide_behavior_ == auto_hide_behavior) 98 if (auto_hide_behavior_ == auto_hide_behavior)
97 return; 99 return;
98 100
99 auto_hide_behavior_ = auto_hide_behavior; 101 auto_hide_behavior_ = auto_hide_behavior;
100 delegate_->OnShelfAutoHideBehaviorChanged(this); 102 WmShell::Get()->shelf_delegate()->OnShelfAutoHideBehaviorChanged(this);
101 Shell::GetInstance()->OnShelfAutoHideBehaviorChanged( 103 Shell::GetInstance()->OnShelfAutoHideBehaviorChanged(
102 WmWindowAura::Get(shelf_widget_->GetNativeWindow()->GetRootWindow())); 104 WmWindowAura::Get(shelf_widget_->GetNativeWindow()->GetRootWindow()));
103 } 105 }
104 106
105 ShelfAutoHideState Shelf::GetAutoHideState() const { 107 ShelfAutoHideState Shelf::GetAutoHideState() const {
106 return shelf_widget_->shelf_layout_manager()->auto_hide_state(); 108 return shelf_widget_->shelf_layout_manager()->auto_hide_state();
107 } 109 }
108 110
109 ShelfVisibilityState Shelf::GetVisibilityState() const { 111 ShelfVisibilityState Shelf::GetVisibilityState() const {
110 return shelf_widget_->shelf_layout_manager()->visibility_state(); 112 return shelf_widget_->shelf_layout_manager()->visibility_state();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 210
209 gfx::Rect Shelf::GetVisibleItemsBoundsInScreen() const { 211 gfx::Rect Shelf::GetVisibleItemsBoundsInScreen() const {
210 return shelf_view_->GetVisibleItemsBoundsInScreen(); 212 return shelf_view_->GetVisibleItemsBoundsInScreen();
211 } 213 }
212 214
213 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { 215 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() {
214 return shelf_view_; 216 return shelf_view_;
215 } 217 }
216 218
217 } // namespace ash 219 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf.h ('k') | ash/shelf/shelf_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698