| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 ASH_WM_IMMERSIVE_FULLSCREEN_CONTROLLER_H_ | 5 #ifndef ASH_SHARED_IMMERSIVE_FULLSCREEN_CONTROLLER_H_ |
| 6 #define ASH_WM_IMMERSIVE_FULLSCREEN_CONTROLLER_H_ | 6 #define ASH_SHARED_IMMERSIVE_FULLSCREEN_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
| 12 #include "ash/common/wm/immersive/wm_immersive_fullscreen_controller.h" | 12 #include "ash/shared/immersive_revealed_lock.h" |
| 13 #include "ash/common/wm/immersive_revealed_lock.h" | |
| 14 #include "base/macros.h" | 13 #include "base/macros.h" |
| 15 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 16 #include "ui/gfx/animation/animation_delegate.h" | 15 #include "ui/gfx/animation/animation_delegate.h" |
| 17 #include "ui/views/pointer_watcher.h" | 16 #include "ui/views/pointer_watcher.h" |
| 18 #include "ui/views/widget/widget_observer.h" | 17 #include "ui/views/widget/widget_observer.h" |
| 19 | 18 |
| 20 namespace gfx { | 19 namespace gfx { |
| 21 class Point; | 20 class Point; |
| 22 class SlideAnimation; | 21 class SlideAnimation; |
| 23 } | 22 } |
| 24 | 23 |
| 25 namespace ui { | 24 namespace ui { |
| 26 class GestureEvent; | 25 class GestureEvent; |
| 27 class LocatedEvent; | 26 class LocatedEvent; |
| 28 class MouseEvent; | 27 class MouseEvent; |
| 29 class TouchEvent; | 28 class TouchEvent; |
| 30 } | 29 } |
| 31 | 30 |
| 32 namespace views { | 31 namespace views { |
| 33 class View; | 32 class View; |
| 34 class Widget; | 33 class Widget; |
| 35 } | 34 } |
| 36 | 35 |
| 37 namespace ash { | 36 namespace ash { |
| 38 | 37 |
| 39 class ImmersiveFocusWatcher; | 38 class ImmersiveFocusWatcher; |
| 39 class ImmersiveFullscreenControllerDelegate; |
| 40 class ImmersiveFullscreenControllerTestApi; | 40 class ImmersiveFullscreenControllerTestApi; |
| 41 class ImmersiveGestureHandler; | 41 class ImmersiveGestureHandler; |
| 42 class WmWindow; | 42 class WmWindow; |
| 43 | 43 |
| 44 class ASH_EXPORT ImmersiveFullscreenController | 44 class ASH_EXPORT ImmersiveFullscreenController |
| 45 : public WmImmersiveFullscreenController, | 45 : public gfx::AnimationDelegate, |
| 46 public gfx::AnimationDelegate, | |
| 47 public views::PointerWatcher, | 46 public views::PointerWatcher, |
| 48 public views::WidgetObserver, | 47 public views::WidgetObserver, |
| 49 public ImmersiveRevealedLock::Delegate { | 48 public ImmersiveRevealedLock::Delegate { |
| 50 public: | 49 public: |
| 50 // The enum is used for an enumerated histogram. New items should be only |
| 51 // added to the end. |
| 52 enum WindowType { |
| 53 WINDOW_TYPE_OTHER, |
| 54 WINDOW_TYPE_BROWSER, |
| 55 WINDOW_TYPE_HOSTED_APP, |
| 56 WINDOW_TYPE_PACKAGED_APP, |
| 57 WINDOW_TYPE_COUNT |
| 58 }; |
| 59 |
| 60 // How many pixels are reserved for touch-events towards the top of an |
| 61 // immersive-fullscreen window. |
| 62 static const int kImmersiveFullscreenTopEdgeInset; |
| 63 |
| 51 static const int kMouseRevealBoundsHeight; | 64 static const int kMouseRevealBoundsHeight; |
| 52 | 65 |
| 53 ImmersiveFullscreenController(); | 66 ImmersiveFullscreenController(); |
| 54 ~ImmersiveFullscreenController() override; | 67 ~ImmersiveFullscreenController() override; |
| 55 | 68 |
| 56 // WmImmersiveFullscreenController overrides: | 69 // Initializes the controller. Must be called prior to enabling immersive |
| 57 void Init(WmImmersiveFullscreenControllerDelegate* delegate, | 70 // fullscreen via SetEnabled(). |top_container| is used to keep the |
| 71 // top-of-window views revealed when a child of |top_container| has focus. |
| 72 // |top_container| does not affect which mouse and touch events keep the |
| 73 // top-of-window views revealed. |widget| is the widget to make fullscreen. |
| 74 void Init(ImmersiveFullscreenControllerDelegate* delegate, |
| 58 views::Widget* widget, | 75 views::Widget* widget, |
| 59 views::View* top_container) override; | 76 views::View* top_container); |
| 60 void SetEnabled(WindowType window_type, bool enable) override; | 77 |
| 61 bool IsEnabled() const override; | 78 // Enables or disables immersive fullscreen. |
| 62 bool IsRevealed() const override; | 79 // |window_type| is the type of window which is put in immersive fullscreen. |
| 80 // It is only used for histogramming. |
| 81 void SetEnabled(WindowType window_type, bool enable); |
| 82 |
| 83 // Returns true if in immersive fullscreen. |
| 84 bool IsEnabled() const; |
| 85 |
| 86 // Returns true if in immersive fullscreen and the top-of-window views are |
| 87 // fully or partially visible. |
| 88 bool IsRevealed() const; |
| 63 | 89 |
| 64 // Returns a lock which will keep the top-of-window views revealed for its | 90 // Returns a lock which will keep the top-of-window views revealed for its |
| 65 // lifetime. Several locks can be obtained. When all of the locks are | 91 // lifetime. Several locks can be obtained. When all of the locks are |
| 66 // destroyed, if immersive fullscreen is enabled and there is nothing else | 92 // destroyed, if immersive fullscreen is enabled and there is nothing else |
| 67 // keeping the top-of-window views revealed, the top-of-window views will be | 93 // keeping the top-of-window views revealed, the top-of-window views will be |
| 68 // closed. This method always returns a valid lock regardless of whether | 94 // closed. This method always returns a valid lock regardless of whether |
| 69 // immersive fullscreen is enabled. The lock's lifetime can span immersive | 95 // immersive fullscreen is enabled. The lock's lifetime can span immersive |
| 70 // fullscreen being enabled / disabled. If acquiring the lock causes a reveal, | 96 // fullscreen being enabled / disabled. If acquiring the lock causes a reveal, |
| 71 // the top-of-window views will animate according to |animate_reveal|. The | 97 // the top-of-window views will animate according to |animate_reveal|. The |
| 72 // caller takes ownership of the returned lock. | 98 // caller takes ownership of the returned lock. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // the top container is closed "near" means either within the displayed | 213 // the top container is closed "near" means either within the displayed |
| 188 // bounds, above it, or within a few pixels below it. This allow the container | 214 // bounds, above it, or within a few pixels below it. This allow the container |
| 189 // to steal enough pixels to detect a swipe in and handles the case that there | 215 // to steal enough pixels to detect a swipe in and handles the case that there |
| 190 // is a bezel sensor above the top container. | 216 // is a bezel sensor above the top container. |
| 191 bool ShouldHandleGestureEvent(const gfx::Point& location) const; | 217 bool ShouldHandleGestureEvent(const gfx::Point& location) const; |
| 192 | 218 |
| 193 // Returns the display bounds of the screen |widget_| is on. | 219 // Returns the display bounds of the screen |widget_| is on. |
| 194 gfx::Rect GetDisplayBoundsInScreen() const; | 220 gfx::Rect GetDisplayBoundsInScreen() const; |
| 195 | 221 |
| 196 // Not owned. | 222 // Not owned. |
| 197 WmImmersiveFullscreenControllerDelegate* delegate_; | 223 ImmersiveFullscreenControllerDelegate* delegate_; |
| 198 views::View* top_container_; | 224 views::View* top_container_; |
| 199 views::Widget* widget_; | 225 views::Widget* widget_; |
| 200 // The WmWindow for |widget_|. | 226 // The WmWindow for |widget_|. |
| 201 WmWindow* widget_window_ = nullptr; | 227 WmWindow* widget_window_ = nullptr; |
| 202 | 228 |
| 203 // True if the observers have been enabled. | 229 // True if the observers have been enabled. |
| 204 bool observers_enabled_; | 230 bool observers_enabled_; |
| 205 | 231 |
| 206 // True when in immersive fullscreen. | 232 // True when in immersive fullscreen. |
| 207 bool enabled_; | 233 bool enabled_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 237 std::unique_ptr<ImmersiveFocusWatcher> immersive_focus_watcher_; | 263 std::unique_ptr<ImmersiveFocusWatcher> immersive_focus_watcher_; |
| 238 std::unique_ptr<ImmersiveGestureHandler> immersive_gesture_handler_; | 264 std::unique_ptr<ImmersiveGestureHandler> immersive_gesture_handler_; |
| 239 | 265 |
| 240 base::WeakPtrFactory<ImmersiveFullscreenController> weak_ptr_factory_; | 266 base::WeakPtrFactory<ImmersiveFullscreenController> weak_ptr_factory_; |
| 241 | 267 |
| 242 DISALLOW_COPY_AND_ASSIGN(ImmersiveFullscreenController); | 268 DISALLOW_COPY_AND_ASSIGN(ImmersiveFullscreenController); |
| 243 }; | 269 }; |
| 244 | 270 |
| 245 } // namespace ash | 271 } // namespace ash |
| 246 | 272 |
| 247 #endif // ASH_WM_IMMERSIVE_FULLSCREEN_CONTROLLER_H_ | 273 #endif // ASH_SHARED_IMMERSIVE_FULLSCREEN_CONTROLLER_H_ |
| OLD | NEW |