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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
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 // 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 void CloseBubble() override; |
| 134 void ShowBubble() override; |
| 135 views::TrayBubbleView* GetBubbleView() override; |
| 136 void OnGestureEvent(ui::GestureEvent* event) 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; |
146 | 150 |
147 ScreenTrayItem* GetScreenShareItem() { return screen_share_tray_item_; } | 151 ScreenTrayItem* GetScreenShareItem() { return screen_share_tray_item_; } |
148 ScreenTrayItem* GetScreenCaptureItem() { return screen_capture_tray_item_; } | 152 ScreenTrayItem* GetScreenCaptureItem() { return screen_capture_tray_item_; } |
149 | 153 |
150 // Activates the system tray bubble. | 154 // Activates the system tray bubble. |
151 void ActivateBubble(); | 155 void ActivateBubble(); |
152 | 156 |
153 // ui::EventHandler: | |
154 void OnGestureEvent(ui::GestureEvent* event) override; | |
155 | |
156 gfx::Rect GetWorkAreaBoundsInScreen() const; | |
157 | |
158 private: | 157 private: |
159 friend class SystemTrayTestApi; | 158 friend class SystemTrayTestApi; |
160 class ActivationObserver; | 159 class ActivationObserver; |
161 | 160 |
162 // Activates the bubble and starts key navigation with the |key_event|. | 161 // Activates the bubble and starts key navigation with the |key_event|. |
163 void ActivateAndStartNavigation(const ui::KeyEvent& key_event); | 162 void ActivateAndStartNavigation(const ui::KeyEvent& key_event); |
164 | 163 |
165 // Creates the default set of items for the sytem tray. | 164 // Creates the default set of items for the sytem tray. |
166 void CreateItems(SystemTrayDelegate* delegate); | 165 void CreateItems(SystemTrayDelegate* delegate); |
167 | 166 |
(...skipping 21 matching lines...) Expand all Loading... |
189 // notification tray according to the current status. | 188 // notification tray according to the current status. |
190 void UpdateWebNotifications(); | 189 void UpdateWebNotifications(); |
191 | 190 |
192 // Deactivate the system tray in the shelf if it was active before. | 191 // Deactivate the system tray in the shelf if it was active before. |
193 void CloseSystemBubbleAndDeactivateSystemTray(); | 192 void CloseSystemBubbleAndDeactivateSystemTray(); |
194 | 193 |
195 // Records UMA metrics for the number of user-visible rows in the system menu | 194 // Records UMA metrics for the number of user-visible rows in the system menu |
196 // and the percentage of the work area height covered by the system menu. | 195 // and the percentage of the work area height covered by the system menu. |
197 void RecordSystemMenuMetrics(); | 196 void RecordSystemMenuMetrics(); |
198 | 197 |
199 // Overridden from ActionableView. | |
200 bool PerformAction(const ui::Event& event) override; | |
201 | |
202 // Gesture related functions: | |
203 bool ProcessGestureEvent(const ui::GestureEvent& event); | |
204 bool StartGestureDrag(const ui::GestureEvent& gesture); | |
205 void UpdateGestureDrag(const ui::GestureEvent& gesture); | |
206 void CompleteGestureDrag(const ui::GestureEvent& gesture); | |
207 | |
208 // Update the bounds of the system tray bubble according to |location|. Note | |
209 // that |location| is in the local coordinate space of |this|. | |
210 void SetBubbleBounds(const gfx::Point& location); | |
211 | |
212 // Return true if the system bubble should be shown (i.e., animated upward to | |
213 // be made fully visible) after a sequence of scroll events terminated by | |
214 // |sequence_end|. Otherwise return false, indicating that the | |
215 // partially-visible system bubble should be animated downward and made fully | |
216 // hidden. | |
217 bool ShouldShowSystemBubbleAfterScrollSequence( | |
218 const ui::GestureEvent& sequence_end); | |
219 | |
220 // Shelf the system tray is in. | |
221 Shelf* const shelf_; | |
222 | |
223 // The original bounds of the system tray bubble. | |
224 gfx::Rect system_tray_bubble_bounds_; | |
225 | |
226 // Tracks the amount of the drag. Only valid if |is_in_drag_| is true. | |
227 float gesture_drag_amount_ = 0.f; | |
228 | |
229 // True if the user is in the process of gesture-dragging to open the system | |
230 // tray bubble, false otherwise. | |
231 bool is_in_drag_ = false; | |
232 | |
233 // The web notification tray view that appears adjacent to this view. | 198 // The web notification tray view that appears adjacent to this view. |
234 WebNotificationTray* web_notification_tray_ = nullptr; | 199 WebNotificationTray* web_notification_tray_ = nullptr; |
235 | 200 |
236 // Items. | 201 // Items. |
237 std::vector<std::unique_ptr<SystemTrayItem>> items_; | 202 std::vector<std::unique_ptr<SystemTrayItem>> items_; |
238 | 203 |
239 // Pointers to members of |items_|. | 204 // Pointers to members of |items_|. |
240 SystemTrayItem* detailed_item_ = nullptr; | 205 SystemTrayItem* detailed_item_ = nullptr; |
241 | 206 |
242 // Bubble for default and detailed views. | 207 // Bubble for default and detailed views. |
(...skipping 28 matching lines...) Expand all Loading... |
271 ScreenTrayItem* screen_share_tray_item_ = nullptr; // not owned | 236 ScreenTrayItem* screen_share_tray_item_ = nullptr; // not owned |
272 | 237 |
273 std::unique_ptr<ActivationObserver> activation_observer_; | 238 std::unique_ptr<ActivationObserver> activation_observer_; |
274 | 239 |
275 DISALLOW_COPY_AND_ASSIGN(SystemTray); | 240 DISALLOW_COPY_AND_ASSIGN(SystemTray); |
276 }; | 241 }; |
277 | 242 |
278 } // namespace ash | 243 } // namespace ash |
279 | 244 |
280 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 245 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
OLD | NEW |