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

Side by Side Diff: ash/wm/power_button_controller.cc

Issue 2734933004: ash: Use SessionController instead of SessionStateDelegate (Closed)
Patch Set: rebase to get WorkspaceLayoutManagerSoloTest change Created 3 years, 9 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
« no previous file with comments | « ash/wm/lock_state_controller_unittest.cc ('k') | ash/wm/window_cycle_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/wm/power_button_controller.h" 5 #include "ash/wm/power_button_controller.h"
6 6
7 #include "ash/common/accelerators/accelerator_controller.h" 7 #include "ash/common/accelerators/accelerator_controller.h"
8 #include "ash/common/ash_switches.h" 8 #include "ash/common/ash_switches.h"
9 #include "ash/common/session/session_state_delegate.h" 9 #include "ash/common/session/session_controller.h"
10 #include "ash/common/system/chromeos/audio/tray_audio.h" 10 #include "ash/common/system/chromeos/audio/tray_audio.h"
11 #include "ash/common/system/tray/system_tray.h" 11 #include "ash/common/system/tray/system_tray.h"
12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
13 #include "ash/common/wm_shell.h" 13 #include "ash/common/wm_shell.h"
14 #include "ash/public/cpp/shell_window_ids.h" 14 #include "ash/public/cpp/shell_window_ids.h"
15 #include "ash/shell.h" 15 #include "ash/shell.h"
16 #include "ash/system/chromeos/power/tablet_power_button_controller.h" 16 #include "ash/system/chromeos/power/tablet_power_button_controller.h"
17 #include "ash/wm/lock_state_controller.h" 17 #include "ash/wm/lock_state_controller.h"
18 #include "ash/wm/session_state_animator.h" 18 #include "ash/wm/session_state_animator.h"
19 #include "base/command_line.h" 19 #include "base/command_line.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 // Restore volume. 97 // Restore volume.
98 chromeos::CrasAudioHandler* audio_handler = 98 chromeos::CrasAudioHandler* audio_handler =
99 chromeos::CrasAudioHandler::Get(); 99 chromeos::CrasAudioHandler::Get();
100 audio_handler->SetOutputVolumePercentWithoutNotifyingObservers( 100 audio_handler->SetOutputVolumePercentWithoutNotifyingObservers(
101 volume_percent_before_screenshot_, 101 volume_percent_before_screenshot_,
102 chromeos::CrasAudioHandler::VOLUME_CHANGE_MAXIMIZE_MODE_SCREENSHOT); 102 chromeos::CrasAudioHandler::VOLUME_CHANGE_MAXIMIZE_MODE_SCREENSHOT);
103 return; 103 return;
104 } 104 }
105 105
106 const SessionStateDelegate* session_state_delegate = 106 const SessionController* const session_controller =
107 WmShell::Get()->GetSessionStateDelegate(); 107 WmShell::Get()->session_controller();
108 if (has_legacy_power_button_) { 108 if (has_legacy_power_button_) {
109 // If power button releases won't get reported correctly because we're not 109 // If power button releases won't get reported correctly because we're not
110 // running on official hardware, just lock the screen or shut down 110 // running on official hardware, just lock the screen or shut down
111 // immediately. 111 // immediately.
112 if (down) { 112 if (down) {
113 if (session_state_delegate->CanLockScreen() && 113 if (session_controller->CanLockScreen() &&
114 !session_state_delegate->IsUserSessionBlocked() && 114 !session_controller->IsUserSessionBlocked() &&
115 !lock_state_controller_->LockRequested()) { 115 !lock_state_controller_->LockRequested()) {
116 lock_state_controller_->StartLockAnimationAndLockImmediately(false); 116 lock_state_controller_->StartLockAnimationAndLockImmediately(false);
117 } else { 117 } else {
118 lock_state_controller_->RequestShutdown(); 118 lock_state_controller_->RequestShutdown();
119 } 119 }
120 } 120 }
121 } else { // !has_legacy_power_button_ 121 } else { // !has_legacy_power_button_
122 if (down) { 122 if (down) {
123 // If we already have a pending request to lock the screen, wait. 123 // If we already have a pending request to lock the screen, wait.
124 if (lock_state_controller_->LockRequested()) 124 if (lock_state_controller_->LockRequested())
125 return; 125 return;
126 126
127 if (session_state_delegate->CanLockScreen() && 127 if (session_controller->CanLockScreen() &&
128 !session_state_delegate->IsUserSessionBlocked()) { 128 !session_controller->IsUserSessionBlocked()) {
129 lock_state_controller_->StartLockAnimation(true); 129 lock_state_controller_->StartLockAnimation(true);
130 } else { 130 } else {
131 lock_state_controller_->StartShutdownAnimation(); 131 lock_state_controller_->StartShutdownAnimation();
132 } 132 }
133 } else { // Button is up. 133 } else { // Button is up.
134 if (lock_state_controller_->CanCancelLockAnimation()) 134 if (lock_state_controller_->CanCancelLockAnimation())
135 lock_state_controller_->CancelLockAnimation(); 135 lock_state_controller_->CancelLockAnimation();
136 else if (lock_state_controller_->CanCancelShutdownAnimation()) 136 else if (lock_state_controller_->CanCancelShutdownAnimation())
137 lock_state_controller_->CancelShutdownAnimation(); 137 lock_state_controller_->CancelShutdownAnimation();
138 } 138 }
139 } 139 }
140 } 140 }
141 141
142 void PowerButtonController::OnLockButtonEvent( 142 void PowerButtonController::OnLockButtonEvent(
143 bool down, 143 bool down,
144 const base::TimeTicks& timestamp) { 144 const base::TimeTicks& timestamp) {
145 lock_button_down_ = down; 145 lock_button_down_ = down;
146 146
147 const SessionStateDelegate* session_state_delegate = 147 const SessionController* const session_controller =
148 WmShell::Get()->GetSessionStateDelegate(); 148 WmShell::Get()->session_controller();
149 if (!session_state_delegate->CanLockScreen() || 149 if (!session_controller->CanLockScreen() ||
150 session_state_delegate->IsScreenLocked() || 150 session_controller->IsScreenLocked() ||
151 lock_state_controller_->LockRequested() || 151 lock_state_controller_->LockRequested() ||
152 lock_state_controller_->ShutdownRequested()) { 152 lock_state_controller_->ShutdownRequested()) {
153 return; 153 return;
154 } 154 }
155 155
156 // Give the power button precedence over the lock button. 156 // Give the power button precedence over the lock button.
157 if (power_button_down_) 157 if (power_button_down_)
158 return; 158 return;
159 159
160 if (down) 160 if (down)
(...skipping 30 matching lines...) Expand all
191 internal_display_off && external_display_on; 191 internal_display_off && external_display_on;
192 } 192 }
193 193
194 void PowerButtonController::PowerButtonEventReceived( 194 void PowerButtonController::PowerButtonEventReceived(
195 bool down, 195 bool down,
196 const base::TimeTicks& timestamp) { 196 const base::TimeTicks& timestamp) {
197 OnPowerButtonEvent(down, timestamp); 197 OnPowerButtonEvent(down, timestamp);
198 } 198 }
199 199
200 } // namespace ash 200 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/lock_state_controller_unittest.cc ('k') | ash/wm/window_cycle_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698