Chromium Code Reviews| 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" | |
| 9 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 10 #include "ash/display/display_controller.h" | 9 #include "ash/display/display_controller.h" |
| 11 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| 12 #include "ash/shell_observer.h" | 11 #include "ash/shell_observer.h" |
| 13 #include "base/macros.h" | 12 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 16 #include "ui/gfx/display.h" | 15 #include "ui/gfx/display.h" |
| 17 | 16 |
| 18 #if defined(OS_CHROMEOS) | 17 #if defined(OS_CHROMEOS) |
| 18 #include "chromeos/accelerometer/accelerometer_reader.h" | |
| 19 #include "chromeos/dbus/power_manager_client.h" | 19 #include "chromeos/dbus/power_manager_client.h" |
| 20 #endif // OS_CHROMEOS | 20 #endif // OS_CHROMEOS |
| 21 | 21 |
| 22 namespace base { | 22 namespace base { |
| 23 class TickClock; | 23 class TickClock; |
| 24 } | 24 } |
| 25 | 25 |
| 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 { | 36 namespace test { |
| 37 class MultiUserWindowManagerChromeOSTest; | 37 class MultiUserWindowManagerChromeOSTest; |
| 38 } | 38 } |
| 39 | 39 |
| 40 // MaximizeModeController listens to accelerometer events and automatically | 40 // MaximizeModeController listens to accelerometer events and automatically |
| 41 // 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 |
| 42 // 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. |
| 43 class ASH_EXPORT MaximizeModeController | 43 class ASH_EXPORT MaximizeModeController |
| 44 : public AccelerometerObserver, | 44 : public ShellObserver, |
| 45 #if defined(OS_CHROMEOS) | 45 #if defined(OS_CHROMEOS) |
| 46 public chromeos::AccelerometerReader::Observer, | |
| 46 public chromeos::PowerManagerClient::Observer, | 47 public chromeos::PowerManagerClient::Observer, |
| 47 #endif // OS_CHROMEOS | 48 #endif // OS_CHROMEOS |
| 48 public ShellObserver, | |
| 49 public DisplayController::Observer { | 49 public DisplayController::Observer { |
| 50 public: | 50 public: |
| 51 // Observer that reports changes to the state of MaximizeModeController's | 51 // Observer that reports changes to the state of MaximizeModeController's |
| 52 // rotation lock. | 52 // rotation lock. |
| 53 class Observer { | 53 class Observer { |
| 54 public: | 54 public: |
| 55 // Invoked whenever |rotation_locked_| is changed. | 55 // Invoked whenever |rotation_locked_| is changed. |
| 56 virtual void OnRotationLockChanged(bool rotation_locked) {} | 56 virtual void OnRotationLockChanged(bool rotation_locked) {} |
| 57 | 57 |
| 58 protected: | 58 protected: |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 // If the maximize mode is not enabled no action will be performed. | 106 // If the maximize mode is not enabled no action will be performed. |
| 107 void AddWindow(aura::Window* window); | 107 void AddWindow(aura::Window* window); |
| 108 | 108 |
| 109 // TODO(jonross): move this into the destructor. Currently separated as | 109 // TODO(jonross): move this into the destructor. Currently separated as |
| 110 // ShellOberver notifies of maximize mode ending, and the observers end up | 110 // ShellOberver notifies of maximize mode ending, and the observers end up |
| 111 // attempting to access MaximizeModeController via the Shell. If done in | 111 // attempting to access MaximizeModeController via the Shell. If done in |
| 112 // destructor the controller is null, and the observers segfault. | 112 // destructor the controller is null, and the observers segfault. |
| 113 // Shuts down down the MaximizeModeWindowManager and notifies all observers. | 113 // Shuts down down the MaximizeModeWindowManager and notifies all observers. |
| 114 void Shutdown(); | 114 void Shutdown(); |
| 115 | 115 |
| 116 // AccelerometerObserver: | |
| 117 void OnAccelerometerUpdated(const ui::AccelerometerUpdate& update) override; | |
| 118 | |
| 119 // ShellObserver: | 116 // ShellObserver: |
| 120 void OnAppTerminating() override; | 117 void OnAppTerminating() override; |
| 121 void OnMaximizeModeStarted() override; | 118 void OnMaximizeModeStarted() override; |
| 122 void OnMaximizeModeEnded() override; | 119 void OnMaximizeModeEnded() override; |
| 123 | 120 |
| 124 // DisplayController::Observer: | 121 // DisplayController::Observer: |
| 125 void OnDisplayConfigurationChanged() override; | 122 void OnDisplayConfigurationChanged() override; |
| 126 | 123 |
| 127 #if defined(OS_CHROMEOS) | 124 #if defined(OS_CHROMEOS) |
| 125 // AccelerometerReader::Observer: | |
|
flackr
2014/12/12 16:47:10
chromeos::AccelerometerReader::Observer:
jonross
2014/12/12 19:03:25
Done.
| |
| 126 void OnAccelerometerUpdated(const ui::AccelerometerUpdate& update) override; | |
| 127 | |
| 128 // PowerManagerClient::Observer: | 128 // PowerManagerClient::Observer: |
| 129 virtual void LidEventReceived(bool open, | 129 void LidEventReceived(bool open, const base::TimeTicks& time) override; |
| 130 const base::TimeTicks& time) override; | 130 void SuspendImminent() override; |
| 131 virtual void SuspendImminent() override; | 131 void SuspendDone(const base::TimeDelta& sleep_duration) override; |
| 132 virtual void SuspendDone(const base::TimeDelta& sleep_duration) override; | |
| 133 #endif // OS_CHROMEOS | 132 #endif // OS_CHROMEOS |
| 134 | 133 |
| 135 private: | 134 private: |
| 136 friend class MaximizeModeControllerTest; | 135 friend class MaximizeModeControllerTest; |
| 137 friend class MaximizeModeWindowManagerTest; | 136 friend class MaximizeModeWindowManagerTest; |
| 138 friend class test::MultiUserWindowManagerChromeOSTest; | 137 friend class test::MultiUserWindowManagerChromeOSTest; |
| 139 | 138 |
| 140 // Set the TickClock. This is only to be used by tests that need to | 139 // Set the TickClock. This is only to be used by tests that need to |
| 141 // artificially and deterministically control the current time. | 140 // artificially and deterministically control the current time. |
| 142 void SetTickClockForTest(scoped_ptr<base::TickClock> tick_clock); | 141 void SetTickClockForTest(scoped_ptr<base::TickClock> tick_clock); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 | 223 |
| 225 // Tracks when the lid is closed. Used to prevent entering maximize mode. | 224 // Tracks when the lid is closed. Used to prevent entering maximize mode. |
| 226 bool lid_is_closed_; | 225 bool lid_is_closed_; |
| 227 | 226 |
| 228 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); | 227 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); |
| 229 }; | 228 }; |
| 230 | 229 |
| 231 } // namespace ash | 230 } // namespace ash |
| 232 | 231 |
| 233 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 232 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
| OLD | NEW |