| 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/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/shell_observer.h" | 9 #include "ash/shell_observer.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 void SuspendImminent() override; | 90 void SuspendImminent() override; |
| 91 void SuspendDone(const base::TimeDelta& sleep_duration) override; | 91 void SuspendDone(const base::TimeDelta& sleep_duration) override; |
| 92 #endif // OS_CHROMEOS | 92 #endif // OS_CHROMEOS |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 friend class MaximizeModeControllerTest; | 95 friend class MaximizeModeControllerTest; |
| 96 friend class MaximizeModeWindowManagerTest; | 96 friend class MaximizeModeWindowManagerTest; |
| 97 friend class test::MultiUserWindowManagerChromeOSTest; | 97 friend class test::MultiUserWindowManagerChromeOSTest; |
| 98 friend class test::VirtualKeyboardControllerTest; | 98 friend class test::VirtualKeyboardControllerTest; |
| 99 | 99 |
| 100 // Used for recording metrics for intervals of time spent in |
| 101 // and out of TouchView. |
| 102 enum TouchViewIntervalType { |
| 103 TOUCH_VIEW_INTERVAL_INACTIVE, |
| 104 TOUCH_VIEW_INTERVAL_ACTIVE |
| 105 }; |
| 106 |
| 100 // Set the TickClock. This is only to be used by tests that need to | 107 // Set the TickClock. This is only to be used by tests that need to |
| 101 // artificially and deterministically control the current time. | 108 // artificially and deterministically control the current time. |
| 102 void SetTickClockForTest(scoped_ptr<base::TickClock> tick_clock); | 109 void SetTickClockForTest(scoped_ptr<base::TickClock> tick_clock); |
| 103 | 110 |
| 104 #if defined(OS_CHROMEOS) | 111 #if defined(OS_CHROMEOS) |
| 105 // Detect hinge rotation from base and lid accelerometers and automatically | 112 // Detect hinge rotation from base and lid accelerometers and automatically |
| 106 // start / stop maximize mode. | 113 // start / stop maximize mode. |
| 107 void HandleHingeRotation(const chromeos::AccelerometerUpdate& update); | 114 void HandleHingeRotation(const chromeos::AccelerometerUpdate& update); |
| 108 #endif | 115 #endif |
| 109 | 116 |
| 110 // Returns true if the lid was recently opened. | 117 // Returns true if the lid was recently opened. |
| 111 bool WasLidOpenedRecently() const; | 118 bool WasLidOpenedRecently() const; |
| 112 | 119 |
| 113 // Enables MaximizeModeWindowManager, and determines the current state of | 120 // Enables MaximizeModeWindowManager, and determines the current state of |
| 114 // rotation lock. | 121 // rotation lock. |
| 115 void EnterMaximizeMode(); | 122 void EnterMaximizeMode(); |
| 116 | 123 |
| 117 // Removes MaximizeModeWindowManager and resets the display rotation if there | 124 // Removes MaximizeModeWindowManager and resets the display rotation if there |
| 118 // is no rotation lock. | 125 // is no rotation lock. |
| 119 void LeaveMaximizeMode(); | 126 void LeaveMaximizeMode(); |
| 120 | 127 |
| 121 // Record UMA stats tracking touchview usage. | 128 // Record UMA stats tracking TouchView usage. If |type| is |
| 122 void RecordTouchViewStateTransition(); | 129 // TOUCH_VIEW_INTERVAL_INACTIVE, then record that TouchView has been |
| 130 // inactive from |touchview_usage_interval_start_time_| until now. |
| 131 // Similarly, record that TouchView has been active if |type| is |
| 132 // TOUCH_VIEW_INTERVAL_ACTIVE. |
| 133 void RecordTouchViewUsageInterval(TouchViewIntervalType type); |
| 134 |
| 135 // Returns TOUCH_VIEW_INTERVAL_ACTIVE if TouchView is currently active, |
| 136 // otherwise returns TOUCH_VIEW_INTERNAL_INACTIVE. |
| 137 TouchViewIntervalType CurrentTouchViewIntervalType(); |
| 123 | 138 |
| 124 // The maximized window manager (if enabled). | 139 // The maximized window manager (if enabled). |
| 125 scoped_ptr<MaximizeModeWindowManager> maximize_mode_window_manager_; | 140 scoped_ptr<MaximizeModeWindowManager> maximize_mode_window_manager_; |
| 126 | 141 |
| 127 // A helper class which when instantiated will block native events from the | 142 // A helper class which when instantiated will block native events from the |
| 128 // internal keyboard and touchpad. | 143 // internal keyboard and touchpad. |
| 129 scoped_ptr<ScopedDisableInternalMouseAndKeyboard> event_blocker_; | 144 scoped_ptr<ScopedDisableInternalMouseAndKeyboard> event_blocker_; |
| 130 | 145 |
| 131 // Whether we have ever seen accelerometer data. | 146 // Whether we have ever seen accelerometer data. |
| 132 bool have_seen_accelerometer_data_; | 147 bool have_seen_accelerometer_data_; |
| 133 | 148 |
| 134 // True when the hinge angle has been detected past 180 degrees. | 149 // True when the hinge angle has been detected past 180 degrees. |
| 135 bool lid_open_past_180_; | 150 bool lid_open_past_180_; |
| 136 | 151 |
| 137 // Tracks time spent in (and out of) touchview mode. | 152 // Tracks time spent in (and out of) touchview mode. |
| 138 base::Time last_touchview_transition_time_; | 153 base::Time touchview_usage_interval_start_time_; |
| 139 base::TimeDelta total_touchview_time_; | 154 base::TimeDelta total_touchview_time_; |
| 140 base::TimeDelta total_non_touchview_time_; | 155 base::TimeDelta total_non_touchview_time_; |
| 141 | 156 |
| 142 // Tracks the last time we received a lid open event. This is used to suppress | 157 // Tracks the last time we received a lid open event. This is used to suppress |
| 143 // erroneous accelerometer readings as the lid is opened but the accelerometer | 158 // erroneous accelerometer readings as the lid is opened but the accelerometer |
| 144 // reports readings that make the lid to appear near fully open. | 159 // reports readings that make the lid to appear near fully open. |
| 145 base::TimeTicks last_lid_open_time_; | 160 base::TimeTicks last_lid_open_time_; |
| 146 | 161 |
| 147 // Source for the current time in base::TimeTicks. | 162 // Source for the current time in base::TimeTicks. |
| 148 scoped_ptr<base::TickClock> tick_clock_; | 163 scoped_ptr<base::TickClock> tick_clock_; |
| 149 | 164 |
| 150 // Tracks when the lid is closed. Used to prevent entering maximize mode. | 165 // Tracks when the lid is closed. Used to prevent entering maximize mode. |
| 151 bool lid_is_closed_; | 166 bool lid_is_closed_; |
| 152 | 167 |
| 153 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); | 168 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); |
| 154 }; | 169 }; |
| 155 | 170 |
| 156 } // namespace ash | 171 } // namespace ash |
| 157 | 172 |
| 158 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 173 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
| OLD | NEW |