| 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/common/session/session_controller.h" | 5 #include "ash/common/session/session_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/common/session/session_state_observer.h" | 9 #include "ash/common/session/session_state_observer.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "components/signin/core/account_id/account_id.h" | 12 #include "components/signin/core/account_id/account_id.h" |
| 13 #include "services/service_manager/public/cpp/connector.h" | 13 #include "services/service_manager/public/cpp/connector.h" |
| 14 | 14 |
| 15 namespace ash { | 15 namespace ash { |
| 16 | 16 |
| 17 SessionController::SessionController() {} | 17 SessionController::SessionController() {} |
| 18 | 18 |
| 19 SessionController::~SessionController() {} | 19 SessionController::~SessionController() {} |
| 20 | 20 |
| 21 void SessionController::BindRequest(mojom::SessionControllerRequest request) { | 21 void SessionController::BindRequest(mojom::SessionControllerRequest request) { |
| 22 bindings_.AddBinding(this, std::move(request)); | 22 bindings_.AddBinding(this, std::move(request)); |
| 23 } | 23 } |
| 24 | 24 |
| 25 int SessionController::GetMaximumNumberOfLoggedInUsers() const { | 25 int SessionController::GetMaximumNumberOfLoggedInUsers() const { |
| 26 return static_cast<int>(max_users_); | 26 return session_manager::kMaxmiumNumberOfUserSessions; |
| 27 } | 27 } |
| 28 | 28 |
| 29 int SessionController::NumberOfLoggedInUsers() const { | 29 int SessionController::NumberOfLoggedInUsers() const { |
| 30 return static_cast<int>(user_sessions_.size()); | 30 return static_cast<int>(user_sessions_.size()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 AddUserSessionPolicy SessionController::GetAddUserPolicy() const { | 33 AddUserSessionPolicy SessionController::GetAddUserPolicy() const { |
| 34 return add_user_session_policy_; | 34 return add_user_session_policy_; |
| 35 } | 35 } |
| 36 | 36 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 void SessionController::RemoveSessionStateObserver( | 86 void SessionController::RemoveSessionStateObserver( |
| 87 SessionStateObserver* observer) { | 87 SessionStateObserver* observer) { |
| 88 observers_.RemoveObserver(observer); | 88 observers_.RemoveObserver(observer); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void SessionController::SetClient(mojom::SessionControllerClientPtr client) { | 91 void SessionController::SetClient(mojom::SessionControllerClientPtr client) { |
| 92 client_ = std::move(client); | 92 client_ = std::move(client); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void SessionController::SetSessionInfo(mojom::SessionInfoPtr info) { | 95 void SessionController::SetSessionInfo(mojom::SessionInfoPtr info) { |
| 96 max_users_ = info->max_users; | |
| 97 can_lock_ = info->can_lock_screen; | 96 can_lock_ = info->can_lock_screen; |
| 98 should_lock_screen_automatically_ = info->should_lock_screen_automatically; | 97 should_lock_screen_automatically_ = info->should_lock_screen_automatically; |
| 99 add_user_session_policy_ = info->add_user_session_policy; | 98 add_user_session_policy_ = info->add_user_session_policy; |
| 100 SetSessionState(info->state); | 99 SetSessionState(info->state); |
| 101 } | 100 } |
| 102 | 101 |
| 103 void SessionController::UpdateUserSession(mojom::UserSessionPtr user_session) { | 102 void SessionController::UpdateUserSession(mojom::UserSessionPtr user_session) { |
| 104 auto it = | 103 auto it = |
| 105 std::find_if(user_sessions_.begin(), user_sessions_.end(), | 104 std::find_if(user_sessions_.begin(), user_sessions_.end(), |
| 106 [&user_session](const mojom::UserSessionPtr& session) { | 105 [&user_session](const mojom::UserSessionPtr& session) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 void SessionController::AddUserSession(mojom::UserSessionPtr user_session) { | 157 void SessionController::AddUserSession(mojom::UserSessionPtr user_session) { |
| 159 const AccountId account_id(user_session->account_id); | 158 const AccountId account_id(user_session->account_id); |
| 160 | 159 |
| 161 user_sessions_.push_back(std::move(user_session)); | 160 user_sessions_.push_back(std::move(user_session)); |
| 162 | 161 |
| 163 for (auto& observer : observers_) | 162 for (auto& observer : observers_) |
| 164 observer.UserAddedToSession(account_id); | 163 observer.UserAddedToSession(account_id); |
| 165 } | 164 } |
| 166 | 165 |
| 167 } // namespace ash | 166 } // namespace ash |
| OLD | NEW |