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" | 11 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
13 #include "ui/aura/window_observer.h" | |
13 #include "ui/base/events/event_handler.h" | 14 #include "ui/base/events/event_handler.h" |
14 #include "ui/compositor/layer_animation_observer.h" | 15 #include "ui/compositor/layer_animation_observer.h" |
15 #include "ui/views/focus/focus_manager.h" | 16 #include "ui/views/focus/focus_manager.h" |
16 #include "ui/views/widget/widget_observer.h" | 17 #include "ui/views/widget/widget_observer.h" |
17 | 18 |
18 class BrowserView; | 19 class BrowserView; |
19 class BookmarkBarView; | 20 class BookmarkBarView; |
20 class TopContainerView; | 21 class TopContainerView; |
21 | 22 |
22 namespace aura { | 23 namespace aura { |
(...skipping 10 matching lines...) Expand all Loading... | |
33 | 34 |
34 namespace views { | 35 namespace views { |
35 class View; | 36 class View; |
36 } | 37 } |
37 | 38 |
38 class ImmersiveModeControllerAsh : public ImmersiveModeController, | 39 class ImmersiveModeControllerAsh : public ImmersiveModeController, |
39 public content::NotificationObserver, | 40 public content::NotificationObserver, |
40 public ui::EventHandler, | 41 public ui::EventHandler, |
41 public ui::ImplicitAnimationObserver, | 42 public ui::ImplicitAnimationObserver, |
42 public views::FocusChangeListener, | 43 public views::FocusChangeListener, |
43 public views::WidgetObserver { | 44 public views::WidgetObserver, |
45 public aura::WindowObserver { | |
44 public: | 46 public: |
45 ImmersiveModeControllerAsh(); | 47 ImmersiveModeControllerAsh(); |
46 virtual ~ImmersiveModeControllerAsh(); | 48 virtual ~ImmersiveModeControllerAsh(); |
47 | 49 |
48 // These methods are used to increment and decrement |revealed_lock_count_|. | 50 // These methods are used to increment and decrement |revealed_lock_count_|. |
49 // If immersive mode is enabled, a transition from 1 to 0 in | 51 // If immersive mode is enabled, a transition from 1 to 0 in |
50 // |revealed_lock_count_| closes the top-of-window views and a transition | 52 // |revealed_lock_count_| closes the top-of-window views and a transition |
51 // from 0 to 1 in |revealed_lock_count_| reveals the top-of-window views. | 53 // from 0 to 1 in |revealed_lock_count_| reveals the top-of-window views. |
52 void LockRevealedState(AnimateReveal animate_reveal); | 54 void LockRevealedState(AnimateReveal animate_reveal); |
53 void UnlockRevealedState(); | 55 void UnlockRevealedState(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 views::View* focused_now) OVERRIDE; | 90 views::View* focused_now) OVERRIDE; |
89 | 91 |
90 // views::WidgetObserver overrides: | 92 // views::WidgetObserver overrides: |
91 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; | 93 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; |
92 virtual void OnWidgetActivationChanged(views::Widget* widget, | 94 virtual void OnWidgetActivationChanged(views::Widget* widget, |
93 bool active) OVERRIDE; | 95 bool active) OVERRIDE; |
94 | 96 |
95 // ui::ImplicitAnimationObserver override: | 97 // ui::ImplicitAnimationObserver override: |
96 virtual void OnImplicitAnimationsCompleted() OVERRIDE; | 98 virtual void OnImplicitAnimationsCompleted() OVERRIDE; |
97 | 99 |
100 // aura::WindowObserver overrides: | |
101 virtual void OnWindowPropertyChanged(aura::Window* window, | |
102 const void* key, | |
103 intptr_t old) OVERRIDE; | |
104 virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE; | |
105 virtual void OnWindowRemovedFromRootWindow(aura::Window* window) OVERRIDE; | |
106 | |
98 // Testing interface. | 107 // Testing interface. |
99 void SetForceHideTabIndicatorsForTest(bool force); | 108 void SetForceHideTabIndicatorsForTest(bool force); |
100 void StartRevealForTest(bool hovered); | 109 void StartRevealForTest(bool hovered); |
101 void SetMouseHoveredForTest(bool hovered); | 110 void SetMouseHoveredForTest(bool hovered); |
102 | 111 |
103 private: | 112 private: |
104 friend class ImmersiveModeControllerAshTest; | 113 friend class ImmersiveModeControllerAshTest; |
105 | 114 |
106 enum Animate { | 115 enum Animate { |
107 ANIMATE_NO, | 116 ANIMATE_NO, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 // Starts an animation for |layer| of |duration_ms| to |target_transform|. | 199 // Starts an animation for |layer| of |duration_ms| to |target_transform|. |
191 // If non-NULL, sets |observer| to be notified when the animation completes. | 200 // If non-NULL, sets |observer| to be notified when the animation completes. |
192 void DoLayerAnimation(ui::Layer* layer, | 201 void DoLayerAnimation(ui::Layer* layer, |
193 const gfx::Transform& target_transform, | 202 const gfx::Transform& target_transform, |
194 int duration_ms, | 203 int duration_ms, |
195 ui::ImplicitAnimationObserver* observer); | 204 ui::ImplicitAnimationObserver* observer); |
196 | 205 |
197 // Returns the type of swipe given |event|. | 206 // Returns the type of swipe given |event|. |
198 SwipeType GetSwipeType(ui::GestureEvent* event) const; | 207 SwipeType GetSwipeType(ui::GestureEvent* event) const; |
199 | 208 |
200 // True when |location| is "near" to the top container. When the top container | 209 // True when |location| is "near" to the top container. When the top container |
pkotwicz
2013/05/27 21:32:46
Nit: update the comment
rharrison
2013/05/28 17:03:01
Done.
| |
201 // is not closed "near" means within the displayed bounds. When the top | 210 // is not closed "near" means within the displayed bounds. When the top |
202 // container is closed "near" means either within the displayed bounds or | 211 // container is closed "near" means either within the displayed bounds or |
203 // within a few pixels of it. This allow the container to steal enough pixels | 212 // within a few pixels of it. This allow the container to steal enough pixels |
204 // to detect a swipe in. | 213 // to detect a swipe in. |
205 bool IsNearTopContainer(gfx::Point location) const; | 214 bool ShouldHandleEvent(const gfx::Point& location) const; |
215 | |
216 // Call Add/RemovePreTargerHandler since either the RootWindow has changed or | |
217 // the enabled state of observing has changed. | |
218 void SetPreTargetHandler(); | |
James Cook
2013/05/28 16:29:42
nit: Consider making this UpdatePreTargetHandler(b
rharrison
2013/05/28 17:03:01
Done.
| |
206 | 219 |
207 // Injected dependencies. Not owned. | 220 // Injected dependencies. Not owned. |
208 Delegate* delegate_; | 221 Delegate* delegate_; |
209 views::Widget* widget_; | 222 views::Widget* widget_; |
210 TopContainerView* top_container_; | 223 TopContainerView* top_container_; |
211 | 224 |
212 // True if the window observers are enabled. | 225 // True if the window observers are enabled. |
213 bool observers_enabled_; | 226 bool observers_enabled_; |
214 | 227 |
215 // True when in immersive mode. | 228 // True when in immersive mode. |
(...skipping 16 matching lines...) Expand all Loading... | |
232 int mouse_x_when_hit_top_; | 245 int mouse_x_when_hit_top_; |
233 | 246 |
234 // Lock which keeps the top-of-window views revealed based on the current | 247 // Lock which keeps the top-of-window views revealed based on the current |
235 // mouse state. | 248 // mouse state. |
236 scoped_ptr<ImmersiveRevealedLock> mouse_revealed_lock_; | 249 scoped_ptr<ImmersiveRevealedLock> mouse_revealed_lock_; |
237 | 250 |
238 // Lock which keeps the top-of-window views revealed based on the focused view | 251 // Lock which keeps the top-of-window views revealed based on the focused view |
239 // and the active widget. | 252 // and the active widget. |
240 scoped_ptr<ImmersiveRevealedLock> focus_revealed_lock_; | 253 scoped_ptr<ImmersiveRevealedLock> focus_revealed_lock_; |
241 | 254 |
242 // Native window for the browser, needed to clean up observers. | 255 // Native window for the browser. |
243 aura::Window* native_window_; | 256 aura::Window* native_window_; |
244 | 257 |
245 // Observer to disable immersive mode when window leaves the maximized state. | |
246 class WindowObserver; | |
247 scoped_ptr<WindowObserver> window_observer_; | |
248 | |
249 // Manages widgets which are anchored to the top-of-window views. | 258 // Manages widgets which are anchored to the top-of-window views. |
250 class AnchoredWidgetManager; | 259 class AnchoredWidgetManager; |
251 scoped_ptr<AnchoredWidgetManager> anchored_widget_manager_; | 260 scoped_ptr<AnchoredWidgetManager> anchored_widget_manager_; |
252 | 261 |
253 content::NotificationRegistrar registrar_; | 262 content::NotificationRegistrar registrar_; |
254 | 263 |
255 base::WeakPtrFactory<ImmersiveModeControllerAsh> weak_ptr_factory_; | 264 base::WeakPtrFactory<ImmersiveModeControllerAsh> weak_ptr_factory_; |
256 | 265 |
257 // Tracks if the controller has seen a ET_GESTURE_SCROLL_BEGIN, without the | 266 // Tracks if the controller has seen a ET_GESTURE_SCROLL_BEGIN, without the |
258 // following events. | 267 // following events. |
259 bool gesture_begun_; | 268 bool gesture_begun_; |
260 | 269 |
261 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAsh); | 270 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAsh); |
262 }; | 271 }; |
263 | 272 |
264 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ | 273 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ |
OLD | NEW |