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

Side by Side Diff: ash/session/session_controller.cc

Issue 2830933002: cros: Use SessionController for lock starting code (Closed)
Patch Set: fix nit Created 3 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 unified diff | Download patch
« no previous file with comments | « ash/session/session_controller.h ('k') | ash/wm/lock_state_controller.h » ('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 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/session/session_controller.h" 5 #include "ash/session/session_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/session/session_observer.h" 9 #include "ash/session/session_observer.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 23 matching lines...) Expand all
34 // chrome to update ash for such cases. 34 // chrome to update ash for such cases.
35 SessionState GetDefaultSessionState() { 35 SessionState GetDefaultSessionState() {
36 const bool start_with_user = 36 const bool start_with_user =
37 base::CommandLine::ForCurrentProcess()->HasSwitch( 37 base::CommandLine::ForCurrentProcess()->HasSwitch(
38 chromeos::switches::kLoginUser); 38 chromeos::switches::kLoginUser);
39 return start_with_user ? SessionState::ACTIVE : SessionState::UNKNOWN; 39 return start_with_user ? SessionState::ACTIVE : SessionState::UNKNOWN;
40 } 40 }
41 41
42 } // namespace 42 } // namespace
43 43
44 SessionController::SessionController() : state_(GetDefaultSessionState()) {} 44 SessionController::SessionController()
45 : state_(GetDefaultSessionState()), weak_ptr_factory_(this) {}
45 46
46 SessionController::~SessionController() {} 47 SessionController::~SessionController() {
48 // Abort pending start lock request.
49 if (!start_lock_callback_.is_null())
50 std::move(start_lock_callback_).Run(false /* locked */);
51 }
47 52
48 void SessionController::BindRequest(mojom::SessionControllerRequest request) { 53 void SessionController::BindRequest(mojom::SessionControllerRequest request) {
49 bindings_.AddBinding(this, std::move(request)); 54 bindings_.AddBinding(this, std::move(request));
50 } 55 }
51 56
52 int SessionController::GetMaximumNumberOfLoggedInUsers() const { 57 int SessionController::GetMaximumNumberOfLoggedInUsers() const {
53 return session_manager::kMaxmiumNumberOfUserSessions; 58 return session_manager::kMaxmiumNumberOfUserSessions;
54 } 59 }
55 60
56 int SessionController::NumberOfLoggedInUsers() const { 61 int SessionController::NumberOfLoggedInUsers() const {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 if (user_sessions_[0]->session_id != active_session_id_) { 208 if (user_sessions_[0]->session_id != active_session_id_) {
204 active_session_id_ = user_sessions_[0]->session_id; 209 active_session_id_ = user_sessions_[0]->session_id;
205 210
206 for (auto& observer : observers_) 211 for (auto& observer : observers_)
207 observer.OnActiveUserSessionChanged(user_sessions_[0]->account_id); 212 observer.OnActiveUserSessionChanged(user_sessions_[0]->account_id);
208 213
209 UpdateLoginStatus(); 214 UpdateLoginStatus();
210 } 215 }
211 } 216 }
212 217
218 void SessionController::StartLock(const StartLockCallback& callback) {
219 DCHECK(start_lock_callback_.is_null());
220 start_lock_callback_ = callback;
221
222 LockStateController* const lock_state_controller =
223 Shell::Get()->lock_state_controller();
224
225 lock_state_controller->SetLockScreenDisplayedCallback(
226 base::Bind(&SessionController::OnLockAnimationFinished,
227 weak_ptr_factory_.GetWeakPtr()));
228 lock_state_controller->OnStartingLock();
229 }
230
213 void SessionController::RunUnlockAnimation( 231 void SessionController::RunUnlockAnimation(
214 const RunUnlockAnimationCallback& callback) { 232 const RunUnlockAnimationCallback& callback) {
215 is_unlocking_ = true; 233 is_unlocking_ = true;
216 234
217 // Shell could have no instance in tests. 235 // Shell could have no instance in tests.
218 if (Shell::HasInstance()) 236 if (Shell::HasInstance())
219 Shell::Get()->lock_state_controller()->OnLockScreenHide(callback); 237 Shell::Get()->lock_state_controller()->OnLockScreenHide(callback);
220 } 238 }
221 239
222 void SessionController::NotifyChromeTerminating() { 240 void SessionController::NotifyChromeTerminating() {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 void SessionController::UpdateLoginStatus() { 346 void SessionController::UpdateLoginStatus() {
329 const LoginStatus new_login_status = CalculateLoginStatus(); 347 const LoginStatus new_login_status = CalculateLoginStatus();
330 if (new_login_status == login_status_) 348 if (new_login_status == login_status_)
331 return; 349 return;
332 350
333 login_status_ = new_login_status; 351 login_status_ = new_login_status;
334 for (auto& observer : observers_) 352 for (auto& observer : observers_)
335 observer.OnLoginStatusChanged(login_status_); 353 observer.OnLoginStatusChanged(login_status_);
336 } 354 }
337 355
356 void SessionController::OnLockAnimationFinished() {
357 if (!start_lock_callback_.is_null())
358 std::move(start_lock_callback_).Run(true /* locked */);
359 }
360
338 } // namespace ash 361 } // namespace ash
OLDNEW
« no previous file with comments | « ash/session/session_controller.h ('k') | ash/wm/lock_state_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698