| Index: ash/system/chromeos/power/tablet_power_button_controller.cc
|
| diff --git a/ash/system/chromeos/power/tablet_power_button_controller.cc b/ash/system/chromeos/power/tablet_power_button_controller.cc
|
| index f34dc3ee71973f99955d421e89d595d1b59b9850..aba3b6cca4f4df6d1cdc6e0079d7c74d8dc6deec 100644
|
| --- a/ash/system/chromeos/power/tablet_power_button_controller.cc
|
| +++ b/ash/system/chromeos/power/tablet_power_button_controller.cc
|
| @@ -25,6 +25,9 @@ namespace {
|
| // animation when in tablet mode.
|
| constexpr int kShutdownTimeoutMs = 500;
|
|
|
| +// Amount of time to delay locking screen after display is forced off.
|
| +constexpr int kLockScreenTimeoutMs = 1000;
|
| +
|
| // Amount of time since last SuspendDone() that power button event needs to be
|
| // ignored.
|
| constexpr int kIgnorePowerButtonAfterResumeMs = 2000;
|
| @@ -64,6 +67,16 @@ void TabletPowerButtonController::TestApi::TriggerShutdownTimeout() {
|
| controller_->shutdown_timer_.Stop();
|
| }
|
|
|
| +bool TabletPowerButtonController::TestApi::LockScreenTimerIsRunning() const {
|
| + return controller_->lock_screen_timer_.IsRunning();
|
| +}
|
| +
|
| +void TabletPowerButtonController::TestApi::TriggerLockScreenTimeout() {
|
| + DCHECK(LockScreenTimerIsRunning());
|
| + controller_->OnLockScreenTimeout();
|
| + controller_->lock_screen_timer_.Stop();
|
| +}
|
| +
|
| TabletPowerButtonController::TabletPowerButtonController(
|
| LockStateController* controller)
|
| : tick_clock_(new base::DefaultTickClock()),
|
| @@ -108,6 +121,7 @@ void TabletPowerButtonController::OnPowerButtonEvent(
|
| }
|
| screen_off_when_power_button_down_ = brightness_level_is_zero_;
|
| SetDisplayForcedOff(false);
|
| + lock_screen_timer_.Stop();
|
| StartShutdownTimer();
|
| } else {
|
| if (shutdown_timer_.IsRunning()) {
|
| @@ -159,22 +173,27 @@ void TabletPowerButtonController::OnKeyEvent(ui::KeyEvent* event) {
|
| if (event->key_code() == ui::VKEY_POWER)
|
| return;
|
|
|
| - if (!IsTabletModeActive() && backlights_forced_off_)
|
| + if (!IsTabletModeActive() && backlights_forced_off_) {
|
| SetDisplayForcedOff(false);
|
| + lock_screen_timer_.Stop();
|
| + }
|
| }
|
|
|
| void TabletPowerButtonController::OnMouseEvent(ui::MouseEvent* event) {
|
| if (event->flags() & ui::EF_IS_SYNTHESIZED)
|
| return;
|
|
|
| - if (!IsTabletModeActive() && backlights_forced_off_)
|
| + if (!IsTabletModeActive() && backlights_forced_off_) {
|
| SetDisplayForcedOff(false);
|
| + lock_screen_timer_.Stop();
|
| + }
|
| }
|
|
|
| void TabletPowerButtonController::OnStylusStateChanged(ui::StylusState state) {
|
| if (IsTabletModeSupported() && state == ui::StylusState::REMOVED &&
|
| backlights_forced_off_) {
|
| SetDisplayForcedOff(false);
|
| + lock_screen_timer_.Stop();
|
| }
|
| }
|
|
|
| @@ -234,8 +253,14 @@ void TabletPowerButtonController::LockScreenIfRequired() {
|
| session_state_delegate->CanLockScreen() &&
|
| !session_state_delegate->IsUserSessionBlocked() &&
|
| !controller_->LockRequested()) {
|
| - session_state_delegate->LockScreen();
|
| + lock_screen_timer_.Start(
|
| + FROM_HERE, base::TimeDelta::FromMilliseconds(kLockScreenTimeoutMs),
|
| + this, &TabletPowerButtonController::OnLockScreenTimeout);
|
| }
|
| }
|
|
|
| +void TabletPowerButtonController::OnLockScreenTimeout() {
|
| + WmShell::Get()->GetSessionStateDelegate()->LockScreen();
|
| +}
|
| +
|
| } // namespace ash
|
|
|