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 OnWindowRemovingFromRootWindow(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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
201 // is not closed "near" means within the displayed bounds. When the top | 210 // is not closed "near" means within the displayed bounds or above it. When |
202 // container is closed "near" means either within the displayed bounds or | 211 // the top container is closed "near" means either within the displayed |
203 // within a few pixels of it. This allow the container to steal enough pixels | 212 // bounds, above it, or within a few pixels below it. This allow the container |
204 // to detect a swipe in. | 213 // to steal enough pixels to detect a swipe in and handles the case that there |
205 bool IsNearTopContainer(gfx::Point location) const; | 214 // is a bezel sensor above the top container. |
| 215 bool ShouldHandleEvent(const gfx::Point& location) const; |
| 216 |
| 217 // Call Add/RemovePreTargerHandler since either the RootWindow has changed or |
| 218 // the enabled state of observing has changed. |
| 219 void UpdatePreTargetHandler(); |
206 | 220 |
207 // Injected dependencies. Not owned. | 221 // Injected dependencies. Not owned. |
208 Delegate* delegate_; | 222 Delegate* delegate_; |
209 views::Widget* widget_; | 223 views::Widget* widget_; |
210 TopContainerView* top_container_; | 224 TopContainerView* top_container_; |
211 | 225 |
212 // True if the window observers are enabled. | 226 // True if the window observers are enabled. |
213 bool observers_enabled_; | 227 bool observers_enabled_; |
214 | 228 |
215 // True when in immersive mode. | 229 // True when in immersive mode. |
(...skipping 16 matching lines...) Expand all Loading... |
232 int mouse_x_when_hit_top_; | 246 int mouse_x_when_hit_top_; |
233 | 247 |
234 // Lock which keeps the top-of-window views revealed based on the current | 248 // Lock which keeps the top-of-window views revealed based on the current |
235 // mouse state. | 249 // mouse state. |
236 scoped_ptr<ImmersiveRevealedLock> mouse_revealed_lock_; | 250 scoped_ptr<ImmersiveRevealedLock> mouse_revealed_lock_; |
237 | 251 |
238 // Lock which keeps the top-of-window views revealed based on the focused view | 252 // Lock which keeps the top-of-window views revealed based on the focused view |
239 // and the active widget. | 253 // and the active widget. |
240 scoped_ptr<ImmersiveRevealedLock> focus_revealed_lock_; | 254 scoped_ptr<ImmersiveRevealedLock> focus_revealed_lock_; |
241 | 255 |
242 // Native window for the browser, needed to clean up observers. | 256 // Native window for the browser. |
243 aura::Window* native_window_; | 257 aura::Window* native_window_; |
244 | 258 |
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. | 259 // Manages widgets which are anchored to the top-of-window views. |
250 class AnchoredWidgetManager; | 260 class AnchoredWidgetManager; |
251 scoped_ptr<AnchoredWidgetManager> anchored_widget_manager_; | 261 scoped_ptr<AnchoredWidgetManager> anchored_widget_manager_; |
252 | 262 |
253 content::NotificationRegistrar registrar_; | 263 content::NotificationRegistrar registrar_; |
254 | 264 |
255 base::WeakPtrFactory<ImmersiveModeControllerAsh> weak_ptr_factory_; | 265 base::WeakPtrFactory<ImmersiveModeControllerAsh> weak_ptr_factory_; |
256 | 266 |
257 // Tracks if the controller has seen a ET_GESTURE_SCROLL_BEGIN, without the | 267 // Tracks if the controller has seen a ET_GESTURE_SCROLL_BEGIN, without the |
258 // following events. | 268 // following events. |
259 bool gesture_begun_; | 269 bool gesture_begun_; |
260 | 270 |
261 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAsh); | 271 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAsh); |
262 }; | 272 }; |
263 | 273 |
264 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ | 274 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_IMMERSIVE_MODE_CONTROLLER_ASH_H_ |
OLD | NEW |