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_VIEWS_EXCLUSIVE_ACCESS_BUBBLE_VIEWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXCLUSIVE_ACCESS_BUBBLE_VIEWS_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/ui/exclusive_access/exclusive_access_bubble.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "ui/views/widget/widget_observer.h"
15 class ExclusiveAccessBubbleViewsContext
;
25 // ExclusiveAccessBubbleViews is responsible for showing a bubble atop the
26 // screen in fullscreen/mouse lock mode, telling users how to exit and providing
27 // a click target. The bubble auto-hides, and re-shows when the user moves to
29 class ExclusiveAccessBubbleViews
: public ExclusiveAccessBubble
,
30 public content::NotificationObserver
,
31 public views::WidgetObserver
{
33 ExclusiveAccessBubbleViews(ExclusiveAccessBubbleViewsContext
* context
,
35 ExclusiveAccessBubbleType bubble_type
);
36 ~ExclusiveAccessBubbleViews() override
;
38 void UpdateContent(const GURL
& url
, ExclusiveAccessBubbleType bubble_type
);
40 // Repositions |popup_| if it is visible.
41 void RepositionIfVisible();
43 views::View
* GetView();
46 class ExclusiveAccessView
;
48 enum AnimatedAttribute
{
49 ANIMATED_ATTRIBUTE_BOUNDS
,
50 ANIMATED_ATTRIBUTE_OPACITY
53 // Starts or stops polling the mouse location based on |popup_| and
55 void UpdateMouseWatcher();
57 // Updates any state which depends on whether the user is in immersive
59 void UpdateForImmersiveState();
61 // Updates |popup|'s bounds given |animation_| and |animated_attribute_|.
64 // Returns the root view containing |browser_view_|.
65 views::View
* GetBrowserRootView() const;
67 // FullScreenExitBubble overrides:
68 void AnimationProgressed(const gfx::Animation
* animation
) override
;
69 void AnimationEnded(const gfx::Animation
* animation
) override
;
70 gfx::Rect
GetPopupRect(bool ignore_animation_state
) const override
;
71 gfx::Point
GetCursorScreenPoint() override
;
72 bool WindowContainsPoint(gfx::Point pos
) override
;
73 bool IsWindowActive() override
;
76 bool IsAnimating() override
;
77 bool CanMouseTriggerSlideIn() const override
;
79 // content::NotificationObserver override:
80 void Observe(int type
,
81 const content::NotificationSource
& source
,
82 const content::NotificationDetails
& details
) override
;
84 // views::WidgetObserver override:
85 void OnWidgetVisibilityChanged(views::Widget
* widget
, bool visible
) override
;
87 ExclusiveAccessBubbleViewsContext
* const bubble_view_context_
;
89 views::Widget
* popup_
;
91 // Animation controlling showing/hiding of the exit bubble.
92 scoped_ptr
<gfx::SlideAnimation
> animation_
;
94 // Attribute animated by |animation_|.
95 AnimatedAttribute animated_attribute_
;
97 // The contents of the popup.
98 ExclusiveAccessView
* view_
;
100 content::NotificationRegistrar registrar_
;
102 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessBubbleViews
);
105 #endif // CHROME_BROWSER_UI_VIEWS_EXCLUSIVE_ACCESS_BUBBLE_VIEWS_H_