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

Unified Diff: ash/wm/power_button_controller.cc

Issue 14295008: Add ash SessionStateDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 7 years, 8 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/gestures/shelf_gesture_handler.cc ('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 9359b8a2bc5fb2a8bb06d2c42a842c699be6aadb..685060806036a8a0ed30dc89830fa437ce0299d4 100644
--- a/ash/wm/power_button_controller.cc
+++ b/ash/wm/power_button_controller.cc
@@ -5,8 +5,8 @@
#include "ash/wm/power_button_controller.h"
#include "ash/ash_switches.h"
+#include "ash/session_state_delegate.h"
#include "ash/shell.h"
-#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/session_state_animator.h"
#include "ash/wm/session_state_controller.h"
@@ -45,13 +45,15 @@ void PowerButtonController::OnPowerButtonEvent(
if (screen_is_off_)
return;
- Shell* shell = Shell::GetInstance();
+ const SessionStateDelegate* session_state_delegate =
+ Shell::GetInstance()->session_state_delegate();
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
// immediately.
if (down) {
- if (shell->CanLockScreen() && !shell->IsScreenLocked() &&
+ if (session_state_delegate->CanLockScreen() &&
+ !session_state_delegate->IsScreenLocked() &&
!controller_->LockRequested()) {
controller_->StartLockAnimationAndLockImmediately();
} else {
@@ -64,10 +66,12 @@ void PowerButtonController::OnPowerButtonEvent(
if (controller_->LockRequested())
return;
- if (shell->CanLockScreen() && !shell->IsScreenLocked())
+ if (session_state_delegate->CanLockScreen() &&
+ !session_state_delegate->IsScreenLocked()) {
controller_->StartLockAnimation(true);
- else
+ } else {
controller_->StartShutdownAnimation();
+ }
} else { // Button is up.
if (controller_->CanCancelLockAnimation())
controller_->CancelLockAnimation();
@@ -81,9 +85,12 @@ void PowerButtonController::OnLockButtonEvent(
bool down, const base::TimeTicks& timestamp) {
lock_button_down_ = down;
- Shell* shell = Shell::GetInstance();
- if (!shell->CanLockScreen() || shell->IsScreenLocked() ||
- controller_->LockRequested() || controller_->ShutdownRequested()) {
+ const SessionStateDelegate* session_state_delegate =
+ Shell::GetInstance()->session_state_delegate();
+ if (!session_state_delegate->CanLockScreen() ||
+ session_state_delegate->IsScreenLocked() ||
+ controller_->LockRequested() ||
+ controller_->ShutdownRequested()) {
return;
}
« no previous file with comments | « ash/wm/gestures/shelf_gesture_handler.cc ('k') | ash/wm/power_button_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698