| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 5 #ifndef ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
| 6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "ash/accelerometer/accelerometer_observer.h" | 8 #include "ash/accelerometer/accelerometer_observer.h" |
| 9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
| 10 #include "ash/display/display_controller.h" | 10 #include "ash/display/display_controller.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 namespace ui { | 26 namespace ui { |
| 27 class EventHandler; | 27 class EventHandler; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace ash { | 30 namespace ash { |
| 31 | 31 |
| 32 class MaximizeModeControllerTest; | 32 class MaximizeModeControllerTest; |
| 33 class ScopedDisableInternalMouseAndKeyboard; | 33 class ScopedDisableInternalMouseAndKeyboard; |
| 34 class MaximizeModeWindowManager; | 34 class MaximizeModeWindowManager; |
| 35 class MaximizeModeWindowManagerTest; | 35 class MaximizeModeWindowManagerTest; |
| 36 namespace test { |
| 37 class MultiUserWindowManagerChromeOSTest; |
| 38 } |
| 36 | 39 |
| 37 // MaximizeModeController listens to accelerometer events and automatically | 40 // MaximizeModeController listens to accelerometer events and automatically |
| 38 // enters and exits maximize mode when the lid is opened beyond the triggering | 41 // enters and exits maximize mode when the lid is opened beyond the triggering |
| 39 // angle and rotates the display to match the device when in maximize mode. | 42 // angle and rotates the display to match the device when in maximize mode. |
| 40 class ASH_EXPORT MaximizeModeController | 43 class ASH_EXPORT MaximizeModeController |
| 41 : public AccelerometerObserver, | 44 : public AccelerometerObserver, |
| 42 #if defined(OS_CHROMEOS) | 45 #if defined(OS_CHROMEOS) |
| 43 public chromeos::PowerManagerClient::Observer, | 46 public chromeos::PowerManagerClient::Observer, |
| 44 #endif // OS_CHROMEOS | 47 #endif // OS_CHROMEOS |
| 45 public ShellObserver, | 48 public ShellObserver, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // TODO(jonross): Merge this with EnterMaximizeMode. Currently these are | 88 // TODO(jonross): Merge this with EnterMaximizeMode. Currently these are |
| 86 // separate for several reasons: there is no internal display when running | 89 // separate for several reasons: there is no internal display when running |
| 87 // unittests; the event blocker prevents keyboard input when running ChromeOS | 90 // unittests; the event blocker prevents keyboard input when running ChromeOS |
| 88 // on linux. http://crbug.com/362881 | 91 // on linux. http://crbug.com/362881 |
| 89 // Turn the always maximize mode window manager on or off. | 92 // Turn the always maximize mode window manager on or off. |
| 90 void EnableMaximizeModeWindowManager(bool enable); | 93 void EnableMaximizeModeWindowManager(bool enable); |
| 91 | 94 |
| 92 // Test if the MaximizeModeWindowManager is enabled or not. | 95 // Test if the MaximizeModeWindowManager is enabled or not. |
| 93 bool IsMaximizeModeWindowManagerEnabled() const; | 96 bool IsMaximizeModeWindowManagerEnabled() const; |
| 94 | 97 |
| 98 // Add a special window to the MaximizeModeWindowManager for tracking. This is |
| 99 // only required for special windows which are handled by other window |
| 100 // managers like the |MultiUserWindowManager|. |
| 101 // If the maximize mode is not enabled no action will be performed. |
| 102 void AddWindow(aura::Window* window); |
| 103 |
| 95 // TODO(jonross): move this into the destructor. Currently separated as | 104 // TODO(jonross): move this into the destructor. Currently separated as |
| 96 // ShellOberver notifies of maximize mode ending, and the observers end up | 105 // ShellOberver notifies of maximize mode ending, and the observers end up |
| 97 // attempting to access MaximizeModeController via the Shell. If done in | 106 // attempting to access MaximizeModeController via the Shell. If done in |
| 98 // destructor the controller is null, and the observers segfault. | 107 // destructor the controller is null, and the observers segfault. |
| 99 // Shuts down down the MaximizeModeWindowManager and notifies all observers. | 108 // Shuts down down the MaximizeModeWindowManager and notifies all observers. |
| 100 void Shutdown(); | 109 void Shutdown(); |
| 101 | 110 |
| 102 // AccelerometerObserver: | 111 // AccelerometerObserver: |
| 103 virtual void OnAccelerometerUpdated(const gfx::Vector3dF& base, | 112 virtual void OnAccelerometerUpdated(const gfx::Vector3dF& base, |
| 104 const gfx::Vector3dF& lid) OVERRIDE; | 113 const gfx::Vector3dF& lid) OVERRIDE; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 115 // PowerManagerClient::Observer: | 124 // PowerManagerClient::Observer: |
| 116 virtual void LidEventReceived(bool open, | 125 virtual void LidEventReceived(bool open, |
| 117 const base::TimeTicks& time) OVERRIDE; | 126 const base::TimeTicks& time) OVERRIDE; |
| 118 virtual void SuspendImminent() OVERRIDE; | 127 virtual void SuspendImminent() OVERRIDE; |
| 119 virtual void SuspendDone(const base::TimeDelta& sleep_duration) OVERRIDE; | 128 virtual void SuspendDone(const base::TimeDelta& sleep_duration) OVERRIDE; |
| 120 #endif // OS_CHROMEOS | 129 #endif // OS_CHROMEOS |
| 121 | 130 |
| 122 private: | 131 private: |
| 123 friend class MaximizeModeControllerTest; | 132 friend class MaximizeModeControllerTest; |
| 124 friend class MaximizeModeWindowManagerTest; | 133 friend class MaximizeModeWindowManagerTest; |
| 134 friend class test::MultiUserWindowManagerChromeOSTest; |
| 125 | 135 |
| 126 // Set the TickClock. This is only to be used by tests that need to | 136 // Set the TickClock. This is only to be used by tests that need to |
| 127 // artificially and deterministically control the current time. | 137 // artificially and deterministically control the current time. |
| 128 void SetTickClockForTest(scoped_ptr<base::TickClock> tick_clock); | 138 void SetTickClockForTest(scoped_ptr<base::TickClock> tick_clock); |
| 129 | 139 |
| 130 // Detect hinge rotation from |base| and |lid| accelerometers and | 140 // Detect hinge rotation from |base| and |lid| accelerometers and |
| 131 // automatically start / stop maximize mode. | 141 // automatically start / stop maximize mode. |
| 132 void HandleHingeRotation(const gfx::Vector3dF& base, | 142 void HandleHingeRotation(const gfx::Vector3dF& base, |
| 133 const gfx::Vector3dF& lid); | 143 const gfx::Vector3dF& lid); |
| 134 | 144 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 210 |
| 201 // Tracks when the lid is closed. Used to prevent entering maximize mode. | 211 // Tracks when the lid is closed. Used to prevent entering maximize mode. |
| 202 bool lid_is_closed_; | 212 bool lid_is_closed_; |
| 203 | 213 |
| 204 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); | 214 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); |
| 205 }; | 215 }; |
| 206 | 216 |
| 207 } // namespace ash | 217 } // namespace ash |
| 208 | 218 |
| 209 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 219 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
| OLD | NEW |