| OLD | NEW |
| 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" |
| 11 #include "ash/wm/lock_state_controller.h" | 11 #include "ash/wm/lock_state_controller.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "chromeos/chromeos_switches.h" | 15 #include "chromeos/chromeos_switches.h" |
| 16 #include "components/signin/core/account_id/account_id.h" | 16 #include "components/signin/core/account_id/account_id.h" |
| 17 #include "components/user_manager/user_type.h" |
| 17 #include "services/service_manager/public/cpp/connector.h" | 18 #include "services/service_manager/public/cpp/connector.h" |
| 18 | 19 |
| 19 using session_manager::SessionState; | 20 using session_manager::SessionState; |
| 20 | 21 |
| 21 namespace ash { | 22 namespace ash { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Get the default session state. Default session state is ACTIVE when the | 26 // Get the default session state. Default session state is ACTIVE when the |
| 26 // process starts with a user session, i.e. the process has kLoginUser command | 27 // process starts with a user session, i.e. the process has kLoginUser command |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 120 } |
| 120 | 121 |
| 121 const mojom::UserSession* SessionController::GetUserSession( | 122 const mojom::UserSession* SessionController::GetUserSession( |
| 122 UserIndex index) const { | 123 UserIndex index) const { |
| 123 if (index < 0 || index >= static_cast<UserIndex>(user_sessions_.size())) | 124 if (index < 0 || index >= static_cast<UserIndex>(user_sessions_.size())) |
| 124 return nullptr; | 125 return nullptr; |
| 125 | 126 |
| 126 return user_sessions_[index].get(); | 127 return user_sessions_[index].get(); |
| 127 } | 128 } |
| 128 | 129 |
| 130 bool SessionController::IsUserSupervised() const { |
| 131 if (!IsActiveUserSessionStarted()) |
| 132 return false; |
| 133 |
| 134 user_manager::UserType active_user_type = GetUserSession(0)->type; |
| 135 return active_user_type == user_manager::USER_TYPE_SUPERVISED || |
| 136 active_user_type == user_manager::USER_TYPE_CHILD; |
| 137 } |
| 138 |
| 139 bool SessionController::IsUserChild() const { |
| 140 if (!IsActiveUserSessionStarted()) |
| 141 return false; |
| 142 |
| 143 user_manager::UserType active_user_type = GetUserSession(0)->type; |
| 144 return active_user_type == user_manager::USER_TYPE_CHILD; |
| 145 } |
| 146 |
| 129 void SessionController::LockScreen() { | 147 void SessionController::LockScreen() { |
| 130 if (client_) | 148 if (client_) |
| 131 client_->RequestLockScreen(); | 149 client_->RequestLockScreen(); |
| 132 } | 150 } |
| 133 | 151 |
| 134 void SessionController::SwitchActiveUser(const AccountId& account_id) { | 152 void SessionController::SwitchActiveUser(const AccountId& account_id) { |
| 135 if (client_) | 153 if (client_) |
| 136 client_->SwitchActiveUser(account_id); | 154 client_->SwitchActiveUser(account_id); |
| 137 } | 155 } |
| 138 | 156 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 338 } // namespace ash | 356 } // namespace ash |
| OLD | NEW |