OLD | NEW |
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/shell_delegate.h" | 9 #include "ash/common/shell_delegate.h" |
10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 void TabletPowerButtonController::SetDisplayForcedOff(bool forced_off) { | 209 void TabletPowerButtonController::SetDisplayForcedOff(bool forced_off) { |
210 if (backlights_forced_off_ == forced_off) | 210 if (backlights_forced_off_ == forced_off) |
211 return; | 211 return; |
212 | 212 |
213 // Set the display and keyboard backlights (if present) to |forced_off|. | 213 // Set the display and keyboard backlights (if present) to |forced_off|. |
214 chromeos::DBusThreadManager::Get() | 214 chromeos::DBusThreadManager::Get() |
215 ->GetPowerManagerClient() | 215 ->GetPowerManagerClient() |
216 ->SetBacklightsForcedOff(forced_off); | 216 ->SetBacklightsForcedOff(forced_off); |
217 backlights_forced_off_ = forced_off; | 217 backlights_forced_off_ = forced_off; |
218 | 218 UpdateTouchscreenStatus(); |
219 ShellDelegate* delegate = WmShell::Get()->delegate(); | |
220 delegate->SetTouchscreenEnabledInPrefs(!forced_off, | |
221 true /* use_local_state */); | |
222 delegate->UpdateTouchscreenStatusFromPrefs(); | |
223 | 219 |
224 // Send an a11y alert. | 220 // Send an a11y alert. |
225 WmShell::Get()->accessibility_delegate()->TriggerAccessibilityAlert( | 221 WmShell::Get()->accessibility_delegate()->TriggerAccessibilityAlert( |
226 forced_off ? A11Y_ALERT_SCREEN_OFF : A11Y_ALERT_SCREEN_ON); | 222 forced_off ? A11Y_ALERT_SCREEN_OFF : A11Y_ALERT_SCREEN_ON); |
227 } | 223 } |
228 | 224 |
229 void TabletPowerButtonController::GetInitialBacklightsForcedOff() { | 225 void TabletPowerButtonController::GetInitialBacklightsForcedOff() { |
230 chromeos::DBusThreadManager::Get() | 226 chromeos::DBusThreadManager::Get() |
231 ->GetPowerManagerClient() | 227 ->GetPowerManagerClient() |
232 ->GetBacklightsForcedOff(base::Bind( | 228 ->GetBacklightsForcedOff(base::Bind( |
233 &TabletPowerButtonController::OnGotInitialBacklightsForcedOff, | 229 &TabletPowerButtonController::OnGotInitialBacklightsForcedOff, |
234 weak_ptr_factory_.GetWeakPtr())); | 230 weak_ptr_factory_.GetWeakPtr())); |
235 } | 231 } |
236 | 232 |
237 void TabletPowerButtonController::OnGotInitialBacklightsForcedOff( | 233 void TabletPowerButtonController::OnGotInitialBacklightsForcedOff( |
238 bool is_forced_off) { | 234 bool is_forced_off) { |
239 backlights_forced_off_ = is_forced_off; | 235 backlights_forced_off_ = is_forced_off; |
| 236 UpdateTouchscreenStatus(); |
| 237 } |
| 238 |
| 239 void TabletPowerButtonController::UpdateTouchscreenStatus() { |
| 240 ShellDelegate* delegate = WmShell::Get()->delegate(); |
| 241 delegate->SetTouchscreenEnabledInPrefs(!backlights_forced_off_, |
| 242 true /* use_local_state */); |
| 243 delegate->UpdateTouchscreenStatusFromPrefs(); |
240 } | 244 } |
241 | 245 |
242 void TabletPowerButtonController::StartShutdownTimer() { | 246 void TabletPowerButtonController::StartShutdownTimer() { |
243 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds( | 247 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds( |
244 screen_off_when_power_button_down_ ? kShutdownWhenScreenOffTimeoutMs | 248 screen_off_when_power_button_down_ ? kShutdownWhenScreenOffTimeoutMs |
245 : kShutdownWhenScreenOnTimeoutMs); | 249 : kShutdownWhenScreenOnTimeoutMs); |
246 shutdown_timer_.Start(FROM_HERE, timeout, this, | 250 shutdown_timer_.Start(FROM_HERE, timeout, this, |
247 &TabletPowerButtonController::OnShutdownTimeout); | 251 &TabletPowerButtonController::OnShutdownTimeout); |
248 } | 252 } |
249 | 253 |
250 void TabletPowerButtonController::OnShutdownTimeout() { | 254 void TabletPowerButtonController::OnShutdownTimeout() { |
251 controller_->StartShutdownAnimation(); | 255 controller_->StartShutdownAnimation(); |
252 } | 256 } |
253 | 257 |
254 void TabletPowerButtonController::LockScreenIfRequired() { | 258 void TabletPowerButtonController::LockScreenIfRequired() { |
255 SessionStateDelegate* session_state_delegate = | 259 SessionStateDelegate* session_state_delegate = |
256 WmShell::Get()->GetSessionStateDelegate(); | 260 WmShell::Get()->GetSessionStateDelegate(); |
257 if (session_state_delegate->ShouldLockScreenAutomatically() && | 261 if (session_state_delegate->ShouldLockScreenAutomatically() && |
258 session_state_delegate->CanLockScreen() && | 262 session_state_delegate->CanLockScreen() && |
259 !session_state_delegate->IsUserSessionBlocked() && | 263 !session_state_delegate->IsUserSessionBlocked() && |
260 !controller_->LockRequested()) { | 264 !controller_->LockRequested()) { |
261 session_state_delegate->LockScreen(); | 265 session_state_delegate->LockScreen(); |
262 } | 266 } |
263 } | 267 } |
264 | 268 |
265 } // namespace ash | 269 } // namespace ash |
OLD | NEW |