Chromium Code Reviews| Index: ash/common/shelf/wm_shelf.h |
| diff --git a/ash/common/shelf/wm_shelf.h b/ash/common/shelf/wm_shelf.h |
| index 4bfd2cfb15b4b0cb641db59fdcc6d089097ba72f..c2d0280fb91c7324b7892e6b85cf638a3e26b7ac 100644 |
| --- a/ash/common/shelf/wm_shelf.h |
| +++ b/ash/common/shelf/wm_shelf.h |
| @@ -5,8 +5,12 @@ |
| #ifndef ASH_COMMON_SHELF_WM_SHELF_H_ |
| #define ASH_COMMON_SHELF_WM_SHELF_H_ |
| +#include <memory> |
| + |
| #include "ash/ash_export.h" |
| #include "ash/common/shelf/shelf_types.h" |
| +#include "ash/shelf/shelf_layout_manager_observer.h" |
| +#include "base/observer_list.h" |
| namespace gfx { |
| class Rect; |
| @@ -18,6 +22,8 @@ class GestureEvent; |
| namespace ash { |
| +class Shelf; |
| +class ShelfLayoutManager; |
| class ShelfLockingManager; |
| class ShelfView; |
| class WmDimmerView; |
| @@ -25,13 +31,21 @@ class WmShelfObserver; |
| class WmWindow; |
| // Used for accessing global state. |
| -class ASH_EXPORT WmShelf { |
| +class ASH_EXPORT WmShelf : public ShelfLayoutManagerObserver { |
| public: |
| + void SetShelf(std::unique_ptr<Shelf> shelf); |
| + Shelf* shelf() const { return shelf_.get(); } |
| + |
| + virtual void SetShelfLayoutManager(ShelfLayoutManager* manager); |
| + ShelfLayoutManager* shelf_layout_manager() const { |
| + return shelf_layout_manager_; |
| + } |
|
James Cook
2016/08/16 23:21:35
Ugh, the SetShelf / SetShelfLayoutManager lifetime
msw
2016/08/17 01:09:01
Done; I expanded on the local members' declaration
|
| + |
| // Returns the window showing the shelf. |
| - virtual WmWindow* GetWindow() = 0; |
| + WmWindow* GetWindow(); |
| - virtual ShelfAlignment GetAlignment() const = 0; |
| - virtual void SetAlignment(ShelfAlignment alignment) = 0; |
| + ShelfAlignment GetAlignment() const; |
| + void SetAlignment(ShelfAlignment alignment); |
| // Returns true if the shelf alignment is horizontal (i.e. at the bottom). |
| bool IsHorizontalAlignment() const; |
| @@ -42,69 +56,88 @@ class ASH_EXPORT WmShelf { |
| // Returns |horizontal| is shelf is horizontal, otherwise |vertical|. |
| int PrimaryAxisValue(int horizontal, int vertical) const; |
| - virtual ShelfAutoHideBehavior GetAutoHideBehavior() const = 0; |
| - virtual void SetAutoHideBehavior(ShelfAutoHideBehavior behavior) = 0; |
| + ShelfAutoHideBehavior GetAutoHideBehavior() const; |
| + void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); |
| - virtual ShelfAutoHideState GetAutoHideState() const = 0; |
| + ShelfAutoHideState GetAutoHideState() const; |
| // Invoke when the auto-hide state may have changed (for example, when the |
| // system tray bubble opens it should force the shelf to be visible). |
| - virtual void UpdateAutoHideState() = 0; |
| + void UpdateAutoHideState(); |
| - virtual ShelfBackgroundType GetBackgroundType() const = 0; |
| + ShelfBackgroundType GetBackgroundType() const; |
| // Creates a view that dims shelf items. The returned view is owned by its |
| // widget. Returns null if shelf dimming is not supported (e.g. on mus). |
| // TODO(jamescook): Delete this after material design ships, as MD will not |
| // require shelf dimming. http://crbug.com/614453 |
| - virtual WmDimmerView* CreateDimmerView(bool disable_animations_for_test) = 0; |
| + virtual WmDimmerView* CreateDimmerView(bool disable_animations_for_test); |
| // Shelf items are slightly dimmed (e.g. when a window is maximized). |
| // TODO(jamescook): Delete this after material design ships, as MD will not |
| // require shelf dimming. http://crbug.com/614453 |
| - virtual bool IsDimmed() const = 0; |
| + bool IsDimmed() const; |
| // Schedules a repaint for all shelf buttons. |
| // TODO(jamescook): Eliminate when ShelfView moves to //ash/common. |
| // http://crbug.com/615155 |
| - virtual void SchedulePaint() = 0; |
| + void SchedulePaint(); |
| // Whether the shelf view is visible. |
| // TODO(jamescook): Consolidate this with GetVisibilityState(). |
| - virtual bool IsVisible() const = 0; |
| + bool IsVisible() const; |
| - virtual void UpdateVisibilityState() = 0; |
| + void UpdateVisibilityState(); |
| - virtual ShelfVisibilityState GetVisibilityState() const = 0; |
| + ShelfVisibilityState GetVisibilityState() const; |
| // Returns the ideal bounds of the shelf assuming it is visible. |
| - virtual gfx::Rect GetIdealBounds() = 0; |
| + gfx::Rect GetIdealBounds(); |
| - virtual gfx::Rect GetUserWorkAreaBounds() const = 0; |
| + gfx::Rect GetUserWorkAreaBounds() const; |
| - virtual void UpdateIconPositionForWindow(WmWindow* window) = 0; |
| + void UpdateIconPositionForWindow(WmWindow* window); |
| // Returns the screen bounds of the item for the specified window. If there is |
| // no item for the specified window an empty rect is returned. |
| - virtual gfx::Rect GetScreenBoundsOfItemIconForWindow(WmWindow* window) = 0; |
| + gfx::Rect GetScreenBoundsOfItemIconForWindow(WmWindow* window); |
| // Handles a gesture |event| coming from a source outside the shelf widget |
| // (e.g. the status area widget). Allows support for behaviors like toggling |
| // auto-hide with a swipe, even if that gesture event hits another window. |
| // Returns true if the event was handled. |
| - virtual bool ProcessGestureEvent(const ui::GestureEvent& event) = 0; |
| + bool ProcessGestureEvent(const ui::GestureEvent& event); |
| - virtual void AddObserver(WmShelfObserver* observer) = 0; |
| - virtual void RemoveObserver(WmShelfObserver* observer) = 0; |
| + void AddObserver(WmShelfObserver* observer); |
| + void RemoveObserver(WmShelfObserver* observer); |
| - // Simulates a virtual keyboard bounds update. |
| - virtual void SetKeyboardBoundsForTesting(const gfx::Rect& bounds) = 0; |
| + void NotifyShelfIconPositionsChanged(); |
| - virtual ShelfLockingManager* GetShelfLockingManagerForTesting() = 0; |
| - virtual ShelfView* GetShelfViewForTesting() = 0; |
| + void SetKeyboardBoundsForTesting(const gfx::Rect& bounds); |
|
James Cook
2016/08/16 23:21:35
nit: Either keep the comment or rename to SetVirtu
msw
2016/08/17 01:09:01
Done (renamed for self-explanatory name).
|
| + ShelfLockingManager* GetShelfLockingManagerForTesting(); |
| + ShelfView* GetShelfViewForTesting(); |
| protected: |
| - virtual ~WmShelf() {} |
| + WmShelf(); |
| + ~WmShelf() override; |
| + |
| + // ShelfLayoutManagerObserver: |
| + void WillDeleteShelfLayoutManager() override; |
| + void WillChangeVisibilityState(ShelfVisibilityState new_state) override; |
| + void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; |
| + void OnBackgroundUpdated(ShelfBackgroundType background_type, |
| + BackgroundAnimatorChangeType change_type) override; |
| + |
| + private: |
| + // Legacy shelf controller. Null before login and in secondary display init. |
| + std::unique_ptr<Shelf> shelf_; |
| + |
| + // Cached separately because it may be destroyed before |shelf_|. |
| + ShelfLayoutManager* shelf_layout_manager_ = nullptr; |
| + |
| + base::ObserverList<WmShelfObserver> observers_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WmShelf); |
| }; |
| } // namespace ash |