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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_EXIT_BUBBLE_H_
6 #define CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_EXIT_BUBBLE_H_
8 #include "base/timer.h"
9 #include "chrome/browser/command_updater.h"
10 #include "chrome/browser/ui/fullscreen/fullscreen_exit_bubble_type.h"
11 #include "googleurl/src/gurl.h"
12 #include "ui/base/animation/animation_delegate.h"
13 #include "ui/gfx/point.h"
21 class FullscreenExitBubble
: public ui::AnimationDelegate
{
23 explicit FullscreenExitBubble(Browser
* browser
,
25 FullscreenExitBubbleType bubble_type
);
26 virtual ~FullscreenExitBubble();
29 static const int kPaddingPx
; // Amount of padding around the link
30 static const int kInitialDelayMs
; // Initial time bubble remains onscreen
31 static const int kIdleTimeMs
; // Time before mouse idle triggers hide
32 static const int kPositionCheckHz
; // How fast to check the mouse position
33 static const int kSlideInRegionHeightPx
;
34 // Height of region triggering
36 static const int kPopupTopPx
; // Space between the popup and the top
38 static const int kSlideInDurationMs
; // Duration of slide-in animation
39 static const int kSlideOutDurationMs
; // Duration of slide-out animation
41 // Returns the current desirable rect for the popup window. If
42 // |ignore_animation_state| is true this returns the rect assuming the popup
44 virtual gfx::Rect
GetPopupRect(bool ignore_animation_state
) const = 0;
45 virtual gfx::Point
GetCursorScreenPoint() = 0;
46 virtual bool WindowContainsPoint(gfx::Point pos
) = 0;
48 // Returns true if the window is active.
49 virtual bool IsWindowActive() = 0;
51 // Hides the bubble. This is a separate function so it can be called by a
53 virtual void Hide() = 0;
56 virtual void Show() = 0;
58 virtual bool IsAnimating() = 0;
60 // Called repeatedly to get the current mouse position and animate the bubble
61 // on or off the screen as appropriate.
62 void CheckMousePosition();
64 void StartWatchingMouse();
65 void StopWatchingMouse();
67 void ToggleFullscreen();
68 // Accepts the request. Can cause FullscreenExitBubble to be deleted.
70 // Denys the request. Can cause FullscreenExitBubble to be deleted.
73 // The following strings may change according to the content type and URL.
74 string16
GetCurrentMessageText() const;
75 string16
GetCurrentDenyButtonText() const;
77 // The following strings never change.
78 string16
GetAllowButtonText() const;
79 string16
GetInstructionText() const;
81 // The browser this bubble is in.
85 // Timer to delay before allowing the bubble to hide after it's initially
87 base::OneShotTimer
<FullscreenExitBubble
> initial_delay_
;
89 // Timer to see how long the mouse has been idle.
90 base::OneShotTimer
<FullscreenExitBubble
> idle_timeout_
;
92 // Timer to poll the current mouse position. We can't just listen for mouse
93 // events without putting a non-empty HWND onscreen (or hooking Windows, which
94 // has other problems), so instead we run a low-frequency poller to see if the
95 // user has moved in or out of our show/hide regions.
96 base::RepeatingTimer
<FullscreenExitBubble
> mouse_position_checker_
;
98 // The most recently seen mouse position, in screen coordinates. Used to see
99 // if the mouse has moved since our last check.
100 gfx::Point last_mouse_pos_
;
103 // The host the bubble is for, can be empty.
106 // The type of the bubble; controls e.g. which buttons to show.
107 FullscreenExitBubbleType bubble_type_
;
110 #endif // CHROME_BROWSER_UI_FULLSCREEN_FULLSCREEN_EXIT_BUBBLE_H_