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

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

Issue 1743493002: Cleanup ash shelf accessor functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ShelfBrowserTest. Created 4 years, 9 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 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/focus_cycler.h" 10 #include "ash/focus_cycler.h"
11 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
12 #include "ash/screen_util.h" 12 #include "ash/screen_util.h"
13 #include "ash/shelf/shelf_delegate.h" 13 #include "ash/shelf/shelf_delegate.h"
14 #include "ash/shelf/shelf_item_delegate.h" 14 #include "ash/shelf/shelf_item_delegate.h"
15 #include "ash/shelf/shelf_item_delegate_manager.h" 15 #include "ash/shelf/shelf_item_delegate_manager.h"
16 #include "ash/shelf/shelf_layout_manager.h" 16 #include "ash/shelf/shelf_layout_manager.h"
17 #include "ash/shelf/shelf_model.h" 17 #include "ash/shelf/shelf_model.h"
18 #include "ash/shelf/shelf_navigator.h" 18 #include "ash/shelf/shelf_navigator.h"
19 #include "ash/shelf/shelf_util.h" 19 #include "ash/shelf/shelf_util.h"
20 #include "ash/shelf/shelf_view.h" 20 #include "ash/shelf/shelf_view.h"
21 #include "ash/shelf/shelf_widget.h"
22 #include "ash/shell.h" 21 #include "ash/shell.h"
23 #include "ash/shell_delegate.h" 22 #include "ash/shell_delegate.h"
24 #include "ash/shell_window_ids.h" 23 #include "ash/shell_window_ids.h"
25 #include "ash/wm/window_properties.h" 24 #include "ash/wm/window_properties.h"
26 #include "ui/aura/window.h" 25 #include "ui/aura/window.h"
27 #include "ui/aura/window_event_dispatcher.h" 26 #include "ui/aura/window_event_dispatcher.h"
28 #include "ui/aura/window_observer.h" 27 #include "ui/aura/window_observer.h"
29 #include "ui/compositor/layer.h" 28 #include "ui/compositor/layer.h"
30 #include "ui/gfx/canvas.h" 29 #include "ui/gfx/canvas.h"
31 #include "ui/gfx/image/image.h" 30 #include "ui/gfx/image/image.h"
(...skipping 22 matching lines...) Expand all
54 shelf_widget_->GetNativeView()->SetName(kNativeViewName); 53 shelf_widget_->GetNativeView()->SetName(kNativeViewName);
55 delegate_->OnShelfCreated(this); 54 delegate_->OnShelfCreated(this);
56 } 55 }
57 56
58 Shelf::~Shelf() { 57 Shelf::~Shelf() {
59 delegate_->OnShelfDestroyed(this); 58 delegate_->OnShelfDestroyed(this);
60 } 59 }
61 60
62 // static 61 // static
63 Shelf* Shelf::ForPrimaryDisplay() { 62 Shelf* Shelf::ForPrimaryDisplay() {
64 ShelfWidget* shelf_widget = 63 return Shelf::ForWindow(Shell::GetPrimaryRootWindow());
65 RootWindowController::ForShelf(Shell::GetPrimaryRootWindow())->shelf(); 64 }
65
66 // static
67 Shelf* Shelf::ForWindow(const aura::Window* window) {
68 ShelfWidget* shelf_widget = RootWindowController::ForWindow(window)->shelf();
66 return shelf_widget ? shelf_widget->shelf() : NULL; 69 return shelf_widget ? shelf_widget->shelf() : NULL;
67 } 70 }
68 71
69 // static
70 Shelf* Shelf::ForWindow(aura::Window* window) {
71 ShelfWidget* shelf_widget = RootWindowController::ForShelf(window)->shelf();
72 return shelf_widget ? shelf_widget->shelf() : NULL;
73 }
74
75 void Shelf::SetAlignment(ShelfAlignment alignment) { 72 void Shelf::SetAlignment(ShelfAlignment alignment) {
76 alignment_ = alignment; 73 alignment_ = alignment;
77 shelf_view_->OnShelfAlignmentChanged(); 74 shelf_view_->OnShelfAlignmentChanged();
78 // ShelfLayoutManager will resize the shelf. 75 // ShelfLayoutManager will resize the shelf.
79 } 76 }
80 77
81 gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow( 78 gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow(
82 const aura::Window* window) { 79 const aura::Window* window) {
83 ShelfID id = GetShelfIDForWindow(window); 80 ShelfID id = GetShelfIDForWindow(window);
84 gfx::Rect bounds(shelf_view_->GetIdealBoundsOfItemIcon(id)); 81 gfx::Rect bounds(shelf_view_->GetIdealBoundsOfItemIcon(id));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 183
187 gfx::Rect Shelf::GetVisibleItemsBoundsInScreen() const { 184 gfx::Rect Shelf::GetVisibleItemsBoundsInScreen() const {
188 return shelf_view_->GetVisibleItemsBoundsInScreen(); 185 return shelf_view_->GetVisibleItemsBoundsInScreen();
189 } 186 }
190 187
191 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { 188 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() {
192 return shelf_view_; 189 return shelf_view_;
193 } 190 }
194 191
195 } // namespace ash 192 } // namespace ash
OLDNEW
« ash/shelf/shelf.h ('K') | « ash/shelf/shelf.h ('k') | ash/shelf/shelf_alignment_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698