Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2517)

Unified Diff: ash/wm/power_button_controller.cc

Issue 10382211: chromeos: Ignore power button presses when screen is off. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/power_button_controller.h ('k') | ash/wm/power_button_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/power_button_controller.cc
diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc
index 22fd150455e8d82f59c3c64fc03d6577d81dfed4..19052194a337d62791e8e78046eef0381f9f152c 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
« no previous file with comments | « ash/wm/power_button_controller.h ('k') | ash/wm/power_button_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698