OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_EXIT_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_UI_FULLSCREEN_EXIT_BUBBLE_H_ |
6 #define CHROME_BROWSER_UI_FULLSCREEN_EXIT_BUBBLE_H_ | 6 #define CHROME_BROWSER_UI_FULLSCREEN_EXIT_BUBBLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
11 #include "chrome/browser/command_updater.h" | 11 #include "chrome/browser/command_updater.h" |
| 12 #include "googleurl/src/gurl.h" |
12 #include "ui/base/animation/animation_delegate.h" | 13 #include "ui/base/animation/animation_delegate.h" |
13 #include "ui/gfx/point.h" | 14 #include "ui/gfx/point.h" |
14 | 15 |
| 16 class Browser; |
| 17 |
15 namespace ui { | 18 namespace ui { |
16 class SlideAnimation; | 19 class SlideAnimation; |
17 } | 20 } |
18 | 21 |
19 namespace gfx { | 22 namespace gfx { |
20 class Rect; | 23 class Rect; |
21 } | 24 } |
22 | 25 |
23 class FullscreenExitBubble : public ui::AnimationDelegate { | 26 class FullscreenExitBubble : public ui::AnimationDelegate { |
24 public: | 27 public: |
25 explicit FullscreenExitBubble( | 28 explicit FullscreenExitBubble(Browser* browser); |
26 CommandUpdater::CommandUpdaterDelegate* delegate); | |
27 virtual ~FullscreenExitBubble(); | 29 virtual ~FullscreenExitBubble(); |
28 | 30 |
29 protected: | 31 protected: |
30 static const double kOpacity; // Opacity of the bubble, 0.0 - 1.0 | |
31 static const int kPaddingPx; // Amount of padding around the link | 32 static const int kPaddingPx; // Amount of padding around the link |
32 static const int kInitialDelayMs; // Initial time bubble remains onscreen | 33 static const int kInitialDelayMs; // Initial time bubble remains onscreen |
33 static const int kIdleTimeMs; // Time before mouse idle triggers hide | 34 static const int kIdleTimeMs; // Time before mouse idle triggers hide |
34 static const int kPositionCheckHz; // How fast to check the mouse position | 35 static const int kPositionCheckHz; // How fast to check the mouse position |
35 static const int kSlideInRegionHeightPx; | 36 static const int kSlideInRegionHeightPx; // Height of region triggering |
36 // Height of region triggering slide-in | 37 // slide-in |
| 38 static const int kPopupTopPx; // Space between the popup and the top |
| 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 | |
45 virtual gfx::Point GetCursorScreenPoint() = 0; | 47 virtual gfx::Point GetCursorScreenPoint() = 0; |
46 | |
47 virtual bool WindowContainsPoint(gfx::Point pos) = 0; | 48 virtual bool WindowContainsPoint(gfx::Point pos) = 0; |
48 | 49 |
49 // Returns true if the window is active. | 50 // Returns true if the window is active. |
50 virtual bool IsWindowActive() = 0; | 51 virtual bool IsWindowActive() = 0; |
51 | 52 |
52 // Hides the bubble. This is a separate function so it can be called by a | 53 // Hides the bubble. This is a separate function so it can be called by a |
53 // timer. | 54 // timer. |
54 virtual void Hide() = 0; | 55 virtual void Hide() = 0; |
55 | 56 |
56 // Shows the bubble. | 57 // Shows the bubble. |
57 virtual void Show() = 0; | 58 virtual void Show() = 0; |
58 | 59 |
59 virtual bool IsAnimating() = 0; | 60 virtual bool IsAnimating() = 0; |
60 | 61 |
61 // Called repeatedly to get the current mouse position and animate the bubble | 62 // Called repeatedly to get the current mouse position and animate the bubble |
62 // on or off the screen as appropriate. | 63 // on or off the screen as appropriate. |
63 void CheckMousePosition(); | 64 void CheckMousePosition(); |
64 | 65 |
65 void StartWatchingMouse(); | 66 void StartWatchingMouse(); |
66 | 67 |
67 void ToggleFullscreen(); | 68 void ToggleFullscreen(); |
| 69 void AcceptFullscreen(const GURL& url); |
| 70 void CancelFullscreen(); |
| 71 |
| 72 // The browser this bubble is in. |
| 73 Browser* browser_; |
68 | 74 |
69 private: | 75 private: |
70 // Someone who can toggle fullscreen mode on and off when the user requests | |
71 // it. | |
72 CommandUpdater::CommandUpdaterDelegate* delegate_; | |
73 | |
74 // Timer to delay before allowing the bubble to hide after it's initially | 76 // Timer to delay before allowing the bubble to hide after it's initially |
75 // shown. | 77 // shown. |
76 base::OneShotTimer<FullscreenExitBubble> initial_delay_; | 78 base::OneShotTimer<FullscreenExitBubble> initial_delay_; |
77 | 79 |
78 // Timer to see how long the mouse has been idle. | 80 // Timer to see how long the mouse has been idle. |
79 base::OneShotTimer<FullscreenExitBubble> idle_timeout_; | 81 base::OneShotTimer<FullscreenExitBubble> idle_timeout_; |
80 | 82 |
81 // Timer to poll the current mouse position. We can't just listen for mouse | 83 // Timer to poll the current mouse position. We can't just listen for mouse |
82 // events without putting a non-empty HWND onscreen (or hooking Windows, which | 84 // events without putting a non-empty HWND onscreen (or hooking Windows, which |
83 // has other problems), so instead we run a low-frequency poller to see if the | 85 // has other problems), so instead we run a low-frequency poller to see if the |
84 // user has moved in or out of our show/hide regions. | 86 // user has moved in or out of our show/hide regions. |
85 base::RepeatingTimer<FullscreenExitBubble> mouse_position_checker_; | 87 base::RepeatingTimer<FullscreenExitBubble> mouse_position_checker_; |
86 | 88 |
87 // The most recently seen mouse position, in screen coordinates. Used to see | 89 // The most recently seen mouse position, in screen coordinates. Used to see |
88 // if the mouse has moved since our last check. | 90 // if the mouse has moved since our last check. |
89 gfx::Point last_mouse_pos_; | 91 gfx::Point last_mouse_pos_; |
90 }; | 92 }; |
91 | 93 |
92 #endif // CHROME_BROWSER_UI_FULLSCREEN_EXIT_BUBBLE_H_ | 94 #endif // CHROME_BROWSER_UI_FULLSCREEN_EXIT_BUBBLE_H_ |
OLD | NEW |