| OLD | NEW |
| 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/shelf/app_list_shelf_item_delegate.h" | 10 #include "ash/shelf/app_list_shelf_item_delegate.h" |
| 10 #include "ash/shelf/wm_shelf.h" | 11 #include "ash/shelf/wm_shelf.h" |
| 11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 12 #include "ash/wm_window.h" | 13 #include "ash/wm_window.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "ui/base/models/simple_menu_model.h" | 15 #include "ui/base/models/simple_menu_model.h" |
| 15 #include "ui/display/display.h" | 16 #include "ui/display/display.h" |
| 16 #include "ui/display/screen.h" | 17 #include "ui/display/screen.h" |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 33 // Create the app list item in the shelf. | 34 // Create the app list item in the shelf. |
| 34 AppListShelfItemDelegate::CreateAppListItemAndDelegate(&model_); | 35 AppListShelfItemDelegate::CreateAppListItemAndDelegate(&model_); |
| 35 } | 36 } |
| 36 | 37 |
| 37 ShelfController::~ShelfController() {} | 38 ShelfController::~ShelfController() {} |
| 38 | 39 |
| 39 void ShelfController::BindRequest(mojom::ShelfControllerRequest request) { | 40 void ShelfController::BindRequest(mojom::ShelfControllerRequest request) { |
| 40 bindings_.AddBinding(this, std::move(request)); | 41 bindings_.AddBinding(this, std::move(request)); |
| 41 } | 42 } |
| 42 | 43 |
| 43 void ShelfController::NotifyShelfCreated(WmShelf* shelf) { | 44 void ShelfController::NotifyShelfInitialized(WmShelf* shelf) { |
| 44 // Notify observers, Chrome will set alignment and auto-hide from prefs. | 45 // Notify observers, Chrome will set alignment and auto-hide from prefs. |
| 45 int64_t display_id = shelf->GetWindow()->GetDisplayNearestWindow().id(); | 46 int64_t display_id = shelf->GetWindow()->GetDisplayNearestWindow().id(); |
| 46 observers_.ForAllPtrs([display_id](mojom::ShelfObserver* observer) { | 47 observers_.ForAllPtrs([display_id](mojom::ShelfObserver* observer) { |
| 47 observer->OnShelfCreated(display_id); | 48 observer->OnShelfInitialized(display_id); |
| 48 }); | 49 }); |
| 49 } | 50 } |
| 50 | 51 |
| 51 void ShelfController::NotifyShelfAlignmentChanged(WmShelf* shelf) { | 52 void ShelfController::NotifyShelfAlignmentChanged(WmShelf* shelf) { |
| 52 ShelfAlignment alignment = shelf->alignment(); | 53 ShelfAlignment alignment = shelf->alignment(); |
| 53 int64_t display_id = shelf->GetWindow()->GetDisplayNearestWindow().id(); | 54 int64_t display_id = shelf->GetWindow()->GetDisplayNearestWindow().id(); |
| 54 observers_.ForAllPtrs( | 55 observers_.ForAllPtrs( |
| 55 [alignment, display_id](mojom::ShelfObserver* observer) { | 56 [alignment, display_id](mojom::ShelfObserver* observer) { |
| 56 observer->OnAlignmentChanged(alignment, display_id); | 57 observer->OnAlignmentChanged(alignment, display_id); |
| 57 }); | 58 }); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 68 void ShelfController::AddObserver( | 69 void ShelfController::AddObserver( |
| 69 mojom::ShelfObserverAssociatedPtrInfo observer) { | 70 mojom::ShelfObserverAssociatedPtrInfo observer) { |
| 70 mojom::ShelfObserverAssociatedPtr observer_ptr; | 71 mojom::ShelfObserverAssociatedPtr observer_ptr; |
| 71 observer_ptr.Bind(std::move(observer)); | 72 observer_ptr.Bind(std::move(observer)); |
| 72 observers_.AddPtr(std::move(observer_ptr)); | 73 observers_.AddPtr(std::move(observer_ptr)); |
| 73 } | 74 } |
| 74 | 75 |
| 75 void ShelfController::SetAlignment(ShelfAlignment alignment, | 76 void ShelfController::SetAlignment(ShelfAlignment alignment, |
| 76 int64_t display_id) { | 77 int64_t display_id) { |
| 77 WmShelf* shelf = GetShelfForDisplay(display_id); | 78 WmShelf* shelf = GetShelfForDisplay(display_id); |
| 78 // TODO(jamescook): The initialization check should not be necessary, but | 79 // TODO(jamescook): The session state check should not be necessary, but |
| 79 // 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 |
| 80 // during login before the ShelfLockingManager and ShelfView are created. | 81 // during login before the ShelfLockingManager is created. |
| 81 if (shelf && shelf->IsShelfInitialized()) | 82 if (shelf && Shell::Get()->session_controller()->IsActiveUserSessionStarted()) |
| 82 shelf->SetAlignment(alignment); | 83 shelf->SetAlignment(alignment); |
| 83 } | 84 } |
| 84 | 85 |
| 85 void ShelfController::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide, | 86 void ShelfController::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide, |
| 86 int64_t display_id) { | 87 int64_t display_id) { |
| 87 WmShelf* shelf = GetShelfForDisplay(display_id); | 88 WmShelf* shelf = GetShelfForDisplay(display_id); |
| 88 // TODO(jamescook): The initialization check should not be necessary, but | 89 // TODO(jamescook): The session state check should not be necessary, but |
| 89 // 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 |
| 90 // during login before the ShelfView is created. | 91 // during login. |
| 91 if (shelf && shelf->IsShelfInitialized()) | 92 if (shelf && Shell::Get()->session_controller()->IsActiveUserSessionStarted()) |
| 92 shelf->SetAutoHideBehavior(auto_hide); | 93 shelf->SetAutoHideBehavior(auto_hide); |
| 93 } | 94 } |
| 94 | 95 |
| 95 void ShelfController::PinItem( | 96 void ShelfController::PinItem( |
| 96 const ShelfItem& item, | 97 const ShelfItem& item, |
| 97 mojom::ShelfItemDelegateAssociatedPtrInfo delegate) { | 98 mojom::ShelfItemDelegateAssociatedPtrInfo delegate) { |
| 98 NOTIMPLEMENTED(); | 99 NOTIMPLEMENTED(); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void ShelfController::UnpinItem(const std::string& app_id) { | 102 void ShelfController::UnpinItem(const std::string& app_id) { |
| 102 NOTIMPLEMENTED(); | 103 NOTIMPLEMENTED(); |
| 103 } | 104 } |
| 104 | 105 |
| 105 void ShelfController::SetItemImage(const std::string& app_id, | 106 void ShelfController::SetItemImage(const std::string& app_id, |
| 106 const SkBitmap& image) { | 107 const SkBitmap& image) { |
| 107 NOTIMPLEMENTED(); | 108 NOTIMPLEMENTED(); |
| 108 } | 109 } |
| 109 | 110 |
| 110 } // namespace ash | 111 } // namespace ash |
| OLD | NEW |