OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 5 #ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 29 matching lines...) Expand all Loading... | |
40 | 40 |
41 // There are different methods for creating bubble views. | 41 // There are different methods for creating bubble views. |
42 enum BubbleCreationType { | 42 enum BubbleCreationType { |
43 BUBBLE_CREATE_NEW, // Closes any existing bubble and creates a new one. | 43 BUBBLE_CREATE_NEW, // Closes any existing bubble and creates a new one. |
44 BUBBLE_USE_EXISTING, // Uses any existing bubble, or creates a new one. | 44 BUBBLE_USE_EXISTING, // Uses any existing bubble, or creates a new one. |
45 }; | 45 }; |
46 | 46 |
47 class ASH_EXPORT SystemTray : public TrayBackgroundView, | 47 class ASH_EXPORT SystemTray : public TrayBackgroundView, |
48 public views::TrayBubbleView::Delegate { | 48 public views::TrayBubbleView::Delegate { |
49 public: | 49 public: |
50 // The threshold of the velocity of the fling event. | |
51 static constexpr float kFlingVelocity = 100.0f; | |
52 | 50 |
53 explicit SystemTray(Shelf* shelf); | 51 explicit SystemTray(Shelf* shelf); |
54 ~SystemTray() override; | 52 ~SystemTray() override; |
55 | 53 |
56 TrayUpdate* tray_update() { return tray_update_; } | 54 TrayUpdate* tray_update() { return tray_update_; } |
57 | 55 |
58 TrayNightLight* tray_night_light() { return tray_night_light_; } | 56 TrayNightLight* tray_night_light() { return tray_night_light_; } |
59 | 57 |
60 // Calls TrayBackgroundView::Initialize(), creates the tray items, and | 58 // Calls TrayBackgroundView::Initialize(), creates the tray items, and |
61 // adds them to SystemTrayNotifier. | 59 // adds them to SystemTrayNotifier. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 // Returns true if the system_bubble_ exists and is of type |type|. | 106 // Returns true if the system_bubble_ exists and is of type |type|. |
109 bool HasSystemBubbleType(SystemTrayBubble::BubbleType type); | 107 bool HasSystemBubbleType(SystemTrayBubble::BubbleType type); |
110 | 108 |
111 // Returns a pointer to the system bubble or NULL if none. | 109 // Returns a pointer to the system bubble or NULL if none. |
112 SystemTrayBubble* GetSystemBubble(); | 110 SystemTrayBubble* GetSystemBubble(); |
113 | 111 |
114 // Returns true if system bubble is visible. | 112 // Returns true if system bubble is visible. |
115 bool IsSystemBubbleVisible() const; | 113 bool IsSystemBubbleVisible() const; |
116 | 114 |
117 // Closes system bubble and returns true if it did exist. | 115 // Closes system bubble and returns true if it did exist. |
118 bool CloseSystemBubble() const; | 116 bool CloseSystemBubble() const; |
msw
2017/07/12 05:04:51
Remove this function, as it's now redundant with C
minch1
2017/07/13 19:10:35
Added TODO, will do it in another CL soon.http://c
msw
2017/07/14 02:00:45
Acknowledged, thanks in advance.
| |
119 | 117 |
120 // Returns view for help button if default view is shown. Returns NULL | 118 // Returns view for help button if default view is shown. Returns NULL |
121 // otherwise. | 119 // otherwise. |
122 views::View* GetHelpButtonView() const; | 120 views::View* GetHelpButtonView() const; |
123 | 121 |
124 // Returns TrayAudio object if present or null otherwise. | 122 // Returns TrayAudio object if present or null otherwise. |
125 TrayAudio* GetTrayAudio() const; | 123 TrayAudio* GetTrayAudio() const; |
126 | 124 |
127 // Overridden from TrayBackgroundView. | 125 // Overridden from TrayBackgroundView. |
128 void UpdateAfterShelfAlignmentChange() override; | 126 void UpdateAfterShelfAlignmentChange() override; |
129 void AnchorUpdated() override; | 127 void AnchorUpdated() override; |
130 base::string16 GetAccessibleNameForTray() override; | 128 base::string16 GetAccessibleNameForTray() override; |
131 void BubbleResized(const views::TrayBubbleView* bubble_view) override; | 129 void BubbleResized(const views::TrayBubbleView* bubble_view) override; |
132 void HideBubbleWithView(const views::TrayBubbleView* bubble_view) override; | 130 void HideBubbleWithView(const views::TrayBubbleView* bubble_view) override; |
133 void ClickedOutsideBubble() override; | 131 void ClickedOutsideBubble() override; |
132 bool PerformAction(const ui::Event& event) override; | |
133 bool HasBubble() override; | |
134 void CloseBubble() override; | |
135 void ShowBubble() override; | |
136 views::TrayBubbleView* GetBubbleView() override; | |
134 | 137 |
135 // views::TrayBubbleView::Delegate: | 138 // views::TrayBubbleView::Delegate: |
136 void BubbleViewDestroyed() override; | 139 void BubbleViewDestroyed() override; |
137 void OnMouseEnteredView() override; | 140 void OnMouseEnteredView() override; |
138 void OnMouseExitedView() override; | 141 void OnMouseExitedView() override; |
139 void RegisterAccelerators(const std::vector<ui::Accelerator>& accelerators, | 142 void RegisterAccelerators(const std::vector<ui::Accelerator>& accelerators, |
140 views::TrayBubbleView* tray_bubble_view) override; | 143 views::TrayBubbleView* tray_bubble_view) override; |
141 void UnregisterAllAccelerators( | 144 void UnregisterAllAccelerators( |
142 views::TrayBubbleView* tray_bubble_view) override; | 145 views::TrayBubbleView* tray_bubble_view) override; |
143 base::string16 GetAccessibleNameForBubble() override; | 146 base::string16 GetAccessibleNameForBubble() override; |
144 bool ShouldEnableExtraKeyboardAccessibility() override; | 147 bool ShouldEnableExtraKeyboardAccessibility() override; |
145 void HideBubble(const views::TrayBubbleView* bubble_view) override; | 148 void HideBubble(const views::TrayBubbleView* bubble_view) override; |
149 bool ProcessGestureEventForBubble(ui::GestureEvent* event) override; | |
150 | |
151 // ui::EventHandler: | |
152 void OnGestureEvent(ui::GestureEvent* event) override; | |
146 | 153 |
147 ScreenTrayItem* GetScreenShareItem() { return screen_share_tray_item_; } | 154 ScreenTrayItem* GetScreenShareItem() { return screen_share_tray_item_; } |
148 ScreenTrayItem* GetScreenCaptureItem() { return screen_capture_tray_item_; } | 155 ScreenTrayItem* GetScreenCaptureItem() { return screen_capture_tray_item_; } |
149 | 156 |
150 // Activates the system tray bubble. | 157 // Activates the system tray bubble. |
151 void ActivateBubble(); | 158 void ActivateBubble(); |
152 | 159 |
153 // ui::EventHandler: | |
154 void OnGestureEvent(ui::GestureEvent* event) override; | |
155 | |
156 gfx::Rect GetWorkAreaBoundsInScreen() const; | |
157 | |
158 private: | 160 private: |
159 friend class SystemTrayTestApi; | 161 friend class SystemTrayTestApi; |
160 class ActivationObserver; | 162 class ActivationObserver; |
161 | 163 |
162 // Closes the bubble. Used to bind as a KeyEventWatcher::KeyEventCallback. | 164 // Closes the bubble. Used to bind as a KeyEventWatcher::KeyEventCallback. |
163 void CloseBubble(const ui::KeyEvent& key_event); | 165 void CloseBubble(const ui::KeyEvent& key_event); |
164 | 166 |
165 // Activates the bubble and starts key navigation with the |key_event|. | 167 // Activates the bubble and starts key navigation with the |key_event|. |
166 void ActivateAndStartNavigation(const ui::KeyEvent& key_event); | 168 void ActivateAndStartNavigation(const ui::KeyEvent& key_event); |
167 | 169 |
(...skipping 24 matching lines...) Expand all Loading... | |
192 // notification tray according to the current status. | 194 // notification tray according to the current status. |
193 void UpdateWebNotifications(); | 195 void UpdateWebNotifications(); |
194 | 196 |
195 // Deactivate the system tray in the shelf if it was active before. | 197 // Deactivate the system tray in the shelf if it was active before. |
196 void CloseSystemBubbleAndDeactivateSystemTray(); | 198 void CloseSystemBubbleAndDeactivateSystemTray(); |
197 | 199 |
198 // Records UMA metrics for the number of user-visible rows in the system menu | 200 // Records UMA metrics for the number of user-visible rows in the system menu |
199 // and the percentage of the work area height covered by the system menu. | 201 // and the percentage of the work area height covered by the system menu. |
200 void RecordSystemMenuMetrics(); | 202 void RecordSystemMenuMetrics(); |
201 | 203 |
202 // Overridden from ActionableView. | |
203 bool PerformAction(const ui::Event& event) override; | |
204 | |
205 // Gesture related functions: | |
206 bool ProcessGestureEvent(const ui::GestureEvent& event); | |
207 bool StartGestureDrag(const ui::GestureEvent& gesture); | |
208 void UpdateGestureDrag(const ui::GestureEvent& gesture); | |
209 void CompleteGestureDrag(const ui::GestureEvent& gesture); | |
210 | |
211 // Update the bounds of the system tray bubble according to |location|. Note | |
212 // that |location| is in the local coordinate space of |this|. | |
213 void SetBubbleBounds(const gfx::Point& location); | |
214 | |
215 // Return true if the system bubble should be shown (i.e., animated upward to | |
216 // be made fully visible) after a sequence of scroll events terminated by | |
217 // |sequence_end|. Otherwise return false, indicating that the | |
218 // partially-visible system bubble should be animated downward and made fully | |
219 // hidden. | |
220 bool ShouldShowSystemBubbleAfterScrollSequence( | |
221 const ui::GestureEvent& sequence_end); | |
222 | |
223 // Shelf the system tray is in. | |
224 Shelf* const shelf_; | |
225 | |
226 // The original bounds of the system tray bubble. | |
227 gfx::Rect system_tray_bubble_bounds_; | |
228 | |
229 // Tracks the amount of the drag. Only valid if |is_in_drag_| is true. | |
230 float gesture_drag_amount_ = 0.f; | |
231 | |
232 // True if the user is in the process of gesture-dragging to open the system | |
233 // tray bubble, false otherwise. | |
234 bool is_in_drag_ = false; | |
235 | |
236 // The web notification tray view that appears adjacent to this view. | 204 // The web notification tray view that appears adjacent to this view. |
237 WebNotificationTray* web_notification_tray_ = nullptr; | 205 WebNotificationTray* web_notification_tray_ = nullptr; |
238 | 206 |
239 // Items. | 207 // Items. |
240 std::vector<std::unique_ptr<SystemTrayItem>> items_; | 208 std::vector<std::unique_ptr<SystemTrayItem>> items_; |
241 | 209 |
242 // Pointers to members of |items_|. | 210 // Pointers to members of |items_|. |
243 SystemTrayItem* detailed_item_ = nullptr; | 211 SystemTrayItem* detailed_item_ = nullptr; |
244 | 212 |
245 // Bubble for default and detailed views. | 213 // Bubble for default and detailed views. |
(...skipping 28 matching lines...) Expand all Loading... | |
274 ScreenTrayItem* screen_share_tray_item_ = nullptr; // not owned | 242 ScreenTrayItem* screen_share_tray_item_ = nullptr; // not owned |
275 | 243 |
276 std::unique_ptr<ActivationObserver> activation_observer_; | 244 std::unique_ptr<ActivationObserver> activation_observer_; |
277 | 245 |
278 DISALLOW_COPY_AND_ASSIGN(SystemTray); | 246 DISALLOW_COPY_AND_ASSIGN(SystemTray); |
279 }; | 247 }; |
280 | 248 |
281 } // namespace ash | 249 } // namespace ash |
282 | 250 |
283 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 251 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
OLD | NEW |