Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 8 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
| 9 | 9 |
| 10 #include "base/timer.h" | 10 #include "base/timer.h" |
| 11 #include "content/public/browser/notification_observer.h" | |
| 12 #include "content/public/browser/notification_registrar.h" | |
| 11 #include "ui/base/events/event_handler.h" | 13 #include "ui/base/events/event_handler.h" |
| 12 #include "ui/compositor/layer_animation_observer.h" | 14 #include "ui/compositor/layer_animation_observer.h" |
| 13 #include "ui/views/focus/focus_manager.h" | 15 #include "ui/views/focus/focus_manager.h" |
| 14 #include "ui/views/widget/widget_observer.h" | 16 #include "ui/views/widget/widget_observer.h" |
| 15 | 17 |
| 16 class BrowserView; | 18 class BrowserView; |
| 17 | 19 |
| 18 namespace aura { | 20 namespace aura { |
| 19 class Window; | 21 class Window; |
| 20 } | 22 } |
| 21 | 23 |
| 22 namespace gfx { | 24 namespace gfx { |
| 23 class Transform; | 25 class Transform; |
| 24 } | 26 } |
| 25 | 27 |
| 26 namespace ui { | 28 namespace ui { |
| 27 class Layer; | 29 class Layer; |
| 28 } | 30 } |
| 29 | 31 |
| 30 namespace views { | 32 namespace views { |
| 31 class View; | 33 class View; |
| 32 } | 34 } |
| 33 | 35 |
| 34 class ImmersiveModeControllerAsh : public ImmersiveModeController, | 36 class ImmersiveModeControllerAsh : public ImmersiveModeController, |
| 37 public content::NotificationObserver, | |
| 35 public ui::EventHandler, | 38 public ui::EventHandler, |
| 36 public ui::ImplicitAnimationObserver, | 39 public ui::ImplicitAnimationObserver, |
| 37 public views::FocusChangeListener, | 40 public views::FocusChangeListener, |
| 38 public views::WidgetObserver { | 41 public views::WidgetObserver { |
| 39 public: | 42 public: |
| 40 ImmersiveModeControllerAsh(); | 43 ImmersiveModeControllerAsh(); |
| 41 virtual ~ImmersiveModeControllerAsh(); | 44 virtual ~ImmersiveModeControllerAsh(); |
| 42 | 45 |
| 43 // These methods are used to increment and decrement |revealed_lock_count_|. | 46 // These methods are used to increment and decrement |revealed_lock_count_|. |
| 44 // If immersive mode is enabled, a transition from 1 to 0 in | 47 // If immersive mode is enabled, a transition from 1 to 0 in |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 58 virtual bool ShouldHideTopViews() const OVERRIDE; | 61 virtual bool ShouldHideTopViews() const OVERRIDE; |
| 59 virtual bool IsRevealed() const OVERRIDE; | 62 virtual bool IsRevealed() const OVERRIDE; |
| 60 virtual void MaybeStackViewAtTop() OVERRIDE; | 63 virtual void MaybeStackViewAtTop() OVERRIDE; |
| 61 virtual ImmersiveModeController::RevealedLock* | 64 virtual ImmersiveModeController::RevealedLock* |
| 62 GetRevealedLock() OVERRIDE WARN_UNUSED_RESULT; | 65 GetRevealedLock() OVERRIDE WARN_UNUSED_RESULT; |
| 63 virtual void AnchorWidgetToTopContainer(views::Widget* widget, | 66 virtual void AnchorWidgetToTopContainer(views::Widget* widget, |
| 64 int y_offset) OVERRIDE; | 67 int y_offset) OVERRIDE; |
| 65 virtual void UnanchorWidgetFromTopContainer(views::Widget* widget) OVERRIDE; | 68 virtual void UnanchorWidgetFromTopContainer(views::Widget* widget) OVERRIDE; |
| 66 virtual void OnTopContainerBoundsChanged() OVERRIDE; | 69 virtual void OnTopContainerBoundsChanged() OVERRIDE; |
| 67 | 70 |
| 71 // content::NotificationObserver override: | |
| 72 virtual void Observe(int type, | |
| 73 const content::NotificationSource& source, | |
| 74 const content::NotificationDetails& details) OVERRIDE; | |
| 75 | |
| 68 // ui::EventHandler overrides: | 76 // ui::EventHandler overrides: |
| 69 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 77 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
| 70 | 78 |
| 71 // views::FocusChangeObserver overrides: | 79 // views::FocusChangeObserver overrides: |
| 72 virtual void OnWillChangeFocus(views::View* focused_before, | 80 virtual void OnWillChangeFocus(views::View* focused_before, |
| 73 views::View* focused_now) OVERRIDE; | 81 views::View* focused_now) OVERRIDE; |
| 74 virtual void OnDidChangeFocus(views::View* focused_before, | 82 virtual void OnDidChangeFocus(views::View* focused_before, |
| 75 views::View* focused_now) OVERRIDE; | 83 views::View* focused_now) OVERRIDE; |
| 76 | 84 |
| 77 // views::WidgetObserver overrides: | 85 // views::WidgetObserver overrides: |
| 78 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; | 86 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; |
| 79 virtual void OnWidgetActivationChanged(views::Widget* widget, | 87 virtual void OnWidgetActivationChanged(views::Widget* widget, |
| 80 bool active) OVERRIDE; | 88 bool active) OVERRIDE; |
| 81 | 89 |
| 82 // ui::ImplicitAnimationObserver override: | 90 // ui::ImplicitAnimationObserver override: |
| 83 virtual void OnImplicitAnimationsCompleted() OVERRIDE; | 91 virtual void OnImplicitAnimationsCompleted() OVERRIDE; |
| 84 | 92 |
| 85 // Testing interface. | 93 // Testing interface. |
| 86 void SetHideTabIndicatorsForTest(bool hide); | 94 void SetForceHideTabIndicatorsForTest(bool force); |
| 87 void StartRevealForTest(bool hovered); | 95 void StartRevealForTest(bool hovered); |
| 88 void SetMouseHoveredForTest(bool hovered); | 96 void SetMouseHoveredForTest(bool hovered); |
| 89 | 97 |
| 90 private: | 98 private: |
| 91 enum Animate { | 99 enum Animate { |
| 92 ANIMATE_NO, | 100 ANIMATE_NO, |
| 93 ANIMATE_SLOW, | 101 ANIMATE_SLOW, |
| 94 ANIMATE_FAST, | 102 ANIMATE_FAST, |
| 95 }; | 103 }; |
| 96 enum RevealState { | 104 enum RevealState { |
| 97 CLOSED, // Top container only showing tabstrip, y = 0. | 105 CLOSED, // Top container only showing tabstrip, y = 0. |
| 98 SLIDING_OPEN, // All views showing, y animating from -height to 0. | 106 SLIDING_OPEN, // All views showing, y animating from -height to 0. |
| 99 REVEALED, // All views showing, y = 0. | 107 REVEALED, // All views showing, y = 0. |
| 100 SLIDING_CLOSED, // All views showing, y animating from 0 to -height. | 108 SLIDING_CLOSED, // All views showing, y animating from 0 to -height. |
| 101 }; | 109 }; |
| 110 enum TabIndicatorVisibility { | |
| 111 TAB_INDICATORS_FORCE_HIDE, | |
| 112 TAB_INDICATORS_HIDE, | |
| 113 TAB_INDICATORS_SHOW | |
| 114 }; | |
| 102 | 115 |
| 103 // Enables or disables observers for mouse move, focus, and window restore. | 116 // Enables or disables observers for mouse move, focus, and window restore. |
| 104 void EnableWindowObservers(bool enable); | 117 void EnableWindowObservers(bool enable); |
| 105 | 118 |
| 106 // Update |mouse_revealed_lock_| based on the current mouse state and the | 119 // Update |mouse_revealed_lock_| based on the current mouse state and the |
| 107 // currently active widget. | 120 // currently active widget. |
| 108 // |maybe_drag| is true if the user may be in the middle of a drag. | 121 // |maybe_drag| is true if the user may be in the middle of a drag. |
| 109 void UpdateMouseRevealedLock(bool maybe_drag); | 122 void UpdateMouseRevealedLock(bool maybe_drag); |
| 110 | 123 |
| 111 // Acquire the mouse revealed lock if it is not already held. | 124 // Acquire the mouse revealed lock if it is not already held. |
| 112 void AcquireMouseRevealedLock(); | 125 void AcquireMouseRevealedLock(); |
| 113 | 126 |
| 114 // Update |focus_revealed_lock_| based on the currently active view and the | 127 // Update |focus_revealed_lock_| based on the currently active view and the |
| 115 // currently active widget. | 128 // currently active widget. |
| 116 void UpdateFocusRevealedLock(); | 129 void UpdateFocusRevealedLock(); |
| 117 | 130 |
| 131 // Updates whether fullscreen uses any chrome at all. When using minimal | |
| 132 // chrome, a 'light bar' is permanently visible for the launcher and possibly | |
| 133 // for the tabstrip. | |
| 134 // If |skip_layout| is true, no layout is done as part of the update. | |
| 135 void UpdateUseMinimalChrome(bool skip_layout); | |
|
James Cook
2013/04/22 18:14:16
Optional: Consider re-introducing the LAYOUT_YES,
| |
| 136 | |
| 118 // Returns the animation duration given |animate|. | 137 // Returns the animation duration given |animate|. |
| 119 int GetAnimationDuration(Animate animate) const; | 138 int GetAnimationDuration(Animate animate) const; |
| 120 | 139 |
| 121 // Temporarily reveals the top-of-window views while in immersive mode, | 140 // Temporarily reveals the top-of-window views while in immersive mode, |
| 122 // hiding them when the cursor exits the area of the top views. If |animate| | 141 // hiding them when the cursor exits the area of the top views. If |animate| |
| 123 // is not ANIMATE_NO, slides in the view, otherwise shows it immediately. | 142 // is not ANIMATE_NO, slides in the view, otherwise shows it immediately. |
| 124 void MaybeStartReveal(Animate animate); | 143 void MaybeStartReveal(Animate animate); |
| 125 | 144 |
| 126 // Enables or disables layer-based painting to allow smooth animations. | 145 // Enables or disables layer-based painting to allow smooth animations. |
| 127 void EnablePaintToLayer(bool enable); | 146 void EnablePaintToLayer(bool enable); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 157 BrowserView* browser_view_; | 176 BrowserView* browser_view_; |
| 158 | 177 |
| 159 // True when in immersive mode. | 178 // True when in immersive mode. |
| 160 bool enabled_; | 179 bool enabled_; |
| 161 | 180 |
| 162 // State machine for the revealed/closed animations. | 181 // State machine for the revealed/closed animations. |
| 163 RevealState reveal_state_; | 182 RevealState reveal_state_; |
| 164 | 183 |
| 165 int revealed_lock_count_; | 184 int revealed_lock_count_; |
| 166 | 185 |
| 167 // True if the miniature "tab indicators" should be hidden in the main browser | 186 // The visibility of the miniature "tab indicators" in the main browser view |
| 168 // view when immersive mode is enabled. | 187 // when immersive mode is enabled and the top-of-window views are closed. |
| 169 bool hide_tab_indicators_; | 188 TabIndicatorVisibility tab_indicator_visibility_; |
| 170 | 189 |
| 171 // Timer to track cursor being held at the top. | 190 // Timer to track cursor being held at the top. |
| 172 base::OneShotTimer<ImmersiveModeController> top_timer_; | 191 base::OneShotTimer<ImmersiveModeController> top_timer_; |
| 173 | 192 |
| 174 // Lock which keeps the top-of-window views revealed based on the current | 193 // Lock which keeps the top-of-window views revealed based on the current |
| 175 // mouse state. | 194 // mouse state. |
| 176 scoped_ptr<RevealedLock> mouse_revealed_lock_; | 195 scoped_ptr<RevealedLock> mouse_revealed_lock_; |
| 177 | 196 |
| 178 // Lock which keeps the top-of-window views revealed based on the focused view | 197 // Lock which keeps the top-of-window views revealed based on the focused view |
| 179 // and the active widget. | 198 // and the active widget. |
| 180 scoped_ptr<RevealedLock> focus_revealed_lock_; | 199 scoped_ptr<RevealedLock> focus_revealed_lock_; |
| 181 | 200 |
| 182 // Native window for the browser, needed to clean up observers. | 201 // Native window for the browser, needed to clean up observers. |
| 183 aura::Window* native_window_; | 202 aura::Window* native_window_; |
| 184 | 203 |
| 185 // Observer to disable immersive mode when window leaves the maximized state. | 204 // Observer to disable immersive mode when window leaves the maximized state. |
| 186 class WindowObserver; | 205 class WindowObserver; |
| 187 scoped_ptr<WindowObserver> window_observer_; | 206 scoped_ptr<WindowObserver> window_observer_; |
| 188 | 207 |
| 189 // Manages widgets which are anchored to the top-of-window views. | 208 // Manages widgets which are anchored to the top-of-window views. |
| 190 class AnchoredWidgetManager; | 209 class AnchoredWidgetManager; |
| 191 scoped_ptr<AnchoredWidgetManager> anchored_widget_manager_; | 210 scoped_ptr<AnchoredWidgetManager> anchored_widget_manager_; |
| 192 | 211 |
| 212 content::NotificationRegistrar registrar_; | |
| 213 | |
| 193 base::WeakPtrFactory<ImmersiveModeControllerAsh> weak_ptr_factory_; | 214 base::WeakPtrFactory<ImmersiveModeControllerAsh> weak_ptr_factory_; |
| 194 | 215 |
| 195 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAsh); | 216 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAsh); |
| 196 }; | 217 }; |
| 197 | 218 |
| 198 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ | 219 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ |
| OLD | NEW |