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_FULLSCREEN_FULLSCREEN_EXIT_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_UI_FULLSCREEN_EXCLUSIVE_ACCESS_BUBBLE_H_ |
6 #define CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_EXIT_BUBBLE_H_ | 6 #define CHROME_BROWSER_UI_FULLSCREEN_EXCLUSIVE_ACCESS_BUBBLE_H_ |
7 | 7 |
8 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
9 #include "chrome/browser/ui/fullscreen/fullscreen_exit_bubble_type.h" | 9 #include "chrome/browser/ui/fullscreen/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/point.h" | 11 #include "ui/gfx/point.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 class Browser; | 14 class Browser; |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 class Rect; | 17 class Rect; |
18 } | 18 } |
19 | 19 |
20 class FullscreenExitBubble : public gfx::AnimationDelegate { | 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 |
| 22 // state, namely fullscreen and mouse lock. |
| 23 class ExclusiveAccessBubble : public gfx::AnimationDelegate { |
21 public: | 24 public: |
22 explicit FullscreenExitBubble(Browser* browser, | 25 explicit ExclusiveAccessBubble(Browser* browser, |
23 const GURL& url, | 26 const GURL& url, |
24 FullscreenExitBubbleType bubble_type); | 27 ExclusiveAccessBubbleType bubble_type); |
25 ~FullscreenExitBubble() override; | 28 ~ExclusiveAccessBubble() override; |
26 | 29 |
27 protected: | 30 protected: |
28 static const int kPaddingPx; // Amount of padding around the link | 31 static const int kPaddingPx; // Amount of padding around the link |
29 static const int kInitialDelayMs; // Initial time bubble remains onscreen | 32 static const int kInitialDelayMs; // Initial time bubble remains onscreen |
30 static const int kIdleTimeMs; // Time before mouse idle triggers hide | 33 static const int kIdleTimeMs; // Time before mouse idle triggers hide |
31 static const int kPositionCheckHz; // How fast to check the mouse position | 34 static const int kPositionCheckHz; // How fast to check the mouse position |
32 static const int kSlideInRegionHeightPx; | 35 static const int kSlideInRegionHeightPx; |
33 // Height of region triggering | 36 // Height of region triggering |
34 // slide-in | 37 // slide-in |
35 static const int kPopupTopPx; // Space between the popup and the top | 38 static const int kPopupTopPx; // Space between the popup and the top |
36 // of the screen. | 39 // of the screen. |
37 static const int kSlideInDurationMs; // Duration of slide-in animation | 40 static const int kSlideInDurationMs; // Duration of slide-in animation |
38 static const int kSlideOutDurationMs; // Duration of slide-out animation | 41 static const int kSlideOutDurationMs; // Duration of slide-out animation |
39 | 42 |
40 // Returns the current desirable rect for the popup window. If | 43 // Returns the current desirable rect for the popup window. If |
41 // |ignore_animation_state| is true this returns the rect assuming the popup | 44 // |ignore_animation_state| is true this returns the rect assuming the popup |
42 // is fully onscreen. | 45 // is fully onscreen. |
43 virtual gfx::Rect GetPopupRect(bool ignore_animation_state) const = 0; | 46 virtual gfx::Rect GetPopupRect(bool ignore_animation_state) const = 0; |
44 virtual gfx::Point GetCursorScreenPoint() = 0; | 47 virtual gfx::Point GetCursorScreenPoint() = 0; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 base::string16 GetAllowButtonText() const; | 85 base::string16 GetAllowButtonText() const; |
83 base::string16 GetInstructionText() const; | 86 base::string16 GetInstructionText() const; |
84 | 87 |
85 // The browser this bubble is in. | 88 // The browser this bubble is in. |
86 Browser* browser_; | 89 Browser* browser_; |
87 | 90 |
88 // The host the bubble is for, can be empty. | 91 // The host the bubble is for, can be empty. |
89 GURL url_; | 92 GURL url_; |
90 | 93 |
91 // The type of the bubble; controls e.g. which buttons to show. | 94 // The type of the bubble; controls e.g. which buttons to show. |
92 FullscreenExitBubbleType bubble_type_; | 95 ExclusiveAccessBubbleType bubble_type_; |
93 | 96 |
94 private: | 97 private: |
95 // Timer to delay before allowing the bubble to hide after it's initially | 98 // Timer to delay before allowing the bubble to hide after it's initially |
96 // shown. | 99 // shown. |
97 base::OneShotTimer<FullscreenExitBubble> initial_delay_; | 100 base::OneShotTimer<ExclusiveAccessBubble> initial_delay_; |
98 | 101 |
99 // Timer to see how long the mouse has been idle. | 102 // Timer to see how long the mouse has been idle. |
100 base::OneShotTimer<FullscreenExitBubble> idle_timeout_; | 103 base::OneShotTimer<ExclusiveAccessBubble> idle_timeout_; |
101 | 104 |
102 // Timer to poll the current mouse position. We can't just listen for mouse | 105 // Timer to poll the current mouse position. We can't just listen for mouse |
103 // events without putting a non-empty HWND onscreen (or hooking Windows, which | 106 // events without putting a non-empty HWND onscreen (or hooking Windows, which |
104 // has other problems), so instead we run a low-frequency poller to see if the | 107 // has other problems), so instead we run a low-frequency poller to see if the |
105 // user has moved in or out of our show/hide regions. | 108 // user has moved in or out of our show/hide regions. |
106 base::RepeatingTimer<FullscreenExitBubble> mouse_position_checker_; | 109 base::RepeatingTimer<ExclusiveAccessBubble> mouse_position_checker_; |
107 | 110 |
108 // The most recently seen mouse position, in screen coordinates. Used to see | 111 // The most recently seen mouse position, in screen coordinates. Used to see |
109 // if the mouse has moved since our last check. | 112 // if the mouse has moved since our last check. |
110 gfx::Point last_mouse_pos_; | 113 gfx::Point last_mouse_pos_; |
111 | 114 |
112 DISALLOW_COPY_AND_ASSIGN(FullscreenExitBubble); | 115 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessBubble); |
113 }; | 116 }; |
114 | 117 |
115 #endif // CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_EXIT_BUBBLE_H_ | 118 #endif // CHROME_BROWSER_UI_FULLSCREEN_EXCLUSIVE_ACCESS_BUBBLE_H_ |
OLD | NEW |