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