| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/session_manager/core/session_manager.h" | 5 #include "components/session_manager/core/session_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool SessionManager::IsSessionStarted() const { | 57 bool SessionManager::IsSessionStarted() const { |
| 58 return session_started_; | 58 return session_started_; |
| 59 } | 59 } |
| 60 | 60 |
| 61 void SessionManager::SessionStarted() { | 61 void SessionManager::SessionStarted() { |
| 62 session_started_ = true; | 62 session_started_ = true; |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool SessionManager::HasSessionForAccountId( |
| 66 const AccountId& user_account_id) const { |
| 67 return std::find_if(sessions_.begin(), sessions_.end(), |
| 68 [user_account_id](const Session& session) { |
| 69 return session.user_account_id == user_account_id; |
| 70 }) != sessions_.end(); |
| 71 } |
| 72 |
| 65 bool SessionManager::IsInSecondaryLoginScreen() const { | 73 bool SessionManager::IsInSecondaryLoginScreen() const { |
| 66 return session_state_ == SessionState::LOGIN_SECONDARY; | 74 return session_state_ == SessionState::LOGIN_SECONDARY; |
| 67 } | 75 } |
| 68 | 76 |
| 69 bool SessionManager::IsScreenLocked() const { | 77 bool SessionManager::IsScreenLocked() const { |
| 70 return session_state_ == SessionState::LOCKED; | 78 return session_state_ == SessionState::LOCKED; |
| 71 } | 79 } |
| 72 | 80 |
| 73 bool SessionManager::IsUserSessionBlocked() const { | 81 bool SessionManager::IsUserSessionBlocked() const { |
| 74 return session_state_ != SessionState::ACTIVE; | 82 return session_state_ != SessionState::ACTIVE; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 92 } | 100 } |
| 93 | 101 |
| 94 // static | 102 // static |
| 95 void SessionManager::SetInstance(SessionManager* session_manager) { | 103 void SessionManager::SetInstance(SessionManager* session_manager) { |
| 96 SessionManager::instance = session_manager; | 104 SessionManager::instance = session_manager; |
| 97 } | 105 } |
| 98 | 106 |
| 99 void SessionManager::CreateSessionInternal(const AccountId& user_account_id, | 107 void SessionManager::CreateSessionInternal(const AccountId& user_account_id, |
| 100 const std::string& user_id_hash, | 108 const std::string& user_id_hash, |
| 101 bool browser_restart) { | 109 bool browser_restart) { |
| 102 DCHECK(std::find_if(sessions_.begin(), sessions_.end(), | 110 DCHECK(!HasSessionForAccountId(user_account_id)); |
| 103 [user_account_id](const Session& session) { | |
| 104 return session.user_account_id == user_account_id; | |
| 105 }) == sessions_.end()); | |
| 106 | |
| 107 sessions_.push_back({next_id_++, user_account_id}); | 111 sessions_.push_back({next_id_++, user_account_id}); |
| 108 NotifyUserLoggedIn(user_account_id, user_id_hash, browser_restart); | 112 NotifyUserLoggedIn(user_account_id, user_id_hash, browser_restart); |
| 109 } | 113 } |
| 110 | 114 |
| 111 } // namespace session_manager | 115 } // namespace session_manager |
| OLD | NEW |