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 CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_BUBBLE_H_ |
| 6 #define CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_BUBBLE_H_ | 6 #define CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_BUBBLE_H_ |
| 7 | 7 |
| 8 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
| 9 #include "chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h" | 9 #include "chrome/browser/ui/exclusive_access/exclusive_access_bubble_type.h" |
| 10 #include "ui/gfx/animation/animation_delegate.h" | 10 #include "ui/gfx/animation/animation_delegate.h" |
| 11 #include "ui/gfx/geometry/point.h" | 11 #include "ui/gfx/geometry/point.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 | 13 |
| 14 class ExclusiveAccessManager; | 14 class ExclusiveAccessManager; |
| 15 | 15 |
| 16 namespace gfx { | 16 namespace gfx { |
| 17 class Rect; | 17 class Rect; |
| 18 } | 18 } |
| 19 | 19 |
| 20 // Bubble that informs the user when an exclusive access state is in effect and | 20 // Bubble that informs the user when an exclusive access state is in effect and |
| 21 // as to how to exit out of the state. Currently there are two exclusive access | 21 // as to how to exit out of the state. Currently there are two exclusive access |
| 22 // state, namely fullscreen and mouse lock. | 22 // state, namely fullscreen and mouse lock. |
| 23 // | |
| 24 // Notification display design note: if the #simplified-fullscreen-ui flag is | |
| 25 // enabled, the bubble has the following behaviour: | |
| 26 // - Upon taking exclusive access, wait kDebounceNotificationsTimeMs, then for | |
| 27 // user input, before displaying the bubble. | |
| 28 // - The bubble is shown for kIdleTimeMs, then hides. | |
| 29 // - We suppress notifications for kSnoozeNotificationsTimeMs, to avoid | |
| 30 // bothering the user. After this time has elapsed, the next user input | |
| 31 // re-displays the bubble. | |
| 23 class ExclusiveAccessBubble : public gfx::AnimationDelegate { | 32 class ExclusiveAccessBubble : public gfx::AnimationDelegate { |
| 24 public: | 33 public: |
| 25 explicit ExclusiveAccessBubble(ExclusiveAccessManager* manager, | 34 explicit ExclusiveAccessBubble(ExclusiveAccessManager* manager, |
| 26 const GURL& url, | 35 const GURL& url, |
| 27 ExclusiveAccessBubbleType bubble_type); | 36 ExclusiveAccessBubbleType bubble_type); |
| 28 ~ExclusiveAccessBubble() override; | 37 ~ExclusiveAccessBubble() override; |
| 29 | 38 |
| 30 protected: | 39 protected: |
| 31 static const int kPaddingPx; // Amount of padding around the link | 40 static const int kPaddingPx; // Amount of padding around the link |
| 32 static const int kInitialDelayMs; // Initial time bubble remains onscreen | 41 static const int kInitialDelayMs; // Initial time bubble remains onscreen |
| 33 static const int kIdleTimeMs; // Time before mouse idle triggers hide | 42 static const int kIdleTimeMs; // Time before mouse idle triggers hide |
| 43 // Time before showing initial message (simplified fullscreen UI). | |
|
msw
2015/08/05 17:29:55
nit: "showing the initial"
Matt Giuca
2015/08/06 03:33:03
N/A
| |
| 44 static const int kDebounceNotificationsTimeMs; | |
| 45 // Time to suppress notifications after a bubble has been shown (simplified | |
| 46 // fullscreen UI). See notification display design note above. | |
| 47 static const int kSnoozeNotificationsTimeMs; | |
| 34 static const int kPositionCheckHz; // How fast to check the mouse position | 48 static const int kPositionCheckHz; // How fast to check the mouse position |
| 35 static const int kSlideInRegionHeightPx; | 49 static const int kSlideInRegionHeightPx; |
| 36 // Height of region triggering | 50 // Height of region triggering |
| 37 // slide-in | 51 // slide-in |
| 38 static const int kPopupTopPx; // Space between the popup and the top | 52 static const int kPopupTopPx; // Space between the popup and the top |
| 39 // of the screen. | 53 // of the screen. |
| 40 static const int kSlideInDurationMs; // Duration of slide-in animation | 54 static const int kSlideInDurationMs; // Duration of slide-in animation |
| 41 static const int kSlideOutDurationMs; // Duration of slide-out animation | 55 static const int kSlideOutDurationMs; // Duration of slide-out animation |
| 42 | 56 |
| 43 // Returns the current desirable rect for the popup window. If | 57 // Returns the current desirable rect for the popup window. If |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 // The Manager associated with this bubble. | 102 // The Manager associated with this bubble. |
| 89 ExclusiveAccessManager* const manager_; | 103 ExclusiveAccessManager* const manager_; |
| 90 | 104 |
| 91 // The host the bubble is for, can be empty. | 105 // The host the bubble is for, can be empty. |
| 92 GURL url_; | 106 GURL url_; |
| 93 | 107 |
| 94 // The type of the bubble; controls e.g. which buttons to show. | 108 // The type of the bubble; controls e.g. which buttons to show. |
| 95 ExclusiveAccessBubbleType bubble_type_; | 109 ExclusiveAccessBubbleType bubble_type_; |
| 96 | 110 |
| 97 private: | 111 private: |
| 98 // Timer to delay before allowing the bubble to hide after it's initially | 112 // When this timer is active, prevent the bubble from hiding. This ensures it |
| 99 // shown. | 113 // will be displayed for a minimum amount of time (which can be extended by |
| 100 base::OneShotTimer<ExclusiveAccessBubble> initial_delay_; | 114 // the user moving the mouse to the top of the screen and holding it there). |
| 115 base::OneShotTimer<ExclusiveAccessBubble> hide_timeout_; | |
| 101 | 116 |
| 102 // Timer to see how long the mouse has been idle. | 117 // Timer to see how long the mouse has been idle. |
| 103 base::OneShotTimer<ExclusiveAccessBubble> idle_timeout_; | 118 base::OneShotTimer<ExclusiveAccessBubble> idle_timeout_; |
| 104 | 119 |
| 120 // When this timer has elapsed, on the next mouse input, we will notify the | |
| 121 // user about any currently active exclusive access. This is used to enact | |
| 122 // both the initial debounce period, and the snooze period before re-notifying | |
| 123 // the user (see notification display design note above). | |
| 124 base::OneShotTimer<ExclusiveAccessBubble> suppress_notify_timeout_; | |
| 125 | |
| 105 // Timer to poll the current mouse position. We can't just listen for mouse | 126 // Timer to poll the current mouse position. We can't just listen for mouse |
| 106 // events without putting a non-empty HWND onscreen (or hooking Windows, which | 127 // events without putting a non-empty HWND onscreen (or hooking Windows, which |
| 107 // has other problems), so instead we run a low-frequency poller to see if the | 128 // has other problems), so instead we run a low-frequency poller to see if the |
| 108 // user has moved in or out of our show/hide regions. | 129 // user has moved in or out of our show/hide regions. |
| 109 base::RepeatingTimer<ExclusiveAccessBubble> mouse_position_checker_; | 130 base::RepeatingTimer<ExclusiveAccessBubble> mouse_position_checker_; |
| 110 | 131 |
| 111 // The most recently seen mouse position, in screen coordinates. Used to see | 132 // The most recently seen mouse position, in screen coordinates. Used to see |
| 112 // if the mouse has moved since our last check. | 133 // if the mouse has moved since our last check. |
| 113 gfx::Point last_mouse_pos_; | 134 gfx::Point last_mouse_pos_; |
| 114 | 135 |
| 115 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessBubble); | 136 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessBubble); |
| 116 }; | 137 }; |
| 117 | 138 |
| 118 #endif // CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_BUBBLE_H_ | 139 #endif // CHROME_BROWSER_UI_EXCLUSIVE_ACCESS_EXCLUSIVE_ACCESS_BUBBLE_H_ |
| OLD | NEW |