Home | History | Annotate | Download | only in frame
      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_ASH_H_
      6 #define CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_
      7 
      8 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
      9 
     10 #include "ash/wm/immersive_fullscreen_controller.h"
     11 #include "ash/wm/window_state_observer.h"
     12 #include "base/memory/scoped_ptr.h"
     13 #include "content/public/browser/notification_observer.h"
     14 #include "content/public/browser/notification_registrar.h"
     15 #include "ui/gfx/rect.h"
     16 
     17 namespace aura {
     18 class Window;
     19 }
     20 
     21 class ImmersiveModeControllerAsh
     22     : public ImmersiveModeController,
     23       public ash::ImmersiveFullscreenController::Delegate,
     24       public ash::wm::WindowStateObserver,
     25       public content::NotificationObserver {
     26  public:
     27   ImmersiveModeControllerAsh();
     28   virtual ~ImmersiveModeControllerAsh();
     29 
     30   // ImmersiveModeController overrides:
     31   virtual void Init(BrowserView* browser_view) OVERRIDE;
     32   virtual void SetEnabled(bool enabled) OVERRIDE;
     33   virtual bool IsEnabled() const OVERRIDE;
     34   virtual bool ShouldHideTabIndicators() const OVERRIDE;
     35   virtual bool ShouldHideTopViews() const OVERRIDE;
     36   virtual bool IsRevealed() const OVERRIDE;
     37   virtual int GetTopContainerVerticalOffset(
     38       const gfx::Size& top_container_size) const OVERRIDE;
     39   virtual ImmersiveRevealedLock* GetRevealedLock(
     40       AnimateReveal animate_reveal) OVERRIDE WARN_UNUSED_RESULT;
     41   virtual void OnFindBarVisibleBoundsChanged(
     42       const gfx::Rect& new_visible_bounds_in_screen) OVERRIDE;
     43   virtual void SetupForTest() OVERRIDE;
     44 
     45  private:
     46   // Enables or disables observers for window restore and entering / exiting
     47   // tab fullscreen.
     48   void EnableWindowObservers(bool enable);
     49 
     50   // Updates the browser root view's layout including window caption controls.
     51   void LayoutBrowserRootView();
     52 
     53   // Updates whether the tab strip is painted in a short "light bar" style.
     54   // Returns true if the visibility of the tab indicators has changed.
     55   bool UpdateTabIndicators();
     56 
     57   // ImmersiveFullscreenController::Delegate overrides:
     58   virtual void OnImmersiveRevealStarted() OVERRIDE;
     59   virtual void OnImmersiveRevealEnded() OVERRIDE;
     60   virtual void OnImmersiveFullscreenExited() OVERRIDE;
     61   virtual void SetVisibleFraction(double visible_fraction) OVERRIDE;
     62   virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() const OVERRIDE;
     63 
     64   // ash::wm::WindowStateObserver override:
     65   virtual void OnPostWindowStateTypeChange(
     66       ash::wm::WindowState* window_state,
     67       ash::wm::WindowStateType old_type) OVERRIDE;
     68 
     69   // content::NotificationObserver override:
     70   virtual void Observe(int type,
     71                        const content::NotificationSource& source,
     72                        const content::NotificationDetails& details) OVERRIDE;
     73 
     74   scoped_ptr<ash::ImmersiveFullscreenController> controller_;
     75 
     76   // Not owned.
     77   BrowserView* browser_view_;
     78   aura::Window* native_window_;
     79 
     80   // True if the observers for window restore and entering / exiting tab
     81   // fullscreen are enabled.
     82   bool observers_enabled_;
     83 
     84   // Whether a short "light bar" version of the tab strip should be painted when
     85   // the top-of-window views are closed. If |use_tab_indicators_| is false, the
     86   // tab strip is not painted at all when the top-of-window views are closed.
     87   bool use_tab_indicators_;
     88 
     89   // The current visible bounds of the find bar, in screen coordinates. This is
     90   // an empty rect if the find bar is not visible.
     91   gfx::Rect find_bar_visible_bounds_in_screen_;
     92 
     93   // The fraction of the TopContainerView's height which is visible. Zero when
     94   // the top-of-window views are not revealed regardless of
     95   // |use_tab_indicators_|.
     96   double visible_fraction_;
     97 
     98   content::NotificationRegistrar registrar_;
     99 
    100   DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAsh);
    101 };
    102 
    103 #endif  // CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_
    104