Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / views / frame / immersive_mode_controller.h
blob21aca5837f33319598578c3a8f93c8437ee8d70b
1 // Copyright 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_FRAME_IMMERSIVE_MODE_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_H_
8 #include "base/compiler_specific.h"
9 #include "base/observer_list.h"
10 #include "chrome/browser/ui/host_desktop.h"
12 class BrowserView;
14 namespace gfx {
15 class Rect;
16 class Size;
19 // A lock which will keep the top-of-window views revealed for its
20 // lifetime.
21 // See ImmersiveModeController::GetRevealedLock for details.
22 class ImmersiveRevealedLock {
23 public:
24 virtual ~ImmersiveRevealedLock() {}
26 protected:
27 ImmersiveRevealedLock() {}
30 // Controller for an "immersive mode" similar to MacOS presentation mode where
31 // the top-of-window views are hidden until the mouse hits the top of the
32 // screen. The tab strip is optionally painted with miniature "tab indicator"
33 // rectangles.
34 // Currently, immersive mode is only available for Chrome OS.
35 class ImmersiveModeController {
36 public:
37 enum AnimateReveal {
38 ANIMATE_REVEAL_YES,
39 ANIMATE_REVEAL_NO
42 class Observer {
43 public:
44 // Called when a reveal of the top-of-window views has been initiated.
45 virtual void OnImmersiveRevealStarted() {}
47 // Called when the immersive mode controller has been destroyed.
48 virtual void OnImmersiveModeControllerDestroyed() {}
50 protected:
51 virtual ~Observer() {}
54 ImmersiveModeController();
55 virtual ~ImmersiveModeController();
57 // Must initialize after browser view has a Widget and native window.
58 virtual void Init(BrowserView* browser_view) = 0;
60 // Enables or disables immersive mode.
61 virtual void SetEnabled(bool enabled) = 0;
62 virtual bool IsEnabled() const = 0;
64 // True if the miniature "tab indicators" should be hidden in the main browser
65 // view when immersive mode is enabled.
66 virtual bool ShouldHideTabIndicators() const = 0;
68 // True when the top views are hidden due to immersive mode.
69 virtual bool ShouldHideTopViews() const = 0;
71 // True when the top views are fully or partially visible.
72 virtual bool IsRevealed() const = 0;
74 // Returns the top container's vertical offset relative to its parent. When
75 // revealing or closing the top-of-window views, part of the top container is
76 // offscreen.
77 // This method takes in the top container's size because it is called as part
78 // of computing the new bounds for the top container in
79 // BrowserViewLayout::UpdateTopContainerBounds().
80 virtual int GetTopContainerVerticalOffset(
81 const gfx::Size& top_container_size) const = 0;
83 // Returns a lock which will keep the top-of-window views revealed for its
84 // lifetime. Several locks can be obtained. When all of the locks are
85 // destroyed, if immersive mode is enabled and there is nothing else keeping
86 // the top-of-window views revealed, the top-of-window views will be closed.
87 // This method always returns a valid lock regardless of whether immersive
88 // mode is enabled. The lock's lifetime can span immersive mode being
89 // enabled / disabled.
90 // If acquiring the lock causes a reveal, the top-of-window views will animate
91 // according to |animate_reveal|.
92 // The caller takes ownership of the returned lock.
93 // This is currently only supported on Ash.
94 virtual ImmersiveRevealedLock* GetRevealedLock(
95 AnimateReveal animate_reveal) WARN_UNUSED_RESULT = 0;
97 // Called by the find bar to indicate that its visible bounds have changed.
98 // |new_visible_bounds_in_screen| should be empty if the find bar is not
99 // visible.
100 virtual void OnFindBarVisibleBoundsChanged(
101 const gfx::Rect& new_visible_bounds_in_screen) = 0;
103 // Disables animations and moves the mouse so that it is not over the
104 // top-of-window views for the sake of testing. Must be called before
105 // enabling immersive fullscreen.
106 virtual void SetupForTest() = 0;
108 virtual void AddObserver(Observer* observer);
109 virtual void RemoveObserver(Observer* observer);
111 protected:
112 base::ObserverList<Observer> observers_;
114 private:
115 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeController);
118 namespace chrome {
120 // Implemented in immersive_mode_controller_factory.cc.
121 ImmersiveModeController* CreateImmersiveModeController(
122 chrome::HostDesktopType host_desktop_type);
124 } // namespace chrome
126 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_H_