| 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_COMMON_SHELF_WM_SHELF_H_ | 5 #ifndef ASH_COMMON_SHELF_WM_SHELF_H_ |
| 6 #define ASH_COMMON_SHELF_WM_SHELF_H_ | 6 #define ASH_COMMON_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/common/shelf/shelf_layout_manager_observer.h" | 11 #include "ash/common/shelf/shelf_layout_manager_observer.h" |
| 12 #include "ash/public/cpp/shelf_types.h" | 12 #include "ash/public/cpp/shelf_types.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 | 15 |
| 16 namespace gfx { | 16 namespace gfx { |
| 17 class Rect; | 17 class Rect; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace ui { | 20 namespace ui { |
| 21 class GestureEvent; | 21 class GestureEvent; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace ash { | 24 namespace ash { |
| 25 | 25 |
| 26 class ShelfBezelEventHandler; |
| 26 class ShelfLayoutManager; | 27 class ShelfLayoutManager; |
| 27 class ShelfLayoutManagerTest; | 28 class ShelfLayoutManagerTest; |
| 28 class ShelfLockingManager; | 29 class ShelfLockingManager; |
| 29 class ShelfView; | 30 class ShelfView; |
| 30 class ShelfWidget; | 31 class ShelfWidget; |
| 31 class StatusAreaWidget; | 32 class StatusAreaWidget; |
| 32 class WmShelfObserver; | 33 class WmShelfObserver; |
| 33 class WmWindow; | 34 class WmWindow; |
| 34 | 35 |
| 35 // Controller for the shelf state. Exists for the lifetime of each root window | 36 // Controller for the shelf state. Exists for the lifetime of each root window |
| 36 // controller. Note that the shelf widget may not be created until after login. | 37 // controller. Note that the shelf widget may not be created until after login. |
| 37 class ASH_EXPORT WmShelf : public ShelfLayoutManagerObserver { | 38 class ASH_EXPORT WmShelf : public ShelfLayoutManagerObserver { |
| 38 public: | 39 public: |
| 40 WmShelf(); |
| 41 ~WmShelf() override; |
| 42 |
| 39 // Returns the shelf for the display that |window| is on. Note that the shelf | 43 // Returns the shelf for the display that |window| is on. Note that the shelf |
| 40 // widget may not exist, or the shelf may not be visible. | 44 // widget may not exist, or the shelf may not be visible. |
| 41 static WmShelf* ForWindow(WmWindow* window); | 45 static WmShelf* ForWindow(WmWindow* window); |
| 42 | 46 |
| 43 // Returns if shelf alignment options are enabled, and the user is able to | 47 // Returns if shelf alignment options are enabled, and the user is able to |
| 44 // adjust the alignment (eg. not allowed in guest and supervised user modes). | 48 // adjust the alignment (eg. not allowed in guest and supervised user modes). |
| 45 static bool CanChangeShelfAlignment(); | 49 static bool CanChangeShelfAlignment(); |
| 46 | 50 |
| 47 virtual void CreateShelfWidget(WmWindow* root); | 51 void CreateShelfWidget(WmWindow* root); |
| 48 void ShutdownShelfWidget(); | 52 void ShutdownShelfWidget(); |
| 49 void DestroyShelfWidget(); | 53 void DestroyShelfWidget(); |
| 50 | 54 |
| 51 ShelfLayoutManager* shelf_layout_manager() const { | 55 ShelfLayoutManager* shelf_layout_manager() const { |
| 52 return shelf_layout_manager_; | 56 return shelf_layout_manager_; |
| 53 } | 57 } |
| 54 | 58 |
| 55 ShelfWidget* shelf_widget() { return shelf_widget_.get(); } | 59 ShelfWidget* shelf_widget() { return shelf_widget_.get(); } |
| 56 | 60 |
| 57 // Creates the shelf view. | 61 // Creates the shelf view. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 void RemoveObserver(WmShelfObserver* observer); | 133 void RemoveObserver(WmShelfObserver* observer); |
| 130 | 134 |
| 131 void NotifyShelfIconPositionsChanged(); | 135 void NotifyShelfIconPositionsChanged(); |
| 132 StatusAreaWidget* GetStatusAreaWidget() const; | 136 StatusAreaWidget* GetStatusAreaWidget() const; |
| 133 | 137 |
| 134 void SetVirtualKeyboardBoundsForTesting(const gfx::Rect& bounds); | 138 void SetVirtualKeyboardBoundsForTesting(const gfx::Rect& bounds); |
| 135 ShelfLockingManager* GetShelfLockingManagerForTesting(); | 139 ShelfLockingManager* GetShelfLockingManagerForTesting(); |
| 136 ShelfView* GetShelfViewForTesting(); | 140 ShelfView* GetShelfViewForTesting(); |
| 137 | 141 |
| 138 protected: | 142 protected: |
| 139 WmShelf(); | |
| 140 ~WmShelf() override; | |
| 141 | |
| 142 // ShelfLayoutManagerObserver: | 143 // ShelfLayoutManagerObserver: |
| 143 void WillDeleteShelfLayoutManager() override; | 144 void WillDeleteShelfLayoutManager() override; |
| 144 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; | 145 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; |
| 145 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; | 146 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; |
| 146 void OnBackgroundUpdated(ShelfBackgroundType background_type, | 147 void OnBackgroundUpdated(ShelfBackgroundType background_type, |
| 147 BackgroundAnimatorChangeType change_type) override; | 148 BackgroundAnimatorChangeType change_type) override; |
| 148 | 149 |
| 149 private: | 150 private: |
| 151 class AutoHideEventHandler; |
| 150 friend class ShelfLayoutManagerTest; | 152 friend class ShelfLayoutManagerTest; |
| 151 | 153 |
| 152 // Layout manager for the shelf container window. Instances are constructed by | 154 // Layout manager for the shelf container window. Instances are constructed by |
| 153 // ShelfWidget and lifetimes are managed by the container windows themselves. | 155 // ShelfWidget and lifetimes are managed by the container windows themselves. |
| 154 ShelfLayoutManager* shelf_layout_manager_ = nullptr; | 156 ShelfLayoutManager* shelf_layout_manager_ = nullptr; |
| 155 | 157 |
| 156 std::unique_ptr<ShelfWidget> shelf_widget_; | 158 std::unique_ptr<ShelfWidget> shelf_widget_; |
| 157 | 159 |
| 158 // Internal implementation detail. Do not expose externally. Owned by views | 160 // Internal implementation detail. Do not expose externally. Owned by views |
| 159 // hierarchy. Null before login and in secondary display init. | 161 // hierarchy. Null before login and in secondary display init. |
| 160 ShelfView* shelf_view_ = nullptr; | 162 ShelfView* shelf_view_ = nullptr; |
| 161 | 163 |
| 162 ShelfAlignment alignment_ = SHELF_ALIGNMENT_BOTTOM_LOCKED; | 164 ShelfAlignment alignment_ = SHELF_ALIGNMENT_BOTTOM_LOCKED; |
| 163 | 165 |
| 164 // Sets shelf alignment to bottom during login and screen lock. | 166 // Sets shelf alignment to bottom during login and screen lock. |
| 165 std::unique_ptr<ShelfLockingManager> shelf_locking_manager_; | 167 std::unique_ptr<ShelfLockingManager> shelf_locking_manager_; |
| 166 | 168 |
| 167 ShelfAutoHideBehavior auto_hide_behavior_ = SHELF_AUTO_HIDE_BEHAVIOR_NEVER; | 169 ShelfAutoHideBehavior auto_hide_behavior_ = SHELF_AUTO_HIDE_BEHAVIOR_NEVER; |
| 168 | 170 |
| 169 base::ObserverList<WmShelfObserver> observers_; | 171 base::ObserverList<WmShelfObserver> observers_; |
| 170 | 172 |
| 171 // Temporary. Used to investigate http://crbug.com/665093 . | 173 // Temporary. Used to investigate http://crbug.com/665093 . |
| 172 base::TimeTicks time_last_auto_hide_change_; | 174 base::TimeTicks time_last_auto_hide_change_; |
| 173 int count_auto_hide_changes_ = 0; | 175 int count_auto_hide_changes_ = 0; |
| 174 | 176 |
| 177 // Forwards mouse and gesture events to ShelfLayoutManager for auto-hide. |
| 178 // TODO(mash): Facilitate simliar functionality in mash: crbug.com/631216 |
| 179 std::unique_ptr<AutoHideEventHandler> auto_hide_event_handler_; |
| 180 |
| 181 // Forwards touch gestures on a bezel sensor to the shelf. |
| 182 // TODO(mash): Facilitate simliar functionality in mash: crbug.com/636647 |
| 183 std::unique_ptr<ShelfBezelEventHandler> bezel_event_handler_; |
| 184 |
| 175 DISALLOW_COPY_AND_ASSIGN(WmShelf); | 185 DISALLOW_COPY_AND_ASSIGN(WmShelf); |
| 176 }; | 186 }; |
| 177 | 187 |
| 178 } // namespace ash | 188 } // namespace ash |
| 179 | 189 |
| 180 #endif // ASH_COMMON_SHELF_WM_SHELF_H_ | 190 #endif // ASH_COMMON_SHELF_WM_SHELF_H_ |
| OLD | NEW |