Chromium Code Reviews| Index: ash/aura/wm_shelf_aura.cc |
| diff --git a/ash/aura/wm_shelf_aura.cc b/ash/aura/wm_shelf_aura.cc |
| index cfeb53d1c41f2f669df5010d6532d576914d4af4..2cbbd68ab75f9c222c57c676dc2f64b061af10a9 100644 |
| --- a/ash/aura/wm_shelf_aura.cc |
| +++ b/ash/aura/wm_shelf_aura.cc |
| @@ -5,14 +5,10 @@ |
| #include "ash/aura/wm_shelf_aura.h" |
| #include "ash/aura/wm_window_aura.h" |
| -#include "ash/common/shelf/wm_shelf_observer.h" |
| -#include "ash/common/wm_window.h" |
| #include "ash/shelf/dimmer_view.h" |
| -#include "ash/shelf/shelf.h" |
| #include "ash/shelf/shelf_bezel_event_handler.h" |
| #include "ash/shelf/shelf_layout_manager.h" |
| #include "ash/shell.h" |
| -#include "ui/views/widget/widget.h" |
| namespace ash { |
| @@ -51,184 +47,31 @@ WmShelfAura::WmShelfAura() {} |
| WmShelfAura::~WmShelfAura() {} |
| -void WmShelfAura::SetShelfLayoutManager( |
| - ShelfLayoutManager* shelf_layout_manager) { |
| - DCHECK(!shelf_layout_manager_); |
| - shelf_layout_manager_ = shelf_layout_manager; |
| - shelf_layout_manager_->AddObserver(this); |
| - bezel_event_handler_.reset(new ShelfBezelEventHandler(this)); |
| -} |
| - |
| -void WmShelfAura::SetShelf(Shelf* shelf) { |
| - DCHECK(!shelf_); |
| - shelf_ = shelf; |
| - shelf_->AddIconObserver(this); |
| -} |
| - |
| -void WmShelfAura::Shutdown() { |
| - if (shelf_) { |
| - shelf_->RemoveIconObserver(this); |
| - shelf_ = nullptr; |
| - } |
| - |
| - ResetShelfLayoutManager(); |
| -} |
| - |
| -// static |
| -Shelf* WmShelfAura::GetShelf(WmShelf* shelf) { |
| - return static_cast<WmShelfAura*>(shelf)->shelf_; |
| -} |
| - |
| -void WmShelfAura::ResetShelfLayoutManager() { |
| - if (!shelf_layout_manager_) |
| - return; |
| - // Clear event handlers that might otherwise forward events during shutdown. |
| - auto_hide_event_handler_.reset(); |
| - bezel_event_handler_.reset(); |
| - shelf_layout_manager_->RemoveObserver(this); |
| - shelf_layout_manager_ = nullptr; |
| -} |
| - |
| -WmWindow* WmShelfAura::GetWindow() { |
| - // Use |shelf_layout_manager_| to access ShelfWidget because it is set |
| - // before |shelf_| is available. |
| - return WmWindowAura::Get( |
| - shelf_layout_manager_->shelf_widget()->GetNativeView()); |
| -} |
| - |
| -ShelfAlignment WmShelfAura::GetAlignment() const { |
| - // Can be called before |shelf_| is set when initializing a secondary monitor. |
| - return shelf_ ? shelf_->alignment() : SHELF_ALIGNMENT_BOTTOM_LOCKED; |
| -} |
| - |
| -void WmShelfAura::SetAlignment(ShelfAlignment alignment) { |
| - shelf_->SetAlignment(alignment); |
| -} |
| - |
| -ShelfAutoHideBehavior WmShelfAura::GetAutoHideBehavior() const { |
| - return shelf_->auto_hide_behavior(); |
| -} |
| - |
| -void WmShelfAura::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) { |
| - shelf_->SetAutoHideBehavior(behavior); |
| -} |
| - |
| -ShelfAutoHideState WmShelfAura::GetAutoHideState() const { |
| - return shelf_layout_manager_->auto_hide_state(); |
| -} |
| - |
| -void WmShelfAura::UpdateAutoHideState() { |
| - shelf_layout_manager_->UpdateAutoHideState(); |
| -} |
| - |
| -ShelfBackgroundType WmShelfAura::GetBackgroundType() const { |
| - return shelf_layout_manager_->shelf_widget()->GetBackgroundType(); |
| -} |
| - |
| WmDimmerView* WmShelfAura::CreateDimmerView(bool disable_animations_for_test) { |
| return DimmerView::Create(this, disable_animations_for_test); |
| } |
| -bool WmShelfAura::IsDimmed() const { |
| - return shelf_layout_manager_->shelf_widget()->GetDimsShelf(); |
| -} |
| - |
| -void WmShelfAura::SchedulePaint() { |
| - // Can be called during shutdown if the overflow bubble is visible. |
| - if (shelf_) |
| - shelf_->SchedulePaint(); |
| -} |
| - |
| -bool WmShelfAura::IsVisible() const { |
| - return shelf_->IsVisible(); |
| -} |
| - |
| -void WmShelfAura::UpdateVisibilityState() { |
| - if (shelf_layout_manager_) |
| - shelf_layout_manager_->UpdateVisibilityState(); |
| -} |
| - |
| -ShelfVisibilityState WmShelfAura::GetVisibilityState() const { |
| - return shelf_layout_manager_ ? shelf_layout_manager_->visibility_state() |
| - : SHELF_HIDDEN; |
| -} |
| - |
| -gfx::Rect WmShelfAura::GetIdealBounds() { |
| - return shelf_layout_manager_->GetIdealBounds(); |
| -} |
| - |
| -gfx::Rect WmShelfAura::GetUserWorkAreaBounds() const { |
| - return shelf_layout_manager_ ? shelf_layout_manager_->user_work_area_bounds() |
| - : gfx::Rect(); |
| -} |
| - |
| -void WmShelfAura::UpdateIconPositionForWindow(WmWindow* window) { |
| - shelf_->UpdateIconPositionForWindow(window); |
| -} |
| - |
| -gfx::Rect WmShelfAura::GetScreenBoundsOfItemIconForWindow(WmWindow* window) { |
| - return shelf_->GetScreenBoundsOfItemIconForWindow(window); |
| -} |
| - |
| -bool WmShelfAura::ProcessGestureEvent(const ui::GestureEvent& event) { |
| - // Can be called at login screen. |
| - if (!shelf_layout_manager_) |
| - return false; |
| - return shelf_layout_manager_->ProcessGestureEvent(event); |
| -} |
| - |
| -void WmShelfAura::AddObserver(WmShelfObserver* observer) { |
| - observers_.AddObserver(observer); |
| -} |
| - |
| -void WmShelfAura::RemoveObserver(WmShelfObserver* observer) { |
| - observers_.RemoveObserver(observer); |
| -} |
| - |
| -void WmShelfAura::SetKeyboardBoundsForTesting(const gfx::Rect& bounds) { |
| - shelf_layout_manager_->OnKeyboardBoundsChanging(bounds); |
| -} |
| - |
| -ShelfLockingManager* WmShelfAura::GetShelfLockingManagerForTesting() { |
| - return shelf_->shelf_locking_manager_for_testing(); |
| -} |
| - |
| -ShelfView* WmShelfAura::GetShelfViewForTesting() { |
| - return shelf_->shelf_view_for_testing(); |
| -} |
| +void WmShelfAura::SetShelfLayoutManager(ShelfLayoutManager* manager) { |
|
James Cook
2016/08/16 23:21:35
I suspect this only needs to be called once to set
msw
2016/08/17 01:09:01
Done. (I wrote ClearShelfLayoutManager, but then d
|
| + if (shelf_layout_manager()) { |
| + // Clear event handlers that might forward events to the destroyed instance. |
| + auto_hide_event_handler_.reset(); |
| + bezel_event_handler_.reset(); |
| + } |
| -void WmShelfAura::WillDeleteShelfLayoutManager() { |
| - ResetShelfLayoutManager(); |
| -} |
| + WmShelf::SetShelfLayoutManager(manager); |
| -void WmShelfAura::OnBackgroundUpdated( |
| - ShelfBackgroundType background_type, |
| - BackgroundAnimatorChangeType change_type) { |
| - if (background_type == GetBackgroundType()) |
| - return; |
| - FOR_EACH_OBSERVER(WmShelfObserver, observers_, |
| - OnBackgroundTypeChanged(background_type, change_type)); |
| + if (manager) |
| + bezel_event_handler_.reset(new ShelfBezelEventHandler(this)); |
|
James Cook
2016/08/16 23:21:34
Do you need to reconstruct the auto_hide_event_fil
msw
2016/08/17 01:09:01
I don't think so; that's created on WillChangeVisi
|
| } |
| void WmShelfAura::WillChangeVisibilityState(ShelfVisibilityState new_state) { |
| - FOR_EACH_OBSERVER(WmShelfObserver, observers_, |
| - WillChangeVisibilityState(new_state)); |
| - |
| + WmShelf::WillChangeVisibilityState(new_state); |
| if (new_state != SHELF_AUTO_HIDE) { |
| auto_hide_event_handler_.reset(); |
| } else if (!auto_hide_event_handler_) { |
| auto_hide_event_handler_.reset( |
| - new AutoHideEventHandler(shelf_layout_manager_)); |
| + new AutoHideEventHandler(shelf_layout_manager())); |
| } |
| } |
| -void WmShelfAura::OnAutoHideStateChanged(ShelfAutoHideState new_state) { |
| - FOR_EACH_OBSERVER(WmShelfObserver, observers_, |
| - OnAutoHideStateChanged(new_state)); |
| -} |
| - |
| -void WmShelfAura::OnShelfIconPositionsChanged() { |
| - FOR_EACH_OBSERVER(WmShelfObserver, observers_, OnShelfIconPositionsChanged()); |
| -} |
| - |
| } // namespace ash |