summaryrefslogtreecommitdiffstats
path: root/ash/wm/power_button_controller.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ash/wm/power_button_controller.cc')
-rw-r--r--ash/wm/power_button_controller.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc
index 22fd150..1905219 100644
--- a/ash/wm/power_button_controller.cc
+++ b/ash/wm/power_button_controller.cc
@@ -285,6 +285,7 @@ PowerButtonController::PowerButtonController()
unlocked_login_status_(user::LOGGED_IN_NONE),
power_button_down_(false),
lock_button_down_(false),
+ screen_is_off_(false),
shutting_down_(false),
has_legacy_power_button_(
CommandLine::ForCurrentProcess()->HasSwitch(
@@ -345,6 +346,10 @@ void PowerButtonController::OnLockStateChanged(bool locked) {
}
}
+void PowerButtonController::OnScreenBrightnessChanged(double percent) {
+ screen_is_off_ = percent <= 0.001;
+}
+
void PowerButtonController::OnStartingLock() {
if (shutting_down_ || login_status_ == user::LOGGED_IN_LOCKED)
return;
@@ -368,6 +373,11 @@ void PowerButtonController::OnPowerButtonEvent(
if (shutting_down_)
return;
+ // Avoid starting the lock/shutdown sequence if the power button is pressed
+ // while the screen is off (http://crbug.com/128451).
+ if (screen_is_off_)
+ return;
+
if (has_legacy_power_button_) {
// If power button releases won't get reported correctly because we're not
// running on official hardware, just lock the screen or shut down