| 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 explicit SystemTray(Shelf* shelf); | 53 explicit SystemTray(Shelf* shelf); |
| 51 ~SystemTray() override; | 54 ~SystemTray() override; |
| 52 | 55 |
| 53 TrayUpdate* tray_update() { return tray_update_; } | 56 TrayUpdate* tray_update() { return tray_update_; } |
| 54 | 57 |
| 55 TrayNightLight* tray_night_light() { return tray_night_light_; } | 58 TrayNightLight* tray_night_light() { return tray_night_light_; } |
| 56 | 59 |
| 57 // Calls TrayBackgroundView::Initialize(), creates the tray items, and | 60 // Calls TrayBackgroundView::Initialize(), creates the tray items, and |
| 58 // adds them to SystemTrayNotifier. | 61 // adds them to SystemTrayNotifier. |
| 59 void InitializeTrayItems(SystemTrayDelegate* delegate, | 62 void InitializeTrayItems(SystemTrayDelegate* delegate, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 void OnMouseExitedView() override; | 138 void OnMouseExitedView() override; |
| 136 base::string16 GetAccessibleNameForBubble() override; | 139 base::string16 GetAccessibleNameForBubble() override; |
| 137 void HideBubble(const views::TrayBubbleView* bubble_view) override; | 140 void HideBubble(const views::TrayBubbleView* bubble_view) override; |
| 138 | 141 |
| 139 ScreenTrayItem* GetScreenShareItem() { return screen_share_tray_item_; } | 142 ScreenTrayItem* GetScreenShareItem() { return screen_share_tray_item_; } |
| 140 ScreenTrayItem* GetScreenCaptureItem() { return screen_capture_tray_item_; } | 143 ScreenTrayItem* GetScreenCaptureItem() { return screen_capture_tray_item_; } |
| 141 | 144 |
| 142 // Activates the system tray bubble. | 145 // Activates the system tray bubble. |
| 143 void ActivateBubble(); | 146 void ActivateBubble(); |
| 144 | 147 |
| 148 // ui::EventHandler: |
| 149 void OnGestureEvent(ui::GestureEvent* event) override; |
| 150 |
| 151 gfx::Rect GetWorkAreaBoundsInScreen() const; |
| 152 |
| 145 private: | 153 private: |
| 146 friend class SystemTrayTestApi; | 154 friend class SystemTrayTestApi; |
| 147 class ActivationObserver; | 155 class ActivationObserver; |
| 148 | 156 |
| 149 // Closes the bubble. Used to bind as a KeyEventWatcher::KeyEventCallback. | 157 // Closes the bubble. Used to bind as a KeyEventWatcher::KeyEventCallback. |
| 150 void CloseBubble(const ui::KeyEvent& key_event); | 158 void CloseBubble(const ui::KeyEvent& key_event); |
| 151 | 159 |
| 152 // Activates the bubble and starts key navigation with the |key_event|. | 160 // Activates the bubble and starts key navigation with the |key_event|. |
| 153 void ActivateAndStartNavigation(const ui::KeyEvent& key_event); | 161 void ActivateAndStartNavigation(const ui::KeyEvent& key_event); |
| 154 | 162 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // Deactivate the system tray in the shelf if it was active before. | 194 // Deactivate the system tray in the shelf if it was active before. |
| 187 void CloseSystemBubbleAndDeactivateSystemTray(); | 195 void CloseSystemBubbleAndDeactivateSystemTray(); |
| 188 | 196 |
| 189 // Records UMA metrics for the number of user-visible rows in the system menu | 197 // Records UMA metrics for the number of user-visible rows in the system menu |
| 190 // and the percentage of the work area height covered by the system menu. | 198 // and the percentage of the work area height covered by the system menu. |
| 191 void RecordSystemMenuMetrics(); | 199 void RecordSystemMenuMetrics(); |
| 192 | 200 |
| 193 // Overridden from ActionableView. | 201 // Overridden from ActionableView. |
| 194 bool PerformAction(const ui::Event& event) override; | 202 bool PerformAction(const ui::Event& event) override; |
| 195 | 203 |
| 204 // Gesture related functions: |
| 205 bool ProcessGestureEvent(const ui::GestureEvent& event); |
| 206 bool StartGestureDrag(const ui::GestureEvent& gesture); |
| 207 void UpdateGestureDrag(const ui::GestureEvent& gesture); |
| 208 void CompleteGestureDrag(const ui::GestureEvent& gesture); |
| 209 |
| 210 // Update the bounds of the system tray bubble according to |location|. Note |
| 211 // that |location| is in the local coordinate space of |this|. |
| 212 void SetBubbleBounds(const gfx::Point& location); |
| 213 |
| 214 // Return true if the system bubble should be shown (i.e., animated upward to |
| 215 // be made fully visible) after a sequence of scroll events terminated by |
| 216 // |sequence_end|. Otherwise return false, indicating that the |
| 217 // partially-visible system bubble should be animated downward and made fully |
| 218 // hidden. |
| 219 bool ShouldShowSystemBubbleAfterScrollSequence( |
| 220 const ui::GestureEvent& sequence_end); |
| 221 |
| 222 // Shelf the system tray is in. |
| 223 Shelf* const shelf_; |
| 224 |
| 225 // The original bounds of the system tray bubble. |
| 226 gfx::Rect system_tray_bubble_bounds_; |
| 227 |
| 228 // Tracks the amount of the drag. Only valid if |is_in_drag_| is true. |
| 229 float gesture_drag_amount_ = 0.f; |
| 230 |
| 231 // True if the user is in the process of gesture-dragging to open the system |
| 232 // tray bubble, false otherwise. |
| 233 bool is_in_drag_ = false; |
| 234 |
| 196 // The web notification tray view that appears adjacent to this view. | 235 // The web notification tray view that appears adjacent to this view. |
| 197 WebNotificationTray* web_notification_tray_ = nullptr; | 236 WebNotificationTray* web_notification_tray_ = nullptr; |
| 198 | 237 |
| 199 // Items. | 238 // Items. |
| 200 std::vector<std::unique_ptr<SystemTrayItem>> items_; | 239 std::vector<std::unique_ptr<SystemTrayItem>> items_; |
| 201 | 240 |
| 202 // Pointers to members of |items_|. | 241 // Pointers to members of |items_|. |
| 203 SystemTrayItem* detailed_item_ = nullptr; | 242 SystemTrayItem* detailed_item_ = nullptr; |
| 204 | 243 |
| 205 // Bubble for default and detailed views. | 244 // Bubble for default and detailed views. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 235 std::unique_ptr<KeyEventWatcher> key_event_watcher_; | 274 std::unique_ptr<KeyEventWatcher> key_event_watcher_; |
| 236 | 275 |
| 237 std::unique_ptr<ActivationObserver> activation_observer_; | 276 std::unique_ptr<ActivationObserver> activation_observer_; |
| 238 | 277 |
| 239 DISALLOW_COPY_AND_ASSIGN(SystemTray); | 278 DISALLOW_COPY_AND_ASSIGN(SystemTray); |
| 240 }; | 279 }; |
| 241 | 280 |
| 242 } // namespace ash | 281 } // namespace ash |
| 243 | 282 |
| 244 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 283 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
| OLD | NEW |