| 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> |
| 11 | 11 |
| 12 #include "ash/ash_export.h" | 12 #include "ash/ash_export.h" |
| 13 #include "ash/shell_observer.h" |
| 13 #include "ash/system/tray/system_tray_bubble.h" | 14 #include "ash/system/tray/system_tray_bubble.h" |
| 14 #include "ash/system/tray/tray_background_view.h" | 15 #include "ash/system/tray/tray_background_view.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "ui/views/bubble/tray_bubble_view.h" | 17 #include "ui/views/bubble/tray_bubble_view.h" |
| 17 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
| 18 | 19 |
| 19 namespace ash { | 20 namespace ash { |
| 20 | 21 |
| 21 class KeyEventWatcher; | 22 class KeyEventWatcher; |
| 22 enum class LoginStatus; | 23 enum class LoginStatus; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 38 class TrayUpdate; | 39 class TrayUpdate; |
| 39 class WebNotificationTray; | 40 class WebNotificationTray; |
| 40 | 41 |
| 41 // There are different methods for creating bubble views. | 42 // There are different methods for creating bubble views. |
| 42 enum BubbleCreationType { | 43 enum BubbleCreationType { |
| 43 BUBBLE_CREATE_NEW, // Closes any existing bubble and creates a new one. | 44 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. | 45 BUBBLE_USE_EXISTING, // Uses any existing bubble, or creates a new one. |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 class ASH_EXPORT SystemTray : public TrayBackgroundView, | 48 class ASH_EXPORT SystemTray : public TrayBackgroundView, |
| 48 public views::TrayBubbleView::Delegate { | 49 public views::TrayBubbleView::Delegate, |
| 50 public ShellObserver { |
| 49 public: | 51 public: |
| 50 explicit SystemTray(Shelf* shelf); | 52 explicit SystemTray(Shelf* shelf); |
| 51 ~SystemTray() override; | 53 ~SystemTray() override; |
| 52 | 54 |
| 53 TrayUpdate* tray_update() { return tray_update_; } | 55 TrayUpdate* tray_update() { return tray_update_; } |
| 54 | 56 |
| 55 TrayNightLight* tray_night_light() { return tray_night_light_; } | 57 TrayNightLight* tray_night_light() { return tray_night_light_; } |
| 56 | 58 |
| 57 // Calls TrayBackgroundView::Initialize(), creates the tray items, and | 59 // Calls TrayBackgroundView::Initialize(), creates the tray items, and |
| 58 // adds them to SystemTrayNotifier. | 60 // adds them to SystemTrayNotifier. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 void HideBubbleWithView(const views::TrayBubbleView* bubble_view) override; | 131 void HideBubbleWithView(const views::TrayBubbleView* bubble_view) override; |
| 130 void ClickedOutsideBubble() override; | 132 void ClickedOutsideBubble() override; |
| 131 | 133 |
| 132 // views::TrayBubbleView::Delegate: | 134 // views::TrayBubbleView::Delegate: |
| 133 void BubbleViewDestroyed() override; | 135 void BubbleViewDestroyed() override; |
| 134 void OnMouseEnteredView() override; | 136 void OnMouseEnteredView() override; |
| 135 void OnMouseExitedView() override; | 137 void OnMouseExitedView() override; |
| 136 base::string16 GetAccessibleNameForBubble() override; | 138 base::string16 GetAccessibleNameForBubble() override; |
| 137 void HideBubble(const views::TrayBubbleView* bubble_view) override; | 139 void HideBubble(const views::TrayBubbleView* bubble_view) override; |
| 138 | 140 |
| 141 // ShellObserver: |
| 142 void OnMaximizeModeStarted() override; |
| 143 void OnMaximizeModeEnded() override; |
| 144 |
| 139 ScreenTrayItem* GetScreenShareItem() { return screen_share_tray_item_; } | 145 ScreenTrayItem* GetScreenShareItem() { return screen_share_tray_item_; } |
| 140 ScreenTrayItem* GetScreenCaptureItem() { return screen_capture_tray_item_; } | 146 ScreenTrayItem* GetScreenCaptureItem() { return screen_capture_tray_item_; } |
| 141 | 147 |
| 142 // Activates the system tray bubble. | 148 // Activates the system tray bubble. |
| 143 void ActivateBubble(); | 149 void ActivateBubble(); |
| 144 | 150 |
| 151 gfx::Rect GetWorkAreaBoundsInScreen() const; |
| 152 |
| 153 bool on_maximize_mode() { return on_maximize_mode_; } |
| 154 |
| 145 private: | 155 private: |
| 146 friend class SystemTrayTestApi; | 156 friend class SystemTrayTestApi; |
| 147 class ActivationObserver; | 157 class ActivationObserver; |
| 148 | 158 |
| 149 // Closes the bubble. Used to bind as a KeyEventWatcher::KeyEventCallback. | 159 // Closes the bubble. Used to bind as a KeyEventWatcher::KeyEventCallback. |
| 150 void CloseBubble(const ui::KeyEvent& key_event); | 160 void CloseBubble(const ui::KeyEvent& key_event); |
| 151 | 161 |
| 152 // Activates the bubble and starts key navigation with the |key_event|. | 162 // Activates the bubble and starts key navigation with the |key_event|. |
| 153 void ActivateAndStartNavigation(const ui::KeyEvent& key_event); | 163 void ActivateAndStartNavigation(const ui::KeyEvent& key_event); |
| 154 | 164 |
| (...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. | 196 // Deactivate the system tray in the shelf if it was active before. |
| 187 void CloseSystemBubbleAndDeactivateSystemTray(); | 197 void CloseSystemBubbleAndDeactivateSystemTray(); |
| 188 | 198 |
| 189 // Records UMA metrics for the number of user-visible rows in the system menu | 199 // 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. | 200 // and the percentage of the work area height covered by the system menu. |
| 191 void RecordSystemMenuMetrics(); | 201 void RecordSystemMenuMetrics(); |
| 192 | 202 |
| 193 // Overridden from ActionableView. | 203 // Overridden from ActionableView. |
| 194 bool PerformAction(const ui::Event& event) override; | 204 bool PerformAction(const ui::Event& event) override; |
| 195 | 205 |
| 206 // Overridden from ui::EventHandler: |
| 207 void OnGestureEvent(ui::GestureEvent* event) override; |
| 208 |
| 209 // Gesture related functions: |
| 210 bool ProcessGestureEvent(const ui::GestureEvent& event); |
| 211 bool StartGestureDrag(const ui::GestureEvent& gesture); |
| 212 void UpdateGestureDrag(const ui::GestureEvent& gesture); |
| 213 void CompleteGestureDrag(const ui::GestureEvent& gesture); |
| 214 |
| 215 // Returns true if swiping down triggered on the system tray area on the |
| 216 // shelf. |
| 217 bool IsSwipingDownOnShelf(const ui::GestureEvent& gesture); |
| 218 |
| 219 // Rules for showing / closing the system bubble for swiping. |
| 220 // |ET_GESTURE_SCROLL_END| considers only the position of the dragging. |
| 221 // |ET_SCROLL_FLING_START| should consider both position and velocity of the |
| 222 // dragging. |
| 223 bool ShouldShowSystemBubbleBasedOnPosition(); |
| 224 bool ShouldShowSystemBubbleForSwiping(const ui::GestureEvent& gesture); |
| 225 |
| 226 Shelf* shelf_; |
| 227 // Swiping of the system tray bubble is only for maximize mode. |
| 228 bool on_maximize_mode_ = false; |
| 229 |
| 230 // The original bounds of the system tray bubble. |
| 231 gfx::Rect system_tray_bubble_bounds_; |
| 232 |
| 233 // Tracks the amount of the drag. |
| 234 float gesture_drag_amount_; |
| 235 |
| 236 // Tracks the final scroll delta of the gesture event. |
| 237 float final_scroll_y_; |
| 238 |
| 196 // The web notification tray view that appears adjacent to this view. | 239 // The web notification tray view that appears adjacent to this view. |
| 197 WebNotificationTray* web_notification_tray_ = nullptr; | 240 WebNotificationTray* web_notification_tray_ = nullptr; |
| 198 | 241 |
| 199 // Items. | 242 // Items. |
| 200 std::vector<std::unique_ptr<SystemTrayItem>> items_; | 243 std::vector<std::unique_ptr<SystemTrayItem>> items_; |
| 201 | 244 |
| 202 // Pointers to members of |items_|. | 245 // Pointers to members of |items_|. |
| 203 SystemTrayItem* detailed_item_ = nullptr; | 246 SystemTrayItem* detailed_item_ = nullptr; |
| 204 | 247 |
| 205 // Bubble for default and detailed views. | 248 // Bubble for default and detailed views. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 235 std::unique_ptr<KeyEventWatcher> key_event_watcher_; | 278 std::unique_ptr<KeyEventWatcher> key_event_watcher_; |
| 236 | 279 |
| 237 std::unique_ptr<ActivationObserver> activation_observer_; | 280 std::unique_ptr<ActivationObserver> activation_observer_; |
| 238 | 281 |
| 239 DISALLOW_COPY_AND_ASSIGN(SystemTray); | 282 DISALLOW_COPY_AND_ASSIGN(SystemTray); |
| 240 }; | 283 }; |
| 241 | 284 |
| 242 } // namespace ash | 285 } // namespace ash |
| 243 | 286 |
| 244 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 287 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
| OLD | NEW |