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

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

Issue 2821303004: cros: Suspend media sessions with display off trigger by tablet power button (Closed)
Patch Set: feedback & remove resuming Created 3 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 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/power/tablet_power_button_controller.h" 5 #include "ash/system/power/tablet_power_button_controller.h"
6 6
7 #include "ash/accessibility_delegate.h" 7 #include "ash/accessibility_delegate.h"
8 #include "ash/session/session_controller.h" 8 #include "ash/session/session_controller.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_delegate.h" 10 #include "ash/shell_delegate.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 if (backlights_forced_off_ == forced_off) 215 if (backlights_forced_off_ == forced_off)
216 return; 216 return;
217 217
218 // Set the display and keyboard backlights (if present) to |forced_off|. 218 // Set the display and keyboard backlights (if present) to |forced_off|.
219 chromeos::DBusThreadManager::Get() 219 chromeos::DBusThreadManager::Get()
220 ->GetPowerManagerClient() 220 ->GetPowerManagerClient()
221 ->SetBacklightsForcedOff(forced_off); 221 ->SetBacklightsForcedOff(forced_off);
222 backlights_forced_off_ = forced_off; 222 backlights_forced_off_ = forced_off;
223 UpdateTouchscreenStatus(); 223 UpdateTouchscreenStatus();
224 224
225 if (backlights_forced_off_) {
226 ShellDelegate* delegate = Shell::Get()->shell_delegate();
227 delegate->SuspendMediaSessions();
Daniel Erat 2017/05/22 23:38:34 nit: i'd put this on a single line since you only
Qiang(Joe) Xu 2017/05/23 17:54:46 Done.
228 }
229
225 // Send an a11y alert. 230 // Send an a11y alert.
226 Shell::Get()->accessibility_delegate()->TriggerAccessibilityAlert( 231 Shell::Get()->accessibility_delegate()->TriggerAccessibilityAlert(
227 forced_off ? A11Y_ALERT_SCREEN_OFF : A11Y_ALERT_SCREEN_ON); 232 forced_off ? A11Y_ALERT_SCREEN_OFF : A11Y_ALERT_SCREEN_ON);
228 } 233 }
229 234
230 void TabletPowerButtonController::GetInitialBacklightsForcedOff() { 235 void TabletPowerButtonController::GetInitialBacklightsForcedOff() {
231 chromeos::DBusThreadManager::Get() 236 chromeos::DBusThreadManager::Get()
232 ->GetPowerManagerClient() 237 ->GetPowerManagerClient()
233 ->GetBacklightsForcedOff(base::Bind( 238 ->GetBacklightsForcedOff(base::Bind(
234 &TabletPowerButtonController::OnGotInitialBacklightsForcedOff, 239 &TabletPowerButtonController::OnGotInitialBacklightsForcedOff,
(...skipping 29 matching lines...) Expand all
264 SessionController* session_controller = Shell::Get()->session_controller(); 269 SessionController* session_controller = Shell::Get()->session_controller();
265 if (session_controller->ShouldLockScreenAutomatically() && 270 if (session_controller->ShouldLockScreenAutomatically() &&
266 session_controller->CanLockScreen() && 271 session_controller->CanLockScreen() &&
267 !session_controller->IsUserSessionBlocked() && 272 !session_controller->IsUserSessionBlocked() &&
268 !controller_->LockRequested()) { 273 !controller_->LockRequested()) {
269 session_controller->LockScreen(); 274 session_controller->LockScreen();
270 } 275 }
271 } 276 }
272 277
273 } // namespace ash 278 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698