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