Chromium Code Reviews| 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 66841d16597b65f645e36c4b68846202ecc4625e..7b9e7ab4b36c72cf136c063f7151d69e0afeef40 100644 |
| --- a/ash/system/chromeos/power/tablet_power_button_controller.cc |
| +++ b/ash/system/chromeos/power/tablet_power_button_controller.cc |
| @@ -68,6 +68,7 @@ TabletPowerButtonController::TabletPowerButtonController( |
| LockStateController* controller) |
| : tick_clock_(new base::DefaultTickClock()), |
| last_resume_time_(base::TimeTicks()), |
| + force_off_on_button_up_(true), |
| controller_(controller), |
| weak_ptr_factory_(this) { |
| chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( |
| @@ -92,36 +93,28 @@ bool TabletPowerButtonController::ShouldHandlePowerButtonEvents() const { |
| void TabletPowerButtonController::OnPowerButtonEvent( |
| bool down, |
| const base::TimeTicks& timestamp) { |
| - // When the system resumes in response to the power button being pressed, |
| - // Chrome receives powerd's SuspendDone signal and notification that the |
| - // backlight has been turned back on before seeing the power button events |
| - // that woke the system. Ignore events just after resuming to ensure that we |
| - // don't turn the screen off in response to the events. |
| - // |
| - // TODO(warx): pressing power button should also StartShutdownTimer() in this |
| - // case. Reorganize the code to support that. |
| - if (timestamp - last_resume_time_ <= |
| - base::TimeDelta::FromMilliseconds(kIgnorePowerButtonAfterResumeMs)) { |
| - // If backlights are forced off, stop forcing off because resuming system |
| - // doesn't handle this. |
| - if (down && backlights_forced_off_) |
| - SetDisplayForcedOff(false); |
| - return; |
| - } |
| - |
| if (down) { |
| + force_off_on_button_up_ = true; |
| + // When the system resumes in response to the power button being pressed, |
| + // Chrome receives powerd's SuspendDone signal and notification that the |
| + // baclight has been turned back on before seeing the power button events |
|
Daniel Erat
2016/12/05 22:08:09
nit: s/baclight/backlight/
Qiang(Joe) Xu
2016/12/05 22:38:29
Done.
|
| + // that woke the system. Ignore forcing off display just after resuming to |
|
Daniel Erat
2016/12/05 22:08:09
nit: s/Ignore/Avoid/
Qiang(Joe) Xu
2016/12/05 22:38:29
Done.
|
| + // ensure that we don't turn the display off in response to the events. |
| + if (timestamp - last_resume_time_ <= |
| + base::TimeDelta::FromMilliseconds(kIgnorePowerButtonAfterResumeMs)) { |
| + force_off_on_button_up_ = false; |
| + } |
| screen_off_when_power_button_down_ = brightness_level_is_zero_; |
| SetDisplayForcedOff(false); |
| StartShutdownTimer(); |
| } else { |
| if (shutdown_timer_.IsRunning()) { |
| shutdown_timer_.Stop(); |
| - if (!screen_off_when_power_button_down_) { |
| + if (!screen_off_when_power_button_down_ && force_off_on_button_up_) { |
| SetDisplayForcedOff(true); |
| LockScreenIfRequired(); |
| } |
| } |
| - screen_off_when_power_button_down_ = false; |
|
Qiang(Joe) Xu
2016/12/05 19:33:59
feel this is not needed, as it is always updated i
Daniel Erat
2016/12/05 22:08:09
yep, i agree
|
| // When power button is released, cancel shutdown animation whenever it is |
| // still cancellable. |