Chromium Code Reviews| 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; |
| 23 class ScreenTrayItem; | 24 class ScreenTrayItem; |
| 24 class SystemBubbleWrapper; | 25 class SystemBubbleWrapper; |
| 25 class SystemTrayDelegate; | 26 class SystemTrayDelegate; |
| 26 class SystemTrayItem; | 27 class SystemTrayItem; |
| 27 class TrayAccessibility; | 28 class TrayAccessibility; |
| 28 class TrayAudio; | 29 class TrayAudio; |
| 29 class TrayCast; | 30 class TrayCast; |
| 30 class TrayEnterprise; | 31 class TrayEnterprise; |
| 31 class TrayNetwork; | 32 class TrayNetwork; |
| 32 class TrayNightLight; | 33 class TrayNightLight; |
| 33 class TrayScale; | 34 class TrayScale; |
| 34 class TraySessionLengthLimit; | 35 class TraySessionLengthLimit; |
| 35 class TraySupervisedUser; | 36 class TraySupervisedUser; |
| 36 class TraySystemInfo; | 37 class TraySystemInfo; |
| 37 class TrayTiles; | 38 class TrayTiles; |
| 38 class TrayUpdate; | 39 class TrayUpdate; |
| 39 class WebNotificationTray; | 40 class WebNotificationTray; |
| 40 | 41 |
| 42 namespace test { | |
| 43 class SystemTrayTest; | |
| 44 } | |
| 45 | |
| 41 // There are different methods for creating bubble views. | 46 // There are different methods for creating bubble views. |
| 42 enum BubbleCreationType { | 47 enum BubbleCreationType { |
| 43 BUBBLE_CREATE_NEW, // Closes any existing bubble and creates a new one. | 48 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. | 49 BUBBLE_USE_EXISTING, // Uses any existing bubble, or creates a new one. |
| 45 }; | 50 }; |
| 46 | 51 |
| 47 class ASH_EXPORT SystemTray : public TrayBackgroundView, | 52 class ASH_EXPORT SystemTray : public TrayBackgroundView, |
| 48 public views::TrayBubbleView::Delegate { | 53 public views::TrayBubbleView::Delegate, |
| 54 public ShellObserver { | |
| 49 public: | 55 public: |
| 50 explicit SystemTray(Shelf* shelf); | 56 explicit SystemTray(Shelf* shelf); |
| 51 ~SystemTray() override; | 57 ~SystemTray() override; |
| 52 | 58 |
| 53 TrayUpdate* tray_update() { return tray_update_; } | 59 TrayUpdate* tray_update() { return tray_update_; } |
| 54 | 60 |
| 55 TrayNightLight* tray_night_light() { return tray_night_light_; } | 61 TrayNightLight* tray_night_light() { return tray_night_light_; } |
| 56 | 62 |
| 57 // Calls TrayBackgroundView::Initialize(), creates the tray items, and | 63 // Calls TrayBackgroundView::Initialize(), creates the tray items, and |
| 58 // adds them to SystemTrayNotifier. | 64 // 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; | 135 void HideBubbleWithView(const views::TrayBubbleView* bubble_view) override; |
| 130 void ClickedOutsideBubble() override; | 136 void ClickedOutsideBubble() override; |
| 131 | 137 |
| 132 // views::TrayBubbleView::Delegate: | 138 // views::TrayBubbleView::Delegate: |
| 133 void BubbleViewDestroyed() override; | 139 void BubbleViewDestroyed() override; |
| 134 void OnMouseEnteredView() override; | 140 void OnMouseEnteredView() override; |
| 135 void OnMouseExitedView() override; | 141 void OnMouseExitedView() override; |
| 136 base::string16 GetAccessibleNameForBubble() override; | 142 base::string16 GetAccessibleNameForBubble() override; |
| 137 void HideBubble(const views::TrayBubbleView* bubble_view) override; | 143 void HideBubble(const views::TrayBubbleView* bubble_view) override; |
| 138 | 144 |
| 145 // ShellObserver: | |
| 146 void OnMaximizeModeStarted() override; | |
| 147 void OnMaximizeModeEnded() override; | |
| 148 | |
| 139 ScreenTrayItem* GetScreenShareItem() { return screen_share_tray_item_; } | 149 ScreenTrayItem* GetScreenShareItem() { return screen_share_tray_item_; } |
| 140 ScreenTrayItem* GetScreenCaptureItem() { return screen_capture_tray_item_; } | 150 ScreenTrayItem* GetScreenCaptureItem() { return screen_capture_tray_item_; } |
| 141 | 151 |
| 142 // Activates the system tray bubble. | 152 // Activates the system tray bubble. |
| 143 void ActivateBubble(); | 153 void ActivateBubble(); |
| 144 | 154 |
| 155 gfx::Rect GetWorkAreaBoundsInScreen() const; | |
| 156 | |
| 157 bool in_maximize_mode() { return in_maximize_mode_; } | |
| 158 | |
| 145 private: | 159 private: |
| 146 friend class SystemTrayTestApi; | 160 friend class SystemTrayTestApi; |
| 161 friend class test::SystemTrayTest; | |
|
xiyuan
2017/06/16 17:33:42
Can you extend SystemTrayTestApi to allow setting
minch1
2017/06/16 22:11:51
Done.
| |
| 147 class ActivationObserver; | 162 class ActivationObserver; |
| 148 | 163 |
| 149 // Closes the bubble. Used to bind as a KeyEventWatcher::KeyEventCallback. | 164 // Closes the bubble. Used to bind as a KeyEventWatcher::KeyEventCallback. |
| 150 void CloseBubble(const ui::KeyEvent& key_event); | 165 void CloseBubble(const ui::KeyEvent& key_event); |
| 151 | 166 |
| 152 // Activates the bubble and starts key navigation with the |key_event|. | 167 // Activates the bubble and starts key navigation with the |key_event|. |
| 153 void ActivateAndStartNavigation(const ui::KeyEvent& key_event); | 168 void ActivateAndStartNavigation(const ui::KeyEvent& key_event); |
| 154 | 169 |
| 155 // Creates the key event watcher. See |ShowItems()| for why key events are | 170 // Creates the key event watcher. See |ShowItems()| for why key events are |
| 156 // observed. | 171 // observed. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 186 // Deactivate the system tray in the shelf if it was active before. | 201 // Deactivate the system tray in the shelf if it was active before. |
| 187 void CloseSystemBubbleAndDeactivateSystemTray(); | 202 void CloseSystemBubbleAndDeactivateSystemTray(); |
| 188 | 203 |
| 189 // Records UMA metrics for the number of user-visible rows in the system menu | 204 // 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. | 205 // and the percentage of the work area height covered by the system menu. |
| 191 void RecordSystemMenuMetrics(); | 206 void RecordSystemMenuMetrics(); |
| 192 | 207 |
| 193 // Overridden from ActionableView. | 208 // Overridden from ActionableView. |
| 194 bool PerformAction(const ui::Event& event) override; | 209 bool PerformAction(const ui::Event& event) override; |
| 195 | 210 |
| 211 // Overridden from ui::EventHandler: | |
| 212 void OnGestureEvent(ui::GestureEvent* event) override; | |
| 213 | |
| 214 // Gesture related functions: | |
| 215 bool ProcessGestureEvent(const ui::GestureEvent& event); | |
| 216 bool StartGestureDrag(const ui::GestureEvent& gesture); | |
| 217 void UpdateGestureDrag(const ui::GestureEvent& gesture); | |
| 218 void CompleteGestureDrag(const ui::GestureEvent& gesture); | |
| 219 | |
| 220 // Returns true if swiping down triggered on the system tray area on the | |
| 221 // shelf. | |
| 222 bool IsSwipingDownOnShelf(const ui::GestureEvent& gesture); | |
| 223 | |
| 224 // Update the bounds of the system tray bubble according to the location of | |
| 225 // the gesture. | |
| 226 void UpdateBoundsOnGesture(const ui::GestureEvent& gesture); | |
| 227 | |
| 228 // Rules for showing / closing the system bubble for swiping. | |
| 229 // |ET_GESTURE_SCROLL_END| considers only the position of the dragging. | |
| 230 // |ET_SCROLL_FLING_START| should consider both position and velocity of the | |
| 231 // dragging. | |
|
xiyuan
2017/06/16 17:33:42
This comment seems to be just for ShouldShowSystem
minch1
2017/06/16 22:11:51
Done.
| |
| 232 bool ShouldShowSystemBubbleBasedOnPosition(); | |
|
xiyuan
2017/06/16 17:33:42
nit: ShouldShowSystemBubbleBasedOnPosition -> Shou
minch1
2017/06/16 22:11:51
Done.
| |
| 233 bool ShouldShowSystemBubbleForSwiping(const ui::GestureEvent& gesture); | |
| 234 | |
| 235 // Shelf the system tray is in. | |
| 236 Shelf* const shelf_; | |
| 237 | |
| 238 // Swiping of the system tray bubble is only for maximize mode. | |
| 239 bool in_maximize_mode_ = false; | |
| 240 | |
| 241 // The original bounds of the system tray bubble. | |
| 242 gfx::Rect system_tray_bubble_bounds_ = gfx::Rect(); | |
| 243 | |
| 244 // Tracks the amount of the drag. | |
| 245 float gesture_drag_amount_ = 0.f; | |
| 246 | |
| 196 // The web notification tray view that appears adjacent to this view. | 247 // The web notification tray view that appears adjacent to this view. |
| 197 WebNotificationTray* web_notification_tray_ = nullptr; | 248 WebNotificationTray* web_notification_tray_ = nullptr; |
| 198 | 249 |
| 199 // Items. | 250 // Items. |
| 200 std::vector<std::unique_ptr<SystemTrayItem>> items_; | 251 std::vector<std::unique_ptr<SystemTrayItem>> items_; |
| 201 | 252 |
| 202 // Pointers to members of |items_|. | 253 // Pointers to members of |items_|. |
| 203 SystemTrayItem* detailed_item_ = nullptr; | 254 SystemTrayItem* detailed_item_ = nullptr; |
| 204 | 255 |
| 205 // Bubble for default and detailed views. | 256 // Bubble for default and detailed views. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 235 std::unique_ptr<KeyEventWatcher> key_event_watcher_; | 286 std::unique_ptr<KeyEventWatcher> key_event_watcher_; |
| 236 | 287 |
| 237 std::unique_ptr<ActivationObserver> activation_observer_; | 288 std::unique_ptr<ActivationObserver> activation_observer_; |
| 238 | 289 |
| 239 DISALLOW_COPY_AND_ASSIGN(SystemTray); | 290 DISALLOW_COPY_AND_ASSIGN(SystemTray); |
| 240 }; | 291 }; |
| 241 | 292 |
| 242 } // namespace ash | 293 } // namespace ash |
| 243 | 294 |
| 244 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 295 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
| OLD | NEW |