| 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_SHELF_H_ | 5 #ifndef ASH_SHELF_SHELF_H_ |
| 6 #define ASH_SHELF_SHELF_H_ | 6 #define ASH_SHELF_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 "ash/shelf/shelf_locking_manager.h" |
| 14 #include "ash/shell_observer.h" |
| 14 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 15 | 16 |
| 16 namespace aura { | 17 namespace aura { |
| 17 class Window; | 18 class Window; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace gfx { | 21 namespace gfx { |
| 21 class Rect; | 22 class Rect; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace ui { | 25 namespace ui { |
| 25 class GestureEvent; | 26 class GestureEvent; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace ash { | 29 namespace ash { |
| 29 | 30 |
| 30 enum class AnimationChangeType; | 31 enum class AnimationChangeType; |
| 31 class ShelfBezelEventHandler; | 32 class ShelfBezelEventHandler; |
| 32 class ShelfLayoutManager; | 33 class ShelfLayoutManager; |
| 33 class ShelfLayoutManagerTest; | 34 class ShelfLayoutManagerTest; |
| 34 class ShelfLockingManager; | 35 class ShelfLockingManager; |
| 35 class ShelfView; | 36 class ShelfView; |
| 36 class ShelfWidget; | 37 class ShelfWidget; |
| 37 class StatusAreaWidget; | 38 class StatusAreaWidget; |
| 38 class ShelfObserver; | 39 class ShelfObserver; |
| 39 | 40 |
| 40 // Controller for the shelf state. One per display, because each display might | 41 // Controller for the shelf state. One per display, because each display might |
| 41 // have different shelf alignment, autohide, etc. Exists for the lifetime of the | 42 // have different shelf alignment, autohide, etc. Exists for the lifetime of the |
| 42 // root window controller. | 43 // root window controller. |
| 43 class ASH_EXPORT Shelf : public ShelfLayoutManagerObserver { | 44 class ASH_EXPORT Shelf : public ShelfLayoutManagerObserver, ShellObserver { |
| 44 public: | 45 public: |
| 45 Shelf(); | 46 Shelf(); |
| 46 ~Shelf() override; | 47 ~Shelf() override; |
| 47 | 48 |
| 48 // Returns the shelf for the display that |window| is on. Note that the shelf | 49 // Returns the shelf for the display that |window| is on. Note that the shelf |
| 49 // widget may not exist, or the shelf may not be visible. | 50 // widget may not exist, or the shelf may not be visible. |
| 50 static Shelf* ForWindow(aura::Window* window); | 51 static Shelf* ForWindow(aura::Window* window); |
| 51 | 52 |
| 52 // Returns if shelf alignment options are enabled, and the user is able to | 53 // Returns if shelf alignment options are enabled, and the user is able to |
| 53 // adjust the alignment (eg. not allowed in guest and supervised user modes). | 54 // adjust the alignment (eg. not allowed in guest and supervised user modes). |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 void AddObserver(ShelfObserver* observer); | 132 void AddObserver(ShelfObserver* observer); |
| 132 void RemoveObserver(ShelfObserver* observer); | 133 void RemoveObserver(ShelfObserver* observer); |
| 133 | 134 |
| 134 void NotifyShelfIconPositionsChanged(); | 135 void NotifyShelfIconPositionsChanged(); |
| 135 StatusAreaWidget* GetStatusAreaWidget() const; | 136 StatusAreaWidget* GetStatusAreaWidget() const; |
| 136 | 137 |
| 137 void SetVirtualKeyboardBoundsForTesting(const gfx::Rect& bounds); | 138 void SetVirtualKeyboardBoundsForTesting(const gfx::Rect& bounds); |
| 138 ShelfLockingManager* GetShelfLockingManagerForTesting(); | 139 ShelfLockingManager* GetShelfLockingManagerForTesting(); |
| 139 ShelfView* GetShelfViewForTesting(); | 140 ShelfView* GetShelfViewForTesting(); |
| 140 | 141 |
| 142 // Called when the app list status changes. |
| 143 void OnAppListIsActive(); |
| 144 |
| 141 protected: | 145 protected: |
| 142 // ShelfLayoutManagerObserver: | 146 // ShelfLayoutManagerObserver: |
| 143 void WillDeleteShelfLayoutManager() override; | 147 void WillDeleteShelfLayoutManager() override; |
| 144 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; | 148 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; |
| 145 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; | 149 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; |
| 146 void OnBackgroundUpdated(ShelfBackgroundType background_type, | 150 void OnBackgroundUpdated(ShelfBackgroundType background_type, |
| 147 AnimationChangeType change_type) override; | 151 AnimationChangeType change_type) override; |
| 148 | 152 |
| 149 private: | 153 private: |
| 150 class AutoHideEventHandler; | 154 class AutoHideEventHandler; |
| 151 friend class ShelfLayoutManagerTest; | 155 friend class ShelfLayoutManagerTest; |
| 152 | 156 |
| 157 // ShellObserver overrides: |
| 158 void OnAppListShownOrDismissed(bool shown, |
| 159 aura::Window* root_window) override; |
| 160 |
| 153 // Layout manager for the shelf container window. Instances are constructed by | 161 // Layout manager for the shelf container window. Instances are constructed by |
| 154 // ShelfWidget and lifetimes are managed by the container windows themselves. | 162 // ShelfWidget and lifetimes are managed by the container windows themselves. |
| 155 ShelfLayoutManager* shelf_layout_manager_ = nullptr; | 163 ShelfLayoutManager* shelf_layout_manager_ = nullptr; |
| 156 | 164 |
| 157 std::unique_ptr<ShelfWidget> shelf_widget_; | 165 std::unique_ptr<ShelfWidget> shelf_widget_; |
| 158 | 166 |
| 159 // These initial values hide the shelf until user preferences are available. | 167 // These initial values hide the shelf until user preferences are available. |
| 160 ShelfAlignment alignment_ = SHELF_ALIGNMENT_BOTTOM_LOCKED; | 168 ShelfAlignment alignment_ = SHELF_ALIGNMENT_BOTTOM_LOCKED; |
| 161 ShelfAutoHideBehavior auto_hide_behavior_ = SHELF_AUTO_HIDE_ALWAYS_HIDDEN; | 169 ShelfAutoHideBehavior auto_hide_behavior_ = SHELF_AUTO_HIDE_ALWAYS_HIDDEN; |
| 162 | 170 |
| 163 // Sets shelf alignment to bottom during login and screen lock. | 171 // Sets shelf alignment to bottom during login and screen lock. |
| 164 ShelfLockingManager shelf_locking_manager_; | 172 ShelfLockingManager shelf_locking_manager_; |
| 165 | 173 |
| 166 base::ObserverList<ShelfObserver> observers_; | 174 base::ObserverList<ShelfObserver> observers_; |
| 167 | 175 |
| 168 // Forwards mouse and gesture events to ShelfLayoutManager for auto-hide. | 176 // Forwards mouse and gesture events to ShelfLayoutManager for auto-hide. |
| 169 // TODO(mash): Facilitate simliar functionality in mash: crbug.com/631216 | 177 // TODO(mash): Facilitate simliar functionality in mash: crbug.com/631216 |
| 170 std::unique_ptr<AutoHideEventHandler> auto_hide_event_handler_; | 178 std::unique_ptr<AutoHideEventHandler> auto_hide_event_handler_; |
| 171 | 179 |
| 172 // Forwards touch gestures on a bezel sensor to the shelf. | 180 // Forwards touch gestures on a bezel sensor to the shelf. |
| 173 // TODO(mash): Facilitate simliar functionality in mash: crbug.com/636647 | 181 // TODO(mash): Facilitate simliar functionality in mash: crbug.com/636647 |
| 174 std::unique_ptr<ShelfBezelEventHandler> bezel_event_handler_; | 182 std::unique_ptr<ShelfBezelEventHandler> bezel_event_handler_; |
| 175 | 183 |
| 176 DISALLOW_COPY_AND_ASSIGN(Shelf); | 184 DISALLOW_COPY_AND_ASSIGN(Shelf); |
| 177 }; | 185 }; |
| 178 | 186 |
| 179 } // namespace ash | 187 } // namespace ash |
| 180 | 188 |
| 181 #endif // ASH_SHELF_SHELF_H_ | 189 #endif // ASH_SHELF_SHELF_H_ |
| OLD | NEW |