| 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 #ifndef ASH_SHELF_WM_SHELF_H_ | 5 #ifndef ASH_SHELF_WM_SHELF_H_ |
| 6 #define ASH_SHELF_WM_SHELF_H_ | 6 #define ASH_SHELF_WM_SHELF_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "ash/public/cpp/shelf_types.h" | 11 #include "ash/public/cpp/shelf_types.h" |
| 12 #include "ash/shelf/shelf_layout_manager_observer.h" | 12 #include "ash/shelf/shelf_layout_manager_observer.h" |
| 13 #include "ash/shelf/shelf_locking_manager.h" |
| 13 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 class Rect; | 17 class Rect; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace ui { | 20 namespace ui { |
| 20 class GestureEvent; | 21 class GestureEvent; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace ash { | 24 namespace ash { |
| 24 | 25 |
| 25 enum class AnimationChangeType; | 26 enum class AnimationChangeType; |
| 26 class ShelfBezelEventHandler; | 27 class ShelfBezelEventHandler; |
| 27 class ShelfLayoutManager; | 28 class ShelfLayoutManager; |
| 28 class ShelfLayoutManagerTest; | 29 class ShelfLayoutManagerTest; |
| 29 class ShelfLockingManager; | 30 class ShelfLockingManager; |
| 30 class ShelfView; | 31 class ShelfView; |
| 31 class ShelfWidget; | 32 class ShelfWidget; |
| 32 class StatusAreaWidget; | 33 class StatusAreaWidget; |
| 33 class WmShelfObserver; | 34 class WmShelfObserver; |
| 34 class WmWindow; | 35 class WmWindow; |
| 35 | 36 |
| 36 // Controller for the shelf state. Exists for the lifetime of each root window | 37 // Controller for the shelf state. One per display, because each display might |
| 37 // controller. Note that the shelf widget may not be created until after login. | 38 // have different shelf alignment, autohide, etc. Exists for the lifetime of the |
| 39 // root window controller. |
| 38 class ASH_EXPORT WmShelf : public ShelfLayoutManagerObserver { | 40 class ASH_EXPORT WmShelf : public ShelfLayoutManagerObserver { |
| 39 public: | 41 public: |
| 40 WmShelf(); | 42 WmShelf(); |
| 41 ~WmShelf() override; | 43 ~WmShelf() override; |
| 42 | 44 |
| 43 // Returns the shelf for the display that |window| is on. Note that the shelf | 45 // Returns the shelf for the display that |window| is on. Note that the shelf |
| 44 // widget may not exist, or the shelf may not be visible. | 46 // widget may not exist, or the shelf may not be visible. |
| 45 static WmShelf* ForWindow(WmWindow* window); | 47 static WmShelf* ForWindow(WmWindow* window); |
| 46 | 48 |
| 47 // Returns if shelf alignment options are enabled, and the user is able to | 49 // Returns if shelf alignment options are enabled, and the user is able to |
| 48 // adjust the alignment (eg. not allowed in guest and supervised user modes). | 50 // adjust the alignment (eg. not allowed in guest and supervised user modes). |
| 49 static bool CanChangeShelfAlignment(); | 51 static bool CanChangeShelfAlignment(); |
| 50 | 52 |
| 51 void CreateShelfWidget(WmWindow* root); | 53 void CreateShelfWidget(WmWindow* root); |
| 52 void ShutdownShelfWidget(); | 54 void ShutdownShelfWidget(); |
| 53 void DestroyShelfWidget(); | 55 void DestroyShelfWidget(); |
| 54 | 56 |
| 55 ShelfLayoutManager* shelf_layout_manager() const { | 57 ShelfLayoutManager* shelf_layout_manager() const { |
| 56 return shelf_layout_manager_; | 58 return shelf_layout_manager_; |
| 57 } | 59 } |
| 58 | 60 |
| 59 ShelfWidget* shelf_widget() { return shelf_widget_.get(); } | 61 ShelfWidget* shelf_widget() { return shelf_widget_.get(); } |
| 60 | 62 |
| 61 // Creates the shelf view. | |
| 62 void CreateShelfView(); | |
| 63 | |
| 64 // TODO(jamescook): Eliminate this method. | 63 // TODO(jamescook): Eliminate this method. |
| 65 void ShutdownShelf(); | 64 void NotifyShelfInitialized(); |
| 66 | |
| 67 // True after the ShelfView has been created (e.g. after login). | |
| 68 bool IsShelfInitialized() const; | |
| 69 | 65 |
| 70 // Returns the window showing the shelf. | 66 // Returns the window showing the shelf. |
| 71 WmWindow* GetWindow(); | 67 WmWindow* GetWindow(); |
| 72 | 68 |
| 73 ShelfAlignment alignment() const { return alignment_; } | 69 ShelfAlignment alignment() const { return alignment_; } |
| 74 // TODO(jamescook): Replace with alignment(). | 70 // TODO(jamescook): Replace with alignment(). |
| 75 ShelfAlignment GetAlignment() const { return alignment_; } | 71 ShelfAlignment GetAlignment() const { return alignment_; } |
| 76 void SetAlignment(ShelfAlignment alignment); | 72 void SetAlignment(ShelfAlignment alignment); |
| 77 | 73 |
| 78 // Returns true if the shelf alignment is horizontal (i.e. at the bottom). | 74 // Returns true if the shelf alignment is horizontal (i.e. at the bottom). |
| (...skipping 11 matching lines...) Expand all Loading... |
| 90 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); | 86 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); |
| 91 | 87 |
| 92 ShelfAutoHideState GetAutoHideState() const; | 88 ShelfAutoHideState GetAutoHideState() const; |
| 93 | 89 |
| 94 // Invoke when the auto-hide state may have changed (for example, when the | 90 // Invoke when the auto-hide state may have changed (for example, when the |
| 95 // system tray bubble opens it should force the shelf to be visible). | 91 // system tray bubble opens it should force the shelf to be visible). |
| 96 void UpdateAutoHideState(); | 92 void UpdateAutoHideState(); |
| 97 | 93 |
| 98 ShelfBackgroundType GetBackgroundType() const; | 94 ShelfBackgroundType GetBackgroundType() const; |
| 99 | 95 |
| 100 // Whether the shelf view is visible. | |
| 101 // TODO(jamescook): Consolidate this with GetVisibilityState(). | |
| 102 bool IsVisible() const; | |
| 103 | |
| 104 void UpdateVisibilityState(); | 96 void UpdateVisibilityState(); |
| 105 | 97 |
| 106 ShelfVisibilityState GetVisibilityState() const; | 98 ShelfVisibilityState GetVisibilityState() const; |
| 107 | 99 |
| 108 // Returns the ideal bounds of the shelf assuming it is visible. | 100 // Returns the ideal bounds of the shelf assuming it is visible. |
| 109 gfx::Rect GetIdealBounds(); | 101 gfx::Rect GetIdealBounds(); |
| 110 | 102 |
| 111 gfx::Rect GetUserWorkAreaBounds() const; | 103 gfx::Rect GetUserWorkAreaBounds() const; |
| 112 | 104 |
| 113 // Updates the icon position given the current window bounds. This is used | 105 // Updates the icon position given the current window bounds. This is used |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 private: | 144 private: |
| 153 class AutoHideEventHandler; | 145 class AutoHideEventHandler; |
| 154 friend class ShelfLayoutManagerTest; | 146 friend class ShelfLayoutManagerTest; |
| 155 | 147 |
| 156 // Layout manager for the shelf container window. Instances are constructed by | 148 // Layout manager for the shelf container window. Instances are constructed by |
| 157 // ShelfWidget and lifetimes are managed by the container windows themselves. | 149 // ShelfWidget and lifetimes are managed by the container windows themselves. |
| 158 ShelfLayoutManager* shelf_layout_manager_ = nullptr; | 150 ShelfLayoutManager* shelf_layout_manager_ = nullptr; |
| 159 | 151 |
| 160 std::unique_ptr<ShelfWidget> shelf_widget_; | 152 std::unique_ptr<ShelfWidget> shelf_widget_; |
| 161 | 153 |
| 162 // Internal implementation detail. Do not expose externally. Owned by views | |
| 163 // hierarchy. Null before login and in secondary display init. | |
| 164 ShelfView* shelf_view_ = nullptr; | |
| 165 | |
| 166 // These initial values hide the shelf until user preferences are available. | 154 // These initial values hide the shelf until user preferences are available. |
| 167 ShelfAlignment alignment_ = SHELF_ALIGNMENT_BOTTOM_LOCKED; | 155 ShelfAlignment alignment_ = SHELF_ALIGNMENT_BOTTOM_LOCKED; |
| 168 ShelfAutoHideBehavior auto_hide_behavior_ = SHELF_AUTO_HIDE_ALWAYS_HIDDEN; | 156 ShelfAutoHideBehavior auto_hide_behavior_ = SHELF_AUTO_HIDE_ALWAYS_HIDDEN; |
| 169 | 157 |
| 170 // Sets shelf alignment to bottom during login and screen lock. | 158 // Sets shelf alignment to bottom during login and screen lock. |
| 171 std::unique_ptr<ShelfLockingManager> shelf_locking_manager_; | 159 ShelfLockingManager shelf_locking_manager_; |
| 172 | 160 |
| 173 base::ObserverList<WmShelfObserver> observers_; | 161 base::ObserverList<WmShelfObserver> observers_; |
| 174 | 162 |
| 175 // Forwards mouse and gesture events to ShelfLayoutManager for auto-hide. | 163 // Forwards mouse and gesture events to ShelfLayoutManager for auto-hide. |
| 176 // TODO(mash): Facilitate simliar functionality in mash: crbug.com/631216 | 164 // TODO(mash): Facilitate simliar functionality in mash: crbug.com/631216 |
| 177 std::unique_ptr<AutoHideEventHandler> auto_hide_event_handler_; | 165 std::unique_ptr<AutoHideEventHandler> auto_hide_event_handler_; |
| 178 | 166 |
| 179 // Forwards touch gestures on a bezel sensor to the shelf. | 167 // Forwards touch gestures on a bezel sensor to the shelf. |
| 180 // TODO(mash): Facilitate simliar functionality in mash: crbug.com/636647 | 168 // TODO(mash): Facilitate simliar functionality in mash: crbug.com/636647 |
| 181 std::unique_ptr<ShelfBezelEventHandler> bezel_event_handler_; | 169 std::unique_ptr<ShelfBezelEventHandler> bezel_event_handler_; |
| 182 | 170 |
| 183 DISALLOW_COPY_AND_ASSIGN(WmShelf); | 171 DISALLOW_COPY_AND_ASSIGN(WmShelf); |
| 184 }; | 172 }; |
| 185 | 173 |
| 186 } // namespace ash | 174 } // namespace ash |
| 187 | 175 |
| 188 #endif // ASH_SHELF_WM_SHELF_H_ | 176 #endif // ASH_SHELF_WM_SHELF_H_ |
| OLD | NEW |