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> |
| 9 |
8 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
9 #include "ash/common/shelf/shelf_layout_manager_observer.h" | 11 #include "ash/common/shelf/shelf_layout_manager_observer.h" |
10 #include "ash/common/shelf/shelf_types.h" | 12 #include "ash/common/shelf/shelf_types.h" |
11 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
12 | 14 |
13 namespace gfx { | 15 namespace gfx { |
14 class Rect; | 16 class Rect; |
15 } | 17 } |
16 | 18 |
17 namespace ui { | 19 namespace ui { |
18 class GestureEvent; | 20 class GestureEvent; |
19 } | 21 } |
20 | 22 |
21 namespace ash { | 23 namespace ash { |
22 | 24 |
23 class Shelf; | 25 class Shelf; |
24 class ShelfLayoutManager; | 26 class ShelfLayoutManager; |
25 class ShelfLockingManager; | 27 class ShelfLockingManager; |
26 class ShelfView; | 28 class ShelfView; |
| 29 class ShelfWidget; |
27 class StatusAreaWidget; | 30 class StatusAreaWidget; |
28 class WmDimmerView; | 31 class WmDimmerView; |
29 class WmShelfObserver; | 32 class WmShelfObserver; |
30 class WmWindow; | 33 class WmWindow; |
31 | 34 |
32 // Used for accessing global state. | 35 // 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. |
33 class ASH_EXPORT WmShelf : public ShelfLayoutManagerObserver { | 37 class ASH_EXPORT WmShelf : public ShelfLayoutManagerObserver { |
34 public: | 38 public: |
35 void SetShelf(Shelf* shelf); | 39 void SetShelf(Shelf* shelf); |
36 void ClearShelf(); | 40 void ClearShelf(); |
37 Shelf* shelf() const { return shelf_; } | 41 Shelf* shelf() const { return shelf_; } |
38 | 42 |
39 virtual void SetShelfLayoutManager(ShelfLayoutManager* manager); | 43 virtual void SetShelfLayoutManager(ShelfLayoutManager* manager); |
40 ShelfLayoutManager* shelf_layout_manager() const { | 44 ShelfLayoutManager* shelf_layout_manager() const { |
41 return shelf_layout_manager_; | 45 return shelf_layout_manager_; |
42 } | 46 } |
43 | 47 |
44 // Returns the window showing the shelf. | 48 // Returns the window showing the shelf. |
45 WmWindow* GetWindow(); | 49 WmWindow* GetWindow(); |
46 | 50 |
47 ShelfAlignment GetAlignment() const; | 51 ShelfAlignment alignment() const { return alignment_; } |
| 52 // TODO(jamescook): Replace with alignment(). |
| 53 ShelfAlignment GetAlignment() const { return alignment_; } |
48 void SetAlignment(ShelfAlignment alignment); | 54 void SetAlignment(ShelfAlignment alignment); |
49 | 55 |
50 // Returns true if the shelf alignment is horizontal (i.e. at the bottom). | 56 // Returns true if the shelf alignment is horizontal (i.e. at the bottom). |
51 bool IsHorizontalAlignment() const; | 57 bool IsHorizontalAlignment() const; |
52 | 58 |
53 // Returns a value based on shelf alignment. | 59 // Returns a value based on shelf alignment. |
54 int SelectValueForShelfAlignment(int bottom, int left, int right) const; | 60 int SelectValueForShelfAlignment(int bottom, int left, int right) const; |
55 | 61 |
56 // Returns |horizontal| is shelf is horizontal, otherwise |vertical|. | 62 // Returns |horizontal| is shelf is horizontal, otherwise |vertical|. |
57 int PrimaryAxisValue(int horizontal, int vertical) const; | 63 int PrimaryAxisValue(int horizontal, int vertical) const; |
58 | 64 |
59 ShelfAutoHideBehavior GetAutoHideBehavior() const; | 65 ShelfAutoHideBehavior auto_hide_behavior() const { |
| 66 return auto_hide_behavior_; |
| 67 } |
60 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); | 68 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); |
61 | 69 |
62 ShelfAutoHideState GetAutoHideState() const; | 70 ShelfAutoHideState GetAutoHideState() const; |
63 | 71 |
64 // Invoke when the auto-hide state may have changed (for example, when the | 72 // Invoke when the auto-hide state may have changed (for example, when the |
65 // system tray bubble opens it should force the shelf to be visible). | 73 // system tray bubble opens it should force the shelf to be visible). |
66 void UpdateAutoHideState(); | 74 void UpdateAutoHideState(); |
67 | 75 |
68 ShelfBackgroundType GetBackgroundType() const; | 76 ShelfBackgroundType GetBackgroundType() const; |
69 | 77 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 113 |
106 void AddObserver(WmShelfObserver* observer); | 114 void AddObserver(WmShelfObserver* observer); |
107 void RemoveObserver(WmShelfObserver* observer); | 115 void RemoveObserver(WmShelfObserver* observer); |
108 | 116 |
109 void NotifyShelfIconPositionsChanged(); | 117 void NotifyShelfIconPositionsChanged(); |
110 StatusAreaWidget* GetStatusAreaWidget() const; | 118 StatusAreaWidget* GetStatusAreaWidget() const; |
111 | 119 |
112 void SetVirtualKeyboardBoundsForTesting(const gfx::Rect& bounds); | 120 void SetVirtualKeyboardBoundsForTesting(const gfx::Rect& bounds); |
113 ShelfLockingManager* GetShelfLockingManagerForTesting(); | 121 ShelfLockingManager* GetShelfLockingManagerForTesting(); |
114 ShelfView* GetShelfViewForTesting(); | 122 ShelfView* GetShelfViewForTesting(); |
| 123 ShelfWidget* GetShelfWidgetForTesting(); |
115 | 124 |
116 protected: | 125 protected: |
117 WmShelf(); | 126 WmShelf(); |
118 ~WmShelf() override; | 127 ~WmShelf() override; |
119 | 128 |
120 // ShelfLayoutManagerObserver: | 129 // ShelfLayoutManagerObserver: |
121 void WillDeleteShelfLayoutManager() override; | 130 void WillDeleteShelfLayoutManager() override; |
122 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; | 131 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; |
123 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; | 132 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override; |
124 void OnBackgroundUpdated(ShelfBackgroundType background_type, | 133 void OnBackgroundUpdated(ShelfBackgroundType background_type, |
125 BackgroundAnimatorChangeType change_type) override; | 134 BackgroundAnimatorChangeType change_type) override; |
126 | 135 |
127 private: | 136 private: |
128 // Legacy shelf controller. Null before login and in secondary display init. | 137 // Legacy shelf controller. Null before login and in secondary display init. |
129 // Instance lifetimes are managed by ash::RootWindowController and WmShelfMus. | 138 // Instance lifetimes are managed by ash::RootWindowController and WmShelfMus. |
130 Shelf* shelf_ = nullptr; | 139 Shelf* shelf_ = nullptr; |
131 | 140 |
132 // Layout manager for the shelf container window. Instances are constructed by | 141 // Layout manager for the shelf container window. Instances are constructed by |
133 // ShelfWidget and lifetimes are managed by the container windows themselves. | 142 // ShelfWidget and lifetimes are managed by the container windows themselves. |
134 ShelfLayoutManager* shelf_layout_manager_ = nullptr; | 143 ShelfLayoutManager* shelf_layout_manager_ = nullptr; |
135 | 144 |
| 145 ShelfAlignment alignment_ = SHELF_ALIGNMENT_BOTTOM_LOCKED; |
| 146 |
| 147 // Sets shelf alignment to bottom during login and screen lock. |
| 148 std::unique_ptr<ShelfLockingManager> shelf_locking_manager_; |
| 149 |
| 150 ShelfAutoHideBehavior auto_hide_behavior_ = SHELF_AUTO_HIDE_BEHAVIOR_NEVER; |
| 151 |
136 base::ObserverList<WmShelfObserver> observers_; | 152 base::ObserverList<WmShelfObserver> observers_; |
137 | 153 |
138 DISALLOW_COPY_AND_ASSIGN(WmShelf); | 154 DISALLOW_COPY_AND_ASSIGN(WmShelf); |
139 }; | 155 }; |
140 | 156 |
141 } // namespace ash | 157 } // namespace ash |
142 | 158 |
143 #endif // ASH_COMMON_SHELF_WM_SHELF_H_ | 159 #endif // ASH_COMMON_SHELF_WM_SHELF_H_ |
OLD | NEW |