| 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 <memory> |
| 9 |
| 8 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 9 #include "ash/display/window_tree_host_manager.h" | 11 #include "ash/display/window_tree_host_manager.h" |
| 10 #include "ash/shell_observer.h" | 12 #include "ash/shell_observer.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 14 #include "ui/gfx/display.h" | 15 #include "ui/gfx/display.h" |
| 15 #include "ui/gfx/geometry/vector3d_f.h" | 16 #include "ui/gfx/geometry/vector3d_f.h" |
| 16 | 17 |
| 17 #if defined(OS_CHROMEOS) | 18 #if defined(OS_CHROMEOS) |
| 18 #include "chromeos/accelerometer/accelerometer_reader.h" | 19 #include "chromeos/accelerometer/accelerometer_reader.h" |
| 19 #include "chromeos/accelerometer/accelerometer_types.h" | 20 #include "chromeos/accelerometer/accelerometer_types.h" |
| 20 #include "chromeos/dbus/power_manager_client.h" | 21 #include "chromeos/dbus/power_manager_client.h" |
| 21 #endif // OS_CHROMEOS | 22 #endif // OS_CHROMEOS |
| 22 | 23 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 106 |
| 106 // Used for recording metrics for intervals of time spent in | 107 // Used for recording metrics for intervals of time spent in |
| 107 // and out of TouchView. | 108 // and out of TouchView. |
| 108 enum TouchViewIntervalType { | 109 enum TouchViewIntervalType { |
| 109 TOUCH_VIEW_INTERVAL_INACTIVE, | 110 TOUCH_VIEW_INTERVAL_INACTIVE, |
| 110 TOUCH_VIEW_INTERVAL_ACTIVE | 111 TOUCH_VIEW_INTERVAL_ACTIVE |
| 111 }; | 112 }; |
| 112 | 113 |
| 113 // Set the TickClock. This is only to be used by tests that need to | 114 // Set the TickClock. This is only to be used by tests that need to |
| 114 // artificially and deterministically control the current time. | 115 // artificially and deterministically control the current time. |
| 115 void SetTickClockForTest(scoped_ptr<base::TickClock> tick_clock); | 116 void SetTickClockForTest(std::unique_ptr<base::TickClock> tick_clock); |
| 116 | 117 |
| 117 #if defined(OS_CHROMEOS) | 118 #if defined(OS_CHROMEOS) |
| 118 // Detect hinge rotation from base and lid accelerometers and automatically | 119 // Detect hinge rotation from base and lid accelerometers and automatically |
| 119 // start / stop maximize mode. | 120 // start / stop maximize mode. |
| 120 void HandleHingeRotation( | 121 void HandleHingeRotation( |
| 121 scoped_refptr<const chromeos::AccelerometerUpdate> update); | 122 scoped_refptr<const chromeos::AccelerometerUpdate> update); |
| 122 #endif | 123 #endif |
| 123 | 124 |
| 124 // Returns true if the lid was recently opened. | 125 // Returns true if the lid was recently opened. |
| 125 bool WasLidOpenedRecently() const; | 126 bool WasLidOpenedRecently() const; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 137 // inactive from |touchview_usage_interval_start_time_| until now. | 138 // inactive from |touchview_usage_interval_start_time_| until now. |
| 138 // Similarly, record that TouchView has been active if |type| is | 139 // Similarly, record that TouchView has been active if |type| is |
| 139 // TOUCH_VIEW_INTERVAL_ACTIVE. | 140 // TOUCH_VIEW_INTERVAL_ACTIVE. |
| 140 void RecordTouchViewUsageInterval(TouchViewIntervalType type); | 141 void RecordTouchViewUsageInterval(TouchViewIntervalType type); |
| 141 | 142 |
| 142 // Returns TOUCH_VIEW_INTERVAL_ACTIVE if TouchView is currently active, | 143 // Returns TOUCH_VIEW_INTERVAL_ACTIVE if TouchView is currently active, |
| 143 // otherwise returns TOUCH_VIEW_INTERNAL_INACTIVE. | 144 // otherwise returns TOUCH_VIEW_INTERNAL_INACTIVE. |
| 144 TouchViewIntervalType CurrentTouchViewIntervalType(); | 145 TouchViewIntervalType CurrentTouchViewIntervalType(); |
| 145 | 146 |
| 146 // The maximized window manager (if enabled). | 147 // The maximized window manager (if enabled). |
| 147 scoped_ptr<MaximizeModeWindowManager> maximize_mode_window_manager_; | 148 std::unique_ptr<MaximizeModeWindowManager> maximize_mode_window_manager_; |
| 148 | 149 |
| 149 // A helper class which when instantiated will block native events from the | 150 // A helper class which when instantiated will block native events from the |
| 150 // internal keyboard and touchpad. | 151 // internal keyboard and touchpad. |
| 151 scoped_ptr<ScopedDisableInternalMouseAndKeyboard> event_blocker_; | 152 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> event_blocker_; |
| 152 | 153 |
| 153 // Whether we have ever seen accelerometer data. | 154 // Whether we have ever seen accelerometer data. |
| 154 bool have_seen_accelerometer_data_; | 155 bool have_seen_accelerometer_data_; |
| 155 | 156 |
| 156 // True when the hinge angle has been detected past 180 degrees. | 157 // True when the hinge angle has been detected past 180 degrees. |
| 157 bool lid_open_past_180_; | 158 bool lid_open_past_180_; |
| 158 | 159 |
| 159 // Tracks time spent in (and out of) touchview mode. | 160 // Tracks time spent in (and out of) touchview mode. |
| 160 base::Time touchview_usage_interval_start_time_; | 161 base::Time touchview_usage_interval_start_time_; |
| 161 base::TimeDelta total_touchview_time_; | 162 base::TimeDelta total_touchview_time_; |
| 162 base::TimeDelta total_non_touchview_time_; | 163 base::TimeDelta total_non_touchview_time_; |
| 163 | 164 |
| 164 // Tracks the last time we received a lid open event. This is used to suppress | 165 // Tracks the last time we received a lid open event. This is used to suppress |
| 165 // erroneous accelerometer readings as the lid is opened but the accelerometer | 166 // erroneous accelerometer readings as the lid is opened but the accelerometer |
| 166 // reports readings that make the lid to appear near fully open. | 167 // reports readings that make the lid to appear near fully open. |
| 167 base::TimeTicks last_lid_open_time_; | 168 base::TimeTicks last_lid_open_time_; |
| 168 | 169 |
| 169 // Source for the current time in base::TimeTicks. | 170 // Source for the current time in base::TimeTicks. |
| 170 scoped_ptr<base::TickClock> tick_clock_; | 171 std::unique_ptr<base::TickClock> tick_clock_; |
| 171 | 172 |
| 172 // Tracks when the lid is closed. Used to prevent entering maximize mode. | 173 // Tracks when the lid is closed. Used to prevent entering maximize mode. |
| 173 bool lid_is_closed_; | 174 bool lid_is_closed_; |
| 174 | 175 |
| 175 // Tracks smoothed accelerometer data over time. This is done when the hinge | 176 // Tracks smoothed accelerometer data over time. This is done when the hinge |
| 176 // is approaching vertical to remove abrupt acceleration that can lead to | 177 // is approaching vertical to remove abrupt acceleration that can lead to |
| 177 // incorrect calculations of hinge angles. | 178 // incorrect calculations of hinge angles. |
| 178 gfx::Vector3dF base_smoothed_; | 179 gfx::Vector3dF base_smoothed_; |
| 179 gfx::Vector3dF lid_smoothed_; | 180 gfx::Vector3dF lid_smoothed_; |
| 180 | 181 |
| 181 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); | 182 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); |
| 182 }; | 183 }; |
| 183 | 184 |
| 184 } // namespace ash | 185 } // namespace ash |
| 185 | 186 |
| 186 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ | 187 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ |
| OLD | NEW |