Chromium Code Reviews| Index: ash/wm/immersive_fullscreen_controller.h |
| diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.h b/ash/wm/immersive_fullscreen_controller.h |
| similarity index 59% |
| copy from chrome/browser/ui/views/frame/immersive_mode_controller_ash.h |
| copy to ash/wm/immersive_fullscreen_controller.h |
| index 8255e119e5c8b6c3cc0d94e35fbb09dfe7c8242b..434a2c3e78c8e796fe9835c935067c5b0de3233d 100644 |
| --- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.h |
| +++ b/ash/wm/immersive_fullscreen_controller.h |
| @@ -2,14 +2,14 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ |
| -#define CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ |
| +#ifndef ASH_WM_IMMERSIVE_FULLSCREEN_CONTROLLER_H_ |
| +#define ASH_WM_IMMERSIVE_FULLSCREEN_CONTROLLER_H_ |
| -#include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
| +#include <vector> |
| +#include "ash/ash_export.h" |
| +#include "ash/wm/immersive_revealed_lock.h" |
| #include "base/timer/timer.h" |
| -#include "content/public/browser/notification_observer.h" |
| -#include "content/public/browser/notification_registrar.h" |
| #include "ui/aura/window_observer.h" |
| #include "ui/events/event_handler.h" |
| #include "ui/gfx/animation/animation_delegate.h" |
| @@ -17,66 +17,96 @@ |
| #include "ui/views/focus/focus_manager.h" |
| #include "ui/views/widget/widget_observer.h" |
| -class BrowserView; |
| -class BookmarkBarView; |
| - |
| namespace aura { |
| class Window; |
| } |
| namespace gfx { |
| class SlideAnimation; |
| -class Transform; |
| } |
| namespace ui { |
| -class Layer; |
| class LocatedEvent; |
| } |
| namespace views { |
| class View; |
| +class Widget; |
| } |
| -class ImmersiveModeControllerAsh : public ImmersiveModeController, |
| - public content::NotificationObserver, |
| - public gfx::AnimationDelegate, |
| - public ui::EventHandler, |
| - public views::FocusChangeListener, |
| - public views::WidgetObserver, |
| - public aura::WindowObserver { |
| +namespace ash { |
| + |
| +class ASH_EXPORT ImmersiveFullscreenController |
| + : public gfx::AnimationDelegate, |
| + public ui::EventHandler, |
| + public views::FocusChangeListener, |
| + public views::WidgetObserver, |
| + public aura::WindowObserver, |
| + public ImmersiveRevealedLock::Delegate { |
| public: |
| - ImmersiveModeControllerAsh(); |
| - virtual ~ImmersiveModeControllerAsh(); |
| - |
| - // These methods are used to increment and decrement |revealed_lock_count_|. |
| - // If immersive mode is enabled, a transition from 1 to 0 in |
| - // |revealed_lock_count_| closes the top-of-window views and a transition |
| - // from 0 to 1 in |revealed_lock_count_| reveals the top-of-window views. |
| - void LockRevealedState(AnimateReveal animate_reveal); |
| - void UnlockRevealedState(); |
| - |
| - // ImmersiveModeController overrides: |
| - virtual void Init(Delegate* delegate, |
| - views::Widget* widget, |
| - views::View* top_container) OVERRIDE; |
| - virtual void SetEnabled(bool enabled) OVERRIDE; |
| - virtual bool IsEnabled() const OVERRIDE; |
| - virtual bool ShouldHideTabIndicators() const OVERRIDE; |
| - virtual bool ShouldHideTopViews() const OVERRIDE; |
| - virtual bool IsRevealed() const OVERRIDE; |
| - virtual int GetTopContainerVerticalOffset( |
| - const gfx::Size& top_container_size) const OVERRIDE; |
| - virtual ImmersiveRevealedLock* GetRevealedLock( |
| - AnimateReveal animate_reveal) OVERRIDE WARN_UNUSED_RESULT; |
| - virtual void OnFindBarVisibleBoundsChanged( |
| - const gfx::Rect& new_visible_bounds_in_screen) OVERRIDE; |
| - virtual void SetupForTest() OVERRIDE; |
| - |
| - // content::NotificationObserver override: |
| - virtual void Observe(int type, |
| - const content::NotificationSource& source, |
| - const content::NotificationDetails& details) OVERRIDE; |
| + class Delegate { |
| + public: |
| + // Called when a reveal of the top-of-window views starts. |
| + virtual void OnImmersiveRevealStarted() = 0; |
| + |
| + // Called when the top-of-window views have finished closing. This call |
| + // implies a visibility of 0. SetVisibility(0) may not be called prior to |
| + // OnImmersiveRevealEnded(). |
| + virtual void OnImmersiveRevealEnded() = 0; |
| + |
| + // Called as a result of disabling immersive fullscreen via SetEnabled(). |
| + virtual void OnImmersiveFullscreenExited() = 0; |
| + |
| + // Called to update the fraction of the top-of-window views height which is |
| + // visible. |
| + virtual void SetVisibility(double visible_fraction) = 0; |
|
James Cook
2013/10/28 18:32:51
I initially thought this was either like SetVisibl
pkotwicz
2013/10/29 04:32:45
Done.
|
| + |
| + // Returns a list of rects whose union make up the top-of-window views. |
| + // The returned list is used for hittesting when the top-of-window views |
| + // are revealed. |
| + virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() = 0; |
| + |
| + protected: |
| + virtual ~Delegate() {} |
| + }; |
| + |
| + ImmersiveFullscreenController(); |
| + virtual ~ImmersiveFullscreenController(); |
| + |
| + // Initializes the controller. Must be called prior to enabling immersive |
| + // fullscreen via SetEnabled(). |top_container| is used to keep the |
| + // top-of-window views revealed when a child of |top_container| has focus. |
| + // |top_container| has no effect on which mouse and touch events keep the |
| + // top-of-window views revealed. |
| + void Init(Delegate* delegate, |
| + views::Widget* widget, |
| + views::View* top_container); |
| + |
| + // Enables or disables immersive fullscreen. |
| + void SetEnabled(bool enable); |
| + |
| + // Returns true if |native_window_| is in immersive fullscreen. |
| + bool IsEnabled() const; |
| + |
| + // Returns true if |native_window_| is in immersive fullscreen and the |
| + // top-of-window views are fully or partially visible. |
| + bool IsRevealed() const; |
| + |
| + // Returns a lock which will keep the top-of-window views revealed for its |
| + // lifetime. Several locks can be obtained. When all of the locks are |
| + // destroyed, if immersive fullscreen is enabled and there is nothing else |
| + // keeping the top-of-window views revealed, the top-of-window views will be |
| + // closed. This method always returns a valid lock regardless of whether |
| + // immersive fullscreen is enabled. The lock's lifetime can span immersive |
| + // fullscreen being enabled / disabled. If acquiring the lock causes a reveal, |
| + // the top-of-window views will animate according to |animate_reveal|. The |
| + // caller takes ownership of the returned lock. |
| + ImmersiveRevealedLock* GetRevealedLock( |
| + AnimateReveal animate_reveal) WARN_UNUSED_RESULT; |
| + |
| + // Disables animations and moves the mouse so that it is not over the |
| + // top-of-window views for the sake of testing. |
| + void SetupForTest(); |
| // ui::EventHandler overrides: |
| virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
| @@ -99,16 +129,17 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController, |
| virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| // aura::WindowObserver overrides: |
| - virtual void OnWindowPropertyChanged(aura::Window* window, |
| - const void* key, |
| - intptr_t old) OVERRIDE; |
| virtual void OnAddTransientChild(aura::Window* window, |
| aura::Window* transient) OVERRIDE; |
| virtual void OnRemoveTransientChild(aura::Window* window, |
| aura::Window* transient) OVERRIDE; |
| + // ash::ImmersiveRevealedLock::Delegate overrides: |
| + virtual void LockRevealedState(AnimateReveal animate_reveal) OVERRIDE; |
| + virtual void UnlockRevealedState() OVERRIDE; |
| + |
| private: |
| - friend class ImmersiveModeControllerAshTest; |
| + friend class ImmersiveFullscreenControllerTest; |
| enum AllowRevealWhileClosing { |
| ALLOW_REVEAL_WHILE_CLOSING_YES, |
| @@ -119,20 +150,11 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController, |
| ANIMATE_SLOW, |
| ANIMATE_FAST, |
| }; |
| - enum Layout { |
| - LAYOUT_YES, |
| - LAYOUT_NO |
| - }; |
| enum RevealState { |
| - CLOSED, // Top container only showing tabstrip, y = 0. |
| - SLIDING_OPEN, // All views showing, y animating from -height to 0. |
| - REVEALED, // All views showing, y = 0. |
| - SLIDING_CLOSED, // All views showing, y animating from 0 to -height. |
| - }; |
| - enum TabIndicatorVisibility { |
| - TAB_INDICATORS_FORCE_HIDE, |
| - TAB_INDICATORS_HIDE, |
| - TAB_INDICATORS_SHOW |
| + CLOSED, |
|
James Cook
2013/10/28 18:32:51
Are the old comments no longer accurate? What hap
pkotwicz
2013/10/29 04:32:45
The y position is actually an implementation detai
|
| + SLIDING_OPEN, |
| + REVEALED, |
| + SLIDING_CLOSED, |
| }; |
| enum SwipeType { |
| SWIPE_OPEN, |
| @@ -140,7 +162,7 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController, |
| SWIPE_NONE |
| }; |
| - // Enables or disables observers for mouse move, focus, and window restore. |
| + // Enables or disables observers for mouse, touch, focus, and activation. |
| void EnableWindowObservers(bool enable); |
| // Updates |top_edge_hover_timer_| based on a mouse |event|. If the mouse is |
| @@ -171,11 +193,6 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController, |
| // acquired or released. |
| bool UpdateRevealedLocksForSwipe(SwipeType swipe_type); |
| - // Updates whether fullscreen uses any chrome at all. When using minimal |
| - // chrome, a 'light bar' is permanently visible for the launcher and possibly |
| - // for the tabstrip. |
| - void UpdateUseMinimalChrome(Layout layout); |
| - |
| // Returns the animation duration given |animate|. |
| int GetAnimationDuration(Animate animate) const; |
| @@ -184,12 +201,9 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController, |
| // is not ANIMATE_NO, slides in the view, otherwise shows it immediately. |
| void MaybeStartReveal(Animate animate); |
| - // Updates the browser root view's layout including window caption controls. |
| - void LayoutBrowserRootView(); |
| - |
| // Called when the animation to slide open the top-of-window views has |
| // completed. |
| - void OnSlideOpenAnimationCompleted(Layout layout); |
| + void OnSlideOpenAnimationCompleted(); |
| // Hides the top-of-window views if immersive mode is enabled and nothing is |
| // keeping them revealed. Optionally animates. |
| @@ -220,22 +234,16 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController, |
| // child of |top_container_|. |
| void RecreateBubbleManager(); |
| - // Shrinks or expands the touch hit test by updating insets for the render |
| - // window depending on if top_inset is positive or negative respectively. |
| - // Used to ensure that touch events at the top of the screen go to the top |
| - // container so a slide gesture can be generated when the content window is |
| - // consuming all touch events sent to it. |
| - void SetRenderWindowTopInsetsForTouch(int top_inset); |
| - |
| - // Injected dependencies. Not owned. |
| + // Not owned. |
| Delegate* delegate_; |
| - views::Widget* widget_; |
| views::View* top_container_; |
| + views::Widget* widget_; |
| + aura::Window* native_window_; |
| - // True if the window observers are enabled. |
| + // True if the observers have been enabled. |
| bool observers_enabled_; |
| - // True when in immersive mode. |
| + // True when in immersive fullscreen. |
| bool enabled_; |
| // State machine for the revealed/closed animations. |
| @@ -243,12 +251,8 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController, |
| int revealed_lock_count_; |
| - // The visibility of the miniature "tab indicators" in the main browser view |
| - // when immersive mode is enabled and the top-of-window views are closed. |
| - TabIndicatorVisibility tab_indicator_visibility_; |
| - |
| // Timer to track cursor being held at the top edge of the screen. |
| - base::OneShotTimer<ImmersiveModeController> top_edge_hover_timer_; |
| + base::OneShotTimer<ImmersiveFullscreenController> top_edge_hover_timer_; |
| // The cursor x position in screen coordinates when the cursor first hit the |
| // top edge of the screen. |
| @@ -258,10 +262,6 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController, |
| // following events. |
| bool gesture_begun_; |
| - // The current visible bounds of the find bar, in screen coordinates. This is |
| - // an empty rect if the find bar is not visible. |
| - gfx::Rect find_bar_visible_bounds_in_screen_; |
| - |
| // Lock which keeps the top-of-window views revealed based on the current |
| // mouse state and the current touch state. Acquiring the lock is used to |
| // trigger a reveal when the user moves the mouse to the top of the screen |
| @@ -273,9 +273,6 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController, |
| // a view is not focusable till a reveal has made it visible. |
| scoped_ptr<ImmersiveRevealedLock> focus_revealed_lock_; |
| - // Native window for the browser. |
| - aura::Window* native_window_; |
| - |
| // The animation which controls sliding the top-of-window views in and out. |
| scoped_ptr<gfx::SlideAnimation> animation_; |
| @@ -286,11 +283,11 @@ class ImmersiveModeControllerAsh : public ImmersiveModeController, |
| class BubbleManager; |
| scoped_ptr<BubbleManager> bubble_manager_; |
| - content::NotificationRegistrar registrar_; |
| + base::WeakPtrFactory<ImmersiveFullscreenController> weak_ptr_factory_; |
| - base::WeakPtrFactory<ImmersiveModeControllerAsh> weak_ptr_factory_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAsh); |
| + DISALLOW_COPY_AND_ASSIGN(ImmersiveFullscreenController); |
| }; |
| -#endif // CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ |
| +} // namespace ash |
| + |
| +#endif // ASH_WM_IMMERSIVE_FULLSREEN_CONTROLLER_H_ |
|
James Cook
2013/10/28 18:32:51
FULLSREEN -> FULLSCREEN
pkotwicz
2013/10/29 04:32:45
Done.
|