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

Side by Side Diff: ash/system/chromeos/power/tablet_power_button_controller.cc

Issue 2544073002: Resuming from suspend should stop backlights forced off if they are (Closed)
Patch Set: add test coverage Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/system/chromeos/power/tablet_power_button_controller.h" 5 #include "ash/system/chromeos/power/tablet_power_button_controller.h"
6 6
7 #include "ash/common/accessibility_delegate.h" 7 #include "ash/common/accessibility_delegate.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 bool TabletPowerButtonController::ShouldHandlePowerButtonEvents() const { 87 bool TabletPowerButtonController::ShouldHandlePowerButtonEvents() const {
88 return IsTabletModeSupported(); 88 return IsTabletModeSupported();
89 } 89 }
90 90
91 void TabletPowerButtonController::OnPowerButtonEvent( 91 void TabletPowerButtonController::OnPowerButtonEvent(
92 bool down, 92 bool down,
93 const base::TimeTicks& timestamp) { 93 const base::TimeTicks& timestamp) {
94 // When the system resumes in response to the power button being pressed, 94 // When the system resumes in response to the power button being pressed,
95 // Chrome receives powerd's SuspendDone signal and notification that the 95 // Chrome receives powerd's SuspendDone signal and notification that the
96 // backlight has been turned back on before seeing the power button events 96 // backlight has been turned back on before seeing the power button events
97 // that woke the system. Ignore events just after resuming to ensure that we 97 // that woke the system. If backlights are forced off, stop forcing off
Daniel Erat 2016/12/02 00:58:27 nit: i'd move this "If ..." part down just before
98 // don't turn the screen off in response to the events. 98 // because resuming system doesn't handle this, otherwise ignore events
99 // just after resuming to ensure that we don't turn the screen off in response
100 // to the events.
99 if (timestamp - last_resume_time_ <= 101 if (timestamp - last_resume_time_ <=
100 base::TimeDelta::FromMilliseconds(kIgnorePowerButtonAfterResumeMs)) { 102 base::TimeDelta::FromMilliseconds(kIgnorePowerButtonAfterResumeMs)) {
103 if (down && backlights_forced_off_)
104 SetBacklightsForcedOff(false);
Qiang(Joe) Xu 2016/12/02 01:06:38 Hi, just want to mention here, the long pressed sh
Daniel Erat 2016/12/02 01:10:26 are you just saying power button down events that
101 return; 105 return;
102 } 106 }
103 107
104 if (down) { 108 if (down) {
105 screen_off_when_power_button_down_ = brightness_level_is_zero_; 109 screen_off_when_power_button_down_ = brightness_level_is_zero_;
106 SetBacklightsForcedOff(false); 110 SetBacklightsForcedOff(false);
107 StartShutdownTimer(); 111 StartShutdownTimer();
108 } else { 112 } else {
109 if (shutdown_timer_.IsRunning()) { 113 if (shutdown_timer_.IsRunning()) {
110 shutdown_timer_.Stop(); 114 shutdown_timer_.Stop();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 WmShell::Get()->GetSessionStateDelegate(); 219 WmShell::Get()->GetSessionStateDelegate();
216 if (session_state_delegate->ShouldLockScreenAutomatically() && 220 if (session_state_delegate->ShouldLockScreenAutomatically() &&
217 session_state_delegate->CanLockScreen() && 221 session_state_delegate->CanLockScreen() &&
218 !session_state_delegate->IsUserSessionBlocked() && 222 !session_state_delegate->IsUserSessionBlocked() &&
219 !controller_->LockRequested()) { 223 !controller_->LockRequested()) {
220 session_state_delegate->LockScreen(); 224 session_state_delegate->LockScreen();
221 } 225 }
222 } 226 }
223 227
224 } // namespace ash 228 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698