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

Unified Diff: ash/common/shelf/wm_shelf.cc

Issue 2247503002: mash: Create and show a shelf in mash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: ash/common/shelf/wm_shelf.cc
diff --git a/ash/common/shelf/wm_shelf.cc b/ash/common/shelf/wm_shelf.cc
index 646ebed36025f0bcefa8beb4ad2545123599b969..ddeba24afa2d7e6c98e3d3963f2d3fe5d6123a08 100644
--- a/ash/common/shelf/wm_shelf.cc
+++ b/ash/common/shelf/wm_shelf.cc
@@ -3,11 +3,46 @@
// found in the LICENSE file.
#include "ash/common/shelf/wm_shelf.h"
-
+#include "ash/common/shelf/wm_shelf_observer.h"
+#include "ash/common/wm_lookup.h"
+#include "ash/shelf/shelf.h"
+#include "ash/shelf/shelf_layout_manager.h"
#include "base/logging.h"
namespace ash {
+void WmShelf::SetShelf(std::unique_ptr<Shelf> shelf) {
+ DCHECK(!shelf_ || !shelf);
+ shelf_ = std::move(shelf);
+}
+
+void WmShelf::SetShelfLayoutManager(ShelfLayoutManager* shelf_layout_manager) {
+ DCHECK(!shelf_layout_manager_ || !shelf_layout_manager);
+
+ if (shelf_layout_manager_)
+ shelf_layout_manager_->RemoveObserver(this);
+
+ shelf_layout_manager_ = shelf_layout_manager;
+
+ if (shelf_layout_manager_)
+ shelf_layout_manager_->AddObserver(this);
+}
+
+WmWindow* WmShelf::GetWindow() {
+ // Use |shelf_layout_manager_| to access ShelfWidget because it is set before
+ // before the Shelf instance is available.
+ return WmLookup::Get()->GetWindowForWidget(
+ shelf_layout_manager_->shelf_widget());
+}
+
+ShelfAlignment WmShelf::GetAlignment() const {
+ return shelf_ ? shelf_->alignment() : SHELF_ALIGNMENT_BOTTOM_LOCKED;
+}
+
+void WmShelf::SetAlignment(ShelfAlignment alignment) {
+ shelf_->SetAlignment(alignment);
+}
+
bool WmShelf::IsHorizontalAlignment() const {
switch (GetAlignment()) {
case SHELF_ALIGNMENT_BOTTOM:
@@ -41,4 +76,128 @@ int WmShelf::PrimaryAxisValue(int horizontal, int vertical) const {
return IsHorizontalAlignment() ? horizontal : vertical;
}
+ShelfAutoHideBehavior WmShelf::GetAutoHideBehavior() const {
+ return shelf_->auto_hide_behavior();
+}
+
+void WmShelf::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) {
+ shelf_->SetAutoHideBehavior(behavior);
+}
+
+ShelfAutoHideState WmShelf::GetAutoHideState() const {
+ return shelf_layout_manager_->auto_hide_state();
+}
+
+void WmShelf::UpdateAutoHideState() {
+ shelf_layout_manager_->UpdateAutoHideState();
+}
+
+ShelfBackgroundType WmShelf::GetBackgroundType() const {
+ return shelf_layout_manager_->shelf_widget()->GetBackgroundType();
+}
+
+WmDimmerView* WmShelf::CreateDimmerView(bool disable_animations_for_test) {
+ return nullptr;
+}
+
+bool WmShelf::IsDimmed() const {
+ return shelf_layout_manager_->shelf_widget()->GetDimsShelf();
+}
+
+void WmShelf::SchedulePaint() {
+ // Can be called during shutdown if the overflow bubble is visible.
+ if (shelf_)
+ shelf_->SchedulePaint();
+}
+
+bool WmShelf::IsVisible() const {
+ return shelf_->IsVisible();
+}
+
+void WmShelf::UpdateVisibilityState() {
+ if (shelf_layout_manager_)
+ shelf_layout_manager_->UpdateVisibilityState();
+}
+
+ShelfVisibilityState WmShelf::GetVisibilityState() const {
+ return shelf_layout_manager_ ? shelf_layout_manager_->visibility_state()
+ : SHELF_HIDDEN;
+}
+
+gfx::Rect WmShelf::GetIdealBounds() {
+ return shelf_layout_manager_->GetIdealBounds();
+}
+
+gfx::Rect WmShelf::GetUserWorkAreaBounds() const {
+ return shelf_layout_manager_ ? shelf_layout_manager_->user_work_area_bounds()
+ : gfx::Rect();
+}
+
+void WmShelf::UpdateIconPositionForWindow(WmWindow* window) {
+ shelf_->UpdateIconPositionForWindow(window);
+}
+
+gfx::Rect WmShelf::GetScreenBoundsOfItemIconForWindow(WmWindow* window) {
+ return shelf_->GetScreenBoundsOfItemIconForWindow(window);
+}
+
+bool WmShelf::ProcessGestureEvent(const ui::GestureEvent& event) {
+ // Can be called at login screen.
+ if (!shelf_layout_manager_)
+ return false;
+ return shelf_layout_manager_->ProcessGestureEvent(event);
+}
+
+void WmShelf::AddObserver(WmShelfObserver* observer) {
+ observers_.AddObserver(observer);
+}
+
+void WmShelf::RemoveObserver(WmShelfObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+void WmShelf::NotifyShelfIconPositionsChanged() {
+ FOR_EACH_OBSERVER(WmShelfObserver, observers_, OnShelfIconPositionsChanged());
+}
+
+void WmShelf::SetKeyboardBoundsForTesting(const gfx::Rect& bounds) {
+ shelf_layout_manager_->OnKeyboardBoundsChanging(bounds);
+}
+
+ShelfLockingManager* WmShelf::GetShelfLockingManagerForTesting() {
+ return shelf_->shelf_locking_manager_for_testing();
+}
+
+ShelfView* WmShelf::GetShelfViewForTesting() {
+ return shelf_->shelf_view_for_testing();
+}
+
+WmShelf::WmShelf() {}
+
+WmShelf::~WmShelf() {
+ SetShelfLayoutManager(nullptr);
+}
+
+void WmShelf::WillDeleteShelfLayoutManager() {
+ SetShelfLayoutManager(nullptr);
+}
+
+void WmShelf::WillChangeVisibilityState(ShelfVisibilityState new_state) {
+ FOR_EACH_OBSERVER(WmShelfObserver, observers_,
+ WillChangeVisibilityState(new_state));
+}
+
+void WmShelf::OnAutoHideStateChanged(ShelfAutoHideState new_state) {
+ FOR_EACH_OBSERVER(WmShelfObserver, observers_,
+ OnAutoHideStateChanged(new_state));
+}
+
+void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type,
+ BackgroundAnimatorChangeType change_type) {
+ if (background_type == GetBackgroundType())
+ return;
+ FOR_EACH_OBSERVER(WmShelfObserver, observers_,
+ OnBackgroundTypeChanged(background_type, change_type));
+}
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698