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

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

Issue 2899253002: chromeos: Rename ash::WmShelf to Shelf (Closed)
Patch Set: rebase Created 3 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
« no previous file with comments | « ash/shelf/shelf_controller.h ('k') | ash/shelf/shelf_layout_manager.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/shelf/shelf_controller.h" 5 #include "ash/shelf/shelf_controller.h"
6 6
7 #include "ash/public/interfaces/shelf.mojom.h" 7 #include "ash/public/interfaces/shelf.mojom.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/session/session_controller.h" 9 #include "ash/session/session_controller.h"
10 #include "ash/shelf/app_list_shelf_item_delegate.h" 10 #include "ash/shelf/app_list_shelf_item_delegate.h"
11 #include "ash/shelf/wm_shelf.h" 11 #include "ash/shelf/shelf.h"
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/wm_window.h" 13 #include "ash/wm_window.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "ui/base/models/simple_menu_model.h" 15 #include "ui/base/models/simple_menu_model.h"
16 #include "ui/display/display.h" 16 #include "ui/display/display.h"
17 #include "ui/display/screen.h" 17 #include "ui/display/screen.h"
18 18
19 namespace ash { 19 namespace ash {
20 20
21 namespace { 21 namespace {
22 22
23 // Returns the WmShelf instance for the display with the given |display_id|. 23 // Returns the Shelf instance for the display with the given |display_id|.
24 WmShelf* GetShelfForDisplay(int64_t display_id) { 24 Shelf* GetShelfForDisplay(int64_t display_id) {
25 // The controller may be null for invalid ids or for displays being removed. 25 // The controller may be null for invalid ids or for displays being removed.
26 RootWindowController* root_window_controller = 26 RootWindowController* root_window_controller =
27 Shell::GetRootWindowControllerWithDisplayId(display_id); 27 Shell::GetRootWindowControllerWithDisplayId(display_id);
28 return root_window_controller ? root_window_controller->GetShelf() : nullptr; 28 return root_window_controller ? root_window_controller->GetShelf() : nullptr;
29 } 29 }
30 30
31 } // namespace 31 } // namespace
32 32
33 ShelfController::ShelfController() { 33 ShelfController::ShelfController() {
34 // Create the app list item in the shelf. 34 // Create the app list item in the shelf.
35 AppListShelfItemDelegate::CreateAppListItemAndDelegate(&model_); 35 AppListShelfItemDelegate::CreateAppListItemAndDelegate(&model_);
36 } 36 }
37 37
38 ShelfController::~ShelfController() {} 38 ShelfController::~ShelfController() {}
39 39
40 void ShelfController::BindRequest(mojom::ShelfControllerRequest request) { 40 void ShelfController::BindRequest(mojom::ShelfControllerRequest request) {
41 bindings_.AddBinding(this, std::move(request)); 41 bindings_.AddBinding(this, std::move(request));
42 } 42 }
43 43
44 void ShelfController::NotifyShelfInitialized(WmShelf* shelf) { 44 void ShelfController::NotifyShelfInitialized(Shelf* shelf) {
45 // Notify observers, Chrome will set alignment and auto-hide from prefs. 45 // Notify observers, Chrome will set alignment and auto-hide from prefs.
46 int64_t display_id = shelf->GetWindow()->GetDisplayNearestWindow().id(); 46 int64_t display_id = shelf->GetWindow()->GetDisplayNearestWindow().id();
47 observers_.ForAllPtrs([display_id](mojom::ShelfObserver* observer) { 47 observers_.ForAllPtrs([display_id](mojom::ShelfObserver* observer) {
48 observer->OnShelfInitialized(display_id); 48 observer->OnShelfInitialized(display_id);
49 }); 49 });
50 } 50 }
51 51
52 void ShelfController::NotifyShelfAlignmentChanged(WmShelf* shelf) { 52 void ShelfController::NotifyShelfAlignmentChanged(Shelf* shelf) {
53 ShelfAlignment alignment = shelf->alignment(); 53 ShelfAlignment alignment = shelf->alignment();
54 int64_t display_id = shelf->GetWindow()->GetDisplayNearestWindow().id(); 54 int64_t display_id = shelf->GetWindow()->GetDisplayNearestWindow().id();
55 observers_.ForAllPtrs( 55 observers_.ForAllPtrs(
56 [alignment, display_id](mojom::ShelfObserver* observer) { 56 [alignment, display_id](mojom::ShelfObserver* observer) {
57 observer->OnAlignmentChanged(alignment, display_id); 57 observer->OnAlignmentChanged(alignment, display_id);
58 }); 58 });
59 } 59 }
60 60
61 void ShelfController::NotifyShelfAutoHideBehaviorChanged(WmShelf* shelf) { 61 void ShelfController::NotifyShelfAutoHideBehaviorChanged(Shelf* shelf) {
62 ShelfAutoHideBehavior behavior = shelf->auto_hide_behavior(); 62 ShelfAutoHideBehavior behavior = shelf->auto_hide_behavior();
63 int64_t display_id = shelf->GetWindow()->GetDisplayNearestWindow().id(); 63 int64_t display_id = shelf->GetWindow()->GetDisplayNearestWindow().id();
64 observers_.ForAllPtrs([behavior, display_id](mojom::ShelfObserver* observer) { 64 observers_.ForAllPtrs([behavior, display_id](mojom::ShelfObserver* observer) {
65 observer->OnAutoHideBehaviorChanged(behavior, display_id); 65 observer->OnAutoHideBehaviorChanged(behavior, display_id);
66 }); 66 });
67 } 67 }
68 68
69 void ShelfController::AddObserver( 69 void ShelfController::AddObserver(
70 mojom::ShelfObserverAssociatedPtrInfo observer) { 70 mojom::ShelfObserverAssociatedPtrInfo observer) {
71 mojom::ShelfObserverAssociatedPtr observer_ptr; 71 mojom::ShelfObserverAssociatedPtr observer_ptr;
72 observer_ptr.Bind(std::move(observer)); 72 observer_ptr.Bind(std::move(observer));
73 observers_.AddPtr(std::move(observer_ptr)); 73 observers_.AddPtr(std::move(observer_ptr));
74 } 74 }
75 75
76 void ShelfController::SetAlignment(ShelfAlignment alignment, 76 void ShelfController::SetAlignment(ShelfAlignment alignment,
77 int64_t display_id) { 77 int64_t display_id) {
78 WmShelf* shelf = GetShelfForDisplay(display_id); 78 Shelf* shelf = GetShelfForDisplay(display_id);
79 // TODO(jamescook): The session state check should not be necessary, but 79 // TODO(jamescook): The session state check should not be necessary, but
80 // otherwise this wrongly tries to set the alignment on a secondary display 80 // otherwise this wrongly tries to set the alignment on a secondary display
81 // during login before the ShelfLockingManager is created. 81 // during login before the ShelfLockingManager is created.
82 if (shelf && Shell::Get()->session_controller()->IsActiveUserSessionStarted()) 82 if (shelf && Shell::Get()->session_controller()->IsActiveUserSessionStarted())
83 shelf->SetAlignment(alignment); 83 shelf->SetAlignment(alignment);
84 } 84 }
85 85
86 void ShelfController::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide, 86 void ShelfController::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide,
87 int64_t display_id) { 87 int64_t display_id) {
88 WmShelf* shelf = GetShelfForDisplay(display_id); 88 Shelf* shelf = GetShelfForDisplay(display_id);
89 // TODO(jamescook): The session state check should not be necessary, but 89 // TODO(jamescook): The session state check should not be necessary, but
90 // otherwise this wrongly tries to set auto-hide state on a secondary display 90 // otherwise this wrongly tries to set auto-hide state on a secondary display
91 // during login. 91 // during login.
92 if (shelf && Shell::Get()->session_controller()->IsActiveUserSessionStarted()) 92 if (shelf && Shell::Get()->session_controller()->IsActiveUserSessionStarted())
93 shelf->SetAutoHideBehavior(auto_hide); 93 shelf->SetAutoHideBehavior(auto_hide);
94 } 94 }
95 95
96 void ShelfController::PinItem( 96 void ShelfController::PinItem(
97 const ShelfItem& item, 97 const ShelfItem& item,
98 mojom::ShelfItemDelegateAssociatedPtrInfo delegate) { 98 mojom::ShelfItemDelegateAssociatedPtrInfo delegate) {
99 NOTIMPLEMENTED(); 99 NOTIMPLEMENTED();
100 } 100 }
101 101
102 void ShelfController::UnpinItem(const std::string& app_id) { 102 void ShelfController::UnpinItem(const std::string& app_id) {
103 NOTIMPLEMENTED(); 103 NOTIMPLEMENTED();
104 } 104 }
105 105
106 void ShelfController::SetItemImage(const std::string& app_id, 106 void ShelfController::SetItemImage(const std::string& app_id,
107 const SkBitmap& image) { 107 const SkBitmap& image) {
108 NOTIMPLEMENTED(); 108 NOTIMPLEMENTED();
109 } 109 }
110 110
111 } // namespace ash 111 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_controller.h ('k') | ash/shelf/shelf_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698