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

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: rebase 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 ShellDelegate* delegate = Shell::Get()->shell_delegate();
226 backlights_forced_off_ ? delegate->SuspendMediaSessions()
227 : delegate->ResumeMediaSessions();
Daniel Erat 2017/05/17 01:22:25 please update unit tests to check that this happen
Qiang(Joe) Xu 2017/05/22 22:58:47 Done.
228
225 // Send an a11y alert. 229 // Send an a11y alert.
226 Shell::Get()->accessibility_delegate()->TriggerAccessibilityAlert( 230 Shell::Get()->accessibility_delegate()->TriggerAccessibilityAlert(
227 forced_off ? A11Y_ALERT_SCREEN_OFF : A11Y_ALERT_SCREEN_ON); 231 forced_off ? A11Y_ALERT_SCREEN_OFF : A11Y_ALERT_SCREEN_ON);
228 } 232 }
229 233
230 void TabletPowerButtonController::GetInitialBacklightsForcedOff() { 234 void TabletPowerButtonController::GetInitialBacklightsForcedOff() {
231 chromeos::DBusThreadManager::Get() 235 chromeos::DBusThreadManager::Get()
232 ->GetPowerManagerClient() 236 ->GetPowerManagerClient()
233 ->GetBacklightsForcedOff(base::Bind( 237 ->GetBacklightsForcedOff(base::Bind(
234 &TabletPowerButtonController::OnGotInitialBacklightsForcedOff, 238 &TabletPowerButtonController::OnGotInitialBacklightsForcedOff,
(...skipping 29 matching lines...) Expand all
264 SessionController* session_controller = Shell::Get()->session_controller(); 268 SessionController* session_controller = Shell::Get()->session_controller();
265 if (session_controller->ShouldLockScreenAutomatically() && 269 if (session_controller->ShouldLockScreenAutomatically() &&
266 session_controller->CanLockScreen() && 270 session_controller->CanLockScreen() &&
267 !session_controller->IsUserSessionBlocked() && 271 !session_controller->IsUserSessionBlocked() &&
268 !controller_->LockRequested()) { 272 !controller_->LockRequested()) {
269 session_controller->LockScreen(); 273 session_controller->LockScreen();
270 } 274 }
271 } 275 }
272 276
273 } // namespace ash 277 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698