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 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 5 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 6 | 6 |
| 7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
| 8 #include "ash/accelerators/accelerator_table.h" | 8 #include "ash/accelerators/accelerator_table.h" |
| 9 #include "ash/accelerometer/accelerometer_controller.h" | 9 #include "ash/accelerometer/accelerometer_controller.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/display/display_manager.h" | 11 #include "ash/display/display_manager.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" | 13 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" |
| 14 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard.h" | 14 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard.h" |
| 15 #include "base/auto_reset.h" | 15 #include "base/auto_reset.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 18 #include "base/time/default_tick_clock.h" | |
| 19 #include "base/time/tick_clock.h" | |
| 18 #include "ui/base/accelerators/accelerator.h" | 20 #include "ui/base/accelerators/accelerator.h" |
| 19 #include "ui/events/event.h" | 21 #include "ui/events/event.h" |
| 20 #include "ui/events/event_handler.h" | 22 #include "ui/events/event_handler.h" |
| 21 #include "ui/events/keycodes/keyboard_codes.h" | 23 #include "ui/events/keycodes/keyboard_codes.h" |
| 22 #include "ui/gfx/vector3d_f.h" | 24 #include "ui/gfx/vector3d_f.h" |
| 23 | 25 |
| 24 #if defined(USE_X11) | 26 #if defined(USE_X11) |
| 25 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.h" | 27 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.h" |
| 26 #endif | 28 #endif |
| 27 | 29 |
| 30 #if defined(OS_CHROMEOS) | |
| 31 #include "chromeos/dbus/dbus_thread_manager.h" | |
| 32 #endif // OS_CHROMEOS | |
| 33 | |
| 28 namespace ash { | 34 namespace ash { |
| 29 | 35 |
| 30 namespace { | 36 namespace { |
| 31 | 37 |
| 32 // The hinge angle at which to enter maximize mode. | 38 // The hinge angle at which to enter maximize mode. |
| 33 const float kEnterMaximizeModeAngle = 200.0f; | 39 const float kEnterMaximizeModeAngle = 200.0f; |
| 34 | 40 |
| 35 // The angle at which to exit maximize mode, this is specifically less than the | 41 // The angle at which to exit maximize mode, this is specifically less than the |
| 36 // angle to enter maximize mode to prevent rapid toggling when near the angle. | 42 // angle to enter maximize mode to prevent rapid toggling when near the angle. |
| 37 const float kExitMaximizeModeAngle = 160.0f; | 43 const float kExitMaximizeModeAngle = 160.0f; |
| 38 | 44 |
| 39 // When the lid is fully open 360 degrees, the accelerometer readings can | 45 // Defines a range for which accelerometer readings are considered accurate. |
| 40 // occasionally appear as though the lid is almost closed. If the lid appears | 46 // When the lid is near open (or near closed) the acceleromter readings may be |
| 41 // near closed but the device is on we assume it is an erroneous reading from | 47 // inaccurate and a lid that is fully open may appear to be near closed (and |
| 42 // it being open 360 degrees. | 48 // vice versa). |
| 43 const float kFullyOpenAngleErrorTolerance = 20.0f; | 49 const float kMinStableAngle = 20.0f; |
| 50 const float kMaxStableAngle = 340.0f; | |
| 51 | |
| 52 // The time duration to consider the lid to be recently opened. | |
| 53 // This is used to prevent entering maximize mode if an erroneous accelerometer | |
| 54 // reading makes the lid appear to be fully open when the user is opening the | |
| 55 // lid from a closed position. | |
| 56 const base::TimeDelta kLidRecentlyOpenedTolerance = | |
|
flackr
2014/07/29 16:41:45
how about kLidRecentlyOpenedDuration?
bruthig
2014/07/31 16:10:48
Done.
| |
| 57 base::TimeDelta::FromSeconds(2); | |
|
flackr
2014/07/29 16:41:44
nit: indent 4.
bruthig
2014/07/31 16:10:49
Done.
| |
| 44 | 58 |
| 45 // When the device approaches vertical orientation (i.e. portrait orientation) | 59 // When the device approaches vertical orientation (i.e. portrait orientation) |
| 46 // the accelerometers for the base and lid approach the same values (i.e. | 60 // the accelerometers for the base and lid approach the same values (i.e. |
| 47 // gravity pointing in the direction of the hinge). When this happens we cannot | 61 // gravity pointing in the direction of the hinge). When this happens we cannot |
| 48 // compute the hinge angle reliably and must turn ignore accelerometer readings. | 62 // compute the hinge angle reliably and must turn ignore accelerometer readings. |
| 49 // This is the minimum acceleration perpendicular to the hinge under which to | 63 // This is the minimum acceleration perpendicular to the hinge under which to |
| 50 // detect hinge angle. | 64 // detect hinge angle. |
| 51 const float kHingeAngleDetectionThreshold = 0.25f; | 65 const float kHingeAngleDetectionThreshold = 0.25f; |
| 52 | 66 |
| 53 // The maximum deviation from the acceleration expected due to gravity under | 67 // The maximum deviation from the acceleration expected due to gravity under |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 66 | 80 |
| 67 // The minimum acceleration in a direction required to trigger screen rotation. | 81 // The minimum acceleration in a direction required to trigger screen rotation. |
| 68 // This prevents rapid toggling of rotation when the device is near flat and | 82 // This prevents rapid toggling of rotation when the device is near flat and |
| 69 // there is very little screen aligned force on it. The value is effectively the | 83 // there is very little screen aligned force on it. The value is effectively the |
| 70 // sine of the rise angle required, with the current value requiring at least a | 84 // sine of the rise angle required, with the current value requiring at least a |
| 71 // 25 degree rise. | 85 // 25 degree rise. |
| 72 const float kMinimumAccelerationScreenRotation = 0.42f; | 86 const float kMinimumAccelerationScreenRotation = 0.42f; |
| 73 | 87 |
| 74 const float kRadiansToDegrees = 180.0f / 3.14159265f; | 88 const float kRadiansToDegrees = 180.0f / 3.14159265f; |
| 75 | 89 |
| 90 // Returns true if the angle is considered a stable accurate reading. | |
| 91 bool IsAngleStable(float angle) { | |
|
flackr
2014/07/29 16:41:45
I feel like this should be defined as a bool where
bruthig
2014/07/31 16:10:49
Done.
| |
| 92 return angle > kMinStableAngle && angle < kMaxStableAngle; | |
| 93 } | |
| 94 | |
| 76 // Returns the angle between |base| and |other| in degrees. | 95 // Returns the angle between |base| and |other| in degrees. |
| 77 float AngleBetweenVectorsInDegrees(const gfx::Vector3dF& base, | 96 float AngleBetweenVectorsInDegrees(const gfx::Vector3dF& base, |
| 78 const gfx::Vector3dF& other) { | 97 const gfx::Vector3dF& other) { |
| 79 return acos(gfx::DotProduct(base, other) / | 98 return acos(gfx::DotProduct(base, other) / |
| 80 base.Length() / other.Length()) * kRadiansToDegrees; | 99 base.Length() / other.Length()) * kRadiansToDegrees; |
| 81 } | 100 } |
| 82 | 101 |
| 83 // Returns the clockwise angle between |base| and |other| where |normal| is the | 102 // Returns the clockwise angle between |base| and |other| where |normal| is the |
| 84 // normal of the virtual surface to measure clockwise according to. | 103 // normal of the virtual surface to measure clockwise according to. |
| 85 float ClockwiseAngleBetweenVectorsInDegrees(const gfx::Vector3dF& base, | 104 float ClockwiseAngleBetweenVectorsInDegrees(const gfx::Vector3dF& base, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 | 156 |
| 138 #endif // OS_CHROMEOS | 157 #endif // OS_CHROMEOS |
| 139 | 158 |
| 140 } // namespace | 159 } // namespace |
| 141 | 160 |
| 142 MaximizeModeController::MaximizeModeController() | 161 MaximizeModeController::MaximizeModeController() |
| 143 : rotation_locked_(false), | 162 : rotation_locked_(false), |
| 144 have_seen_accelerometer_data_(false), | 163 have_seen_accelerometer_data_(false), |
| 145 in_set_screen_rotation_(false), | 164 in_set_screen_rotation_(false), |
| 146 user_rotation_(gfx::Display::ROTATE_0), | 165 user_rotation_(gfx::Display::ROTATE_0), |
| 147 last_touchview_transition_time_(base::Time::Now()) { | 166 last_touchview_transition_time_(base::Time::Now()), |
| 167 last_lid_open_time_(), | |
|
flackr
2014/07/29 16:41:44
Default constructor is automatically called, no ne
bruthig
2014/07/31 16:10:49
Done.
| |
| 168 tick_clock_(new base::DefaultTickClock()), | |
| 169 lid_is_closed_(false) { | |
| 148 Shell::GetInstance()->accelerometer_controller()->AddObserver(this); | 170 Shell::GetInstance()->accelerometer_controller()->AddObserver(this); |
| 149 Shell::GetInstance()->AddShellObserver(this); | 171 Shell::GetInstance()->AddShellObserver(this); |
| 172 #if defined(OS_CHROMEOS) | |
| 173 chromeos::DBusThreadManager::Get()-> | |
| 174 GetPowerManagerClient()->AddObserver(this); | |
|
flackr
2014/07/29 16:41:44
nit: indent 4.
bruthig
2014/07/31 16:10:48
Done.
| |
| 175 #endif // OS_CHROMEOS | |
| 150 } | 176 } |
| 151 | 177 |
| 152 MaximizeModeController::~MaximizeModeController() { | 178 MaximizeModeController::~MaximizeModeController() { |
| 153 Shell::GetInstance()->RemoveShellObserver(this); | 179 Shell::GetInstance()->RemoveShellObserver(this); |
| 154 Shell::GetInstance()->accelerometer_controller()->RemoveObserver(this); | 180 Shell::GetInstance()->accelerometer_controller()->RemoveObserver(this); |
| 181 #if defined(OS_CHROMEOS) | |
| 182 chromeos::DBusThreadManager::Get()-> | |
| 183 GetPowerManagerClient()->RemoveObserver(this); | |
|
flackr
2014/07/29 16:41:44
nit: indent 4.
bruthig
2014/07/31 16:10:49
Done.
| |
| 184 #endif // OS_CHROMEOS | |
| 155 } | 185 } |
| 156 | 186 |
| 157 void MaximizeModeController::SetRotationLocked(bool rotation_locked) { | 187 void MaximizeModeController::SetRotationLocked(bool rotation_locked) { |
| 158 if (rotation_locked_ == rotation_locked) | 188 if (rotation_locked_ == rotation_locked) |
| 159 return; | 189 return; |
| 160 rotation_locked_ = rotation_locked; | 190 rotation_locked_ = rotation_locked; |
| 161 FOR_EACH_OBSERVER(Observer, observers_, | 191 FOR_EACH_OBSERVER(Observer, observers_, |
| 162 OnRotationLockChanged(rotation_locked_)); | 192 OnRotationLockChanged(rotation_locked_)); |
| 163 } | 193 } |
| 164 | 194 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 if (user_rotation != current_rotation_) { | 262 if (user_rotation != current_rotation_) { |
| 233 // A user may change other display configuration settings. When the user | 263 // A user may change other display configuration settings. When the user |
| 234 // does change the rotation setting, then lock rotation to prevent the | 264 // does change the rotation setting, then lock rotation to prevent the |
| 235 // accelerometer from erasing their change. | 265 // accelerometer from erasing their change. |
| 236 SetRotationLocked(true); | 266 SetRotationLocked(true); |
| 237 user_rotation_ = user_rotation; | 267 user_rotation_ = user_rotation; |
| 238 current_rotation_ = user_rotation; | 268 current_rotation_ = user_rotation; |
| 239 } | 269 } |
| 240 } | 270 } |
| 241 | 271 |
| 272 #if defined(OS_CHROMEOS) | |
| 273 void MaximizeModeController::LidEventReceived(bool open, | |
| 274 const base::TimeTicks& time) { | |
| 275 if (open) | |
| 276 last_lid_open_time_ = time; | |
| 277 lid_is_closed_ = !open; | |
| 278 LeaveMaximizeMode(); | |
| 279 } | |
| 280 | |
| 281 void MaximizeModeController::SuspendImminent() { | |
| 282 RecordTouchViewStateTransition(); | |
| 283 } | |
| 284 | |
| 285 void MaximizeModeController::SuspendDone( | |
| 286 const base::TimeDelta& sleep_duration) { | |
| 287 last_touchview_transition_time_ = base::Time::Now(); | |
| 288 // A lid open event won't always occur when coming out of a suspend state. | |
|
flackr
2014/07/29 16:41:45
This seems problematic, so we can get a lid closed
bruthig
2014/07/31 16:10:49
This shouldn't happen, removed.
| |
| 289 lid_is_closed_ = false; | |
|
flackr
2014/07/29 16:41:45
If lid_is_closed_ was true we probably need to set
| |
| 290 } | |
| 291 #endif // OS_CHROMEOS | |
| 292 | |
| 242 void MaximizeModeController::HandleHingeRotation(const gfx::Vector3dF& base, | 293 void MaximizeModeController::HandleHingeRotation(const gfx::Vector3dF& base, |
| 243 const gfx::Vector3dF& lid) { | 294 const gfx::Vector3dF& lid) { |
| 244 static const gfx::Vector3dF hinge_vector(0.0f, 1.0f, 0.0f); | 295 static const gfx::Vector3dF hinge_vector(0.0f, 1.0f, 0.0f); |
| 245 bool maximize_mode_engaged = IsMaximizeModeWindowManagerEnabled(); | 296 bool maximize_mode_engaged = IsMaximizeModeWindowManagerEnabled(); |
| 246 // Ignore the component of acceleration parallel to the hinge for the purposes | 297 // Ignore the component of acceleration parallel to the hinge for the purposes |
| 247 // of hinge angle calculation. | 298 // of hinge angle calculation. |
| 248 gfx::Vector3dF base_flattened(base); | 299 gfx::Vector3dF base_flattened(base); |
| 249 gfx::Vector3dF lid_flattened(lid); | 300 gfx::Vector3dF lid_flattened(lid); |
| 250 base_flattened.set_y(0.0f); | 301 base_flattened.set_y(0.0f); |
| 251 lid_flattened.set_y(0.0f); | 302 lid_flattened.set_y(0.0f); |
| 252 | 303 |
| 253 // As the hinge approaches a vertical angle, the base and lid accelerometers | 304 // As the hinge approaches a vertical angle, the base and lid accelerometers |
| 254 // approach the same values making any angle calculations highly inaccurate. | 305 // approach the same values making any angle calculations highly inaccurate. |
| 255 // Bail out early when it is too close. | 306 // Bail out early when it is too close. |
| 256 if (base_flattened.Length() < kHingeAngleDetectionThreshold || | 307 if (base_flattened.Length() < kHingeAngleDetectionThreshold || |
| 257 lid_flattened.Length() < kHingeAngleDetectionThreshold) { | 308 lid_flattened.Length() < kHingeAngleDetectionThreshold) { |
| 258 return; | 309 return; |
| 259 } | 310 } |
| 260 | 311 |
| 261 // Compute the angle between the base and the lid. | 312 // Compute the angle between the base and the lid. |
| 262 float angle = ClockwiseAngleBetweenVectorsInDegrees(base_flattened, | 313 float angle = ClockwiseAngleBetweenVectorsInDegrees(base_flattened, |
| 263 lid_flattened, hinge_vector); | 314 lid_flattened, hinge_vector); |
| 264 | 315 |
| 316 // Clear the last_lid_open_time_ for a stable reading so that there is less | |
| 317 // chance of a delay if the lid is moved from the close state to the fully | |
| 318 // open state very quickly. | |
| 319 if (IsAngleStable(angle)) | |
| 320 last_lid_open_time_ = base::TimeTicks(); | |
| 321 | |
| 265 // Toggle maximize mode on or off when corresponding thresholds are passed. | 322 // Toggle maximize mode on or off when corresponding thresholds are passed. |
| 266 // TODO(flackr): Make MaximizeModeController own the MaximizeModeWindowManager | 323 // TODO(flackr): Make MaximizeModeController own the MaximizeModeWindowManager |
| 267 // such that observations of state changes occur after the change and shell | 324 // such that observations of state changes occur after the change and shell |
| 268 // has fewer states to track. | 325 // has fewer states to track. |
| 269 if (maximize_mode_engaged && | 326 if (lid_is_closed_ || |
|
flackr
2014/07/29 16:41:44
LeaveMaximizeMode is called from LidEventReceived,
bruthig
2014/07/31 16:10:48
Done.
| |
| 270 angle > kFullyOpenAngleErrorTolerance && | 327 (maximize_mode_engaged && |
| 271 angle < kExitMaximizeModeAngle) { | 328 ((IsAngleStable(angle) && angle < kExitMaximizeModeAngle) || |
| 329 (angle > kMaxStableAngle && WasLidOpenedRecently())))) { | |
|
flackr
2014/07/29 16:41:44
If we call LeaveMaximizeMode on lid opened (which
bruthig
2014/07/31 16:10:49
Done.
| |
| 272 LeaveMaximizeMode(); | 330 LeaveMaximizeMode(); |
| 273 } else if (!maximize_mode_engaged && | 331 } else if (!maximize_mode_engaged && |
|
flackr
2014/07/29 16:41:44
Probably could add !lid_is_closed_ here though.
bruthig
2014/07/31 16:10:49
Done.
| |
| 274 angle > kEnterMaximizeModeAngle) { | 332 ((IsAngleStable(angle) && angle > kEnterMaximizeModeAngle) || |
| 333 (angle > kMaxStableAngle && !WasLidOpenedRecently()))) { | |
| 275 EnterMaximizeMode(); | 334 EnterMaximizeMode(); |
| 276 } | 335 } |
| 277 } | 336 } |
| 278 | 337 |
| 279 void MaximizeModeController::HandleScreenRotation(const gfx::Vector3dF& lid) { | 338 void MaximizeModeController::HandleScreenRotation(const gfx::Vector3dF& lid) { |
| 280 bool maximize_mode_engaged = IsMaximizeModeWindowManagerEnabled(); | 339 bool maximize_mode_engaged = IsMaximizeModeWindowManagerEnabled(); |
| 281 | 340 |
| 282 // TODO(jonross): track the updated rotation angle even when locked. So that | 341 // TODO(jonross): track the updated rotation angle even when locked. So that |
| 283 // when rotation lock is removed the accelerometer rotation can be applied | 342 // when rotation lock is removed the accelerometer rotation can be applied |
| 284 // without waiting for the next update. | 343 // without waiting for the next update. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 DisplayManager* display_manager, | 402 DisplayManager* display_manager, |
| 344 gfx::Display::Rotation rotation) { | 403 gfx::Display::Rotation rotation) { |
| 345 base::AutoReset<bool> auto_in_set_screen_rotation( | 404 base::AutoReset<bool> auto_in_set_screen_rotation( |
| 346 &in_set_screen_rotation_, true); | 405 &in_set_screen_rotation_, true); |
| 347 current_rotation_ = rotation; | 406 current_rotation_ = rotation; |
| 348 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), | 407 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), |
| 349 rotation); | 408 rotation); |
| 350 } | 409 } |
| 351 | 410 |
| 352 void MaximizeModeController::EnterMaximizeMode() { | 411 void MaximizeModeController::EnterMaximizeMode() { |
| 412 if (IsMaximizeModeWindowManagerEnabled()) | |
| 413 return; | |
| 353 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 414 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 354 current_rotation_ = user_rotation_ = display_manager-> | 415 current_rotation_ = user_rotation_ = display_manager-> |
| 355 GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); | 416 GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); |
| 356 EnableMaximizeModeWindowManager(true); | 417 EnableMaximizeModeWindowManager(true); |
| 357 #if defined(USE_X11) | 418 #if defined(USE_X11) |
| 358 event_blocker_.reset(new ScopedDisableInternalMouseAndKeyboardX11); | 419 event_blocker_.reset(new ScopedDisableInternalMouseAndKeyboardX11); |
| 359 #endif | 420 #endif |
| 360 #if defined(OS_CHROMEOS) | 421 #if defined(OS_CHROMEOS) |
| 361 event_handler_.reset(new ScreenshotActionHandler); | 422 event_handler_.reset(new ScreenshotActionHandler); |
| 362 #endif | 423 #endif |
| 363 Shell::GetInstance()->display_controller()->AddObserver(this); | 424 Shell::GetInstance()->display_controller()->AddObserver(this); |
| 364 } | 425 } |
| 365 | 426 |
| 366 void MaximizeModeController::LeaveMaximizeMode() { | 427 void MaximizeModeController::LeaveMaximizeMode() { |
| 428 if (!IsMaximizeModeWindowManagerEnabled()) | |
| 429 return; | |
| 367 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 430 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 368 gfx::Display::Rotation current_rotation = display_manager-> | 431 gfx::Display::Rotation current_rotation = display_manager-> |
| 369 GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); | 432 GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation(); |
| 370 if (current_rotation != user_rotation_) | 433 if (current_rotation != user_rotation_) |
| 371 SetDisplayRotation(display_manager, user_rotation_); | 434 SetDisplayRotation(display_manager, user_rotation_); |
| 372 rotation_locked_ = false; | 435 rotation_locked_ = false; |
| 373 EnableMaximizeModeWindowManager(false); | 436 EnableMaximizeModeWindowManager(false); |
| 374 event_blocker_.reset(); | 437 event_blocker_.reset(); |
| 375 event_handler_.reset(); | 438 event_handler_.reset(); |
| 376 } | 439 Shell::GetInstance()->display_controller()->RemoveObserver(this); |
| 377 | |
| 378 void MaximizeModeController::OnSuspend() { | |
| 379 RecordTouchViewStateTransition(); | |
|
flackr
2014/07/29 16:41:45
Was this never called before? There are no removed
bruthig
2014/07/31 16:10:49
No it wasn't being called. Appears to have change
| |
| 380 } | |
| 381 | |
| 382 void MaximizeModeController::OnResume() { | |
| 383 last_touchview_transition_time_ = base::Time::Now(); | |
| 384 } | 440 } |
| 385 | 441 |
| 386 // Called after maximize mode has started, windows might still animate though. | 442 // Called after maximize mode has started, windows might still animate though. |
| 387 void MaximizeModeController::OnMaximizeModeStarted() { | 443 void MaximizeModeController::OnMaximizeModeStarted() { |
| 388 RecordTouchViewStateTransition(); | 444 RecordTouchViewStateTransition(); |
| 389 } | 445 } |
| 390 | 446 |
| 391 // Called after maximize mode has ended, windows might still be returning to | 447 // Called after maximize mode has ended, windows might still be returning to |
| 392 // their original position. | 448 // their original position. |
| 393 void MaximizeModeController::OnMaximizeModeEnded() { | 449 void MaximizeModeController::OnMaximizeModeEnded() { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 421 base::TimeDelta total_runtime = total_touchview_time_ + | 477 base::TimeDelta total_runtime = total_touchview_time_ + |
| 422 total_non_touchview_time_; | 478 total_non_touchview_time_; |
| 423 if (total_runtime.InSeconds() > 0) { | 479 if (total_runtime.InSeconds() > 0) { |
| 424 UMA_HISTOGRAM_PERCENTAGE("Ash.TouchView.TouchViewActivePercentage", | 480 UMA_HISTOGRAM_PERCENTAGE("Ash.TouchView.TouchViewActivePercentage", |
| 425 100 * total_touchview_time_.InSeconds() / total_runtime.InSeconds()); | 481 100 * total_touchview_time_.InSeconds() / total_runtime.InSeconds()); |
| 426 } | 482 } |
| 427 } | 483 } |
| 428 Shell::GetInstance()->display_controller()->RemoveObserver(this); | 484 Shell::GetInstance()->display_controller()->RemoveObserver(this); |
| 429 } | 485 } |
| 430 | 486 |
| 487 bool MaximizeModeController::WasLidOpenedRecently() const { | |
| 488 if (last_lid_open_time_.is_null()) | |
| 489 return false; | |
| 490 | |
| 491 base::TimeTicks now = tick_clock_->NowTicks(); | |
| 492 DCHECK(now >= last_lid_open_time_); | |
| 493 base::TimeDelta elapsed_time = now - last_lid_open_time_; | |
| 494 return elapsed_time <= kLidRecentlyOpenedTolerance; | |
| 495 } | |
| 496 | |
| 497 void MaximizeModeController::SetTickClockForTest(base::TickClock* tick_clock) { | |
| 498 DCHECK(tick_clock_); | |
| 499 tick_clock_.reset(tick_clock); | |
| 500 } | |
| 501 | |
| 431 } // namespace ash | 502 } // namespace ash |
| OLD | NEW |