Chromium Code Reviews| 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 #ifndef COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ | 5 #ifndef COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ |
| 6 #define COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ | 6 #define COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <vector> | |
| 9 | |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "components/session_manager/session_manager_export.h" | 11 #include "components/session_manager/session_manager_export.h" |
| 10 #include "components/session_manager/session_manager_types.h" | 12 #include "components/session_manager/session_manager_types.h" |
| 11 | 13 |
| 14 class AccountId; | |
| 15 | |
| 12 namespace session_manager { | 16 namespace session_manager { |
| 13 | 17 |
| 14 class SESSION_EXPORT SessionManager { | 18 class SESSION_EXPORT SessionManager { |
| 15 public: | 19 public: |
| 16 SessionManager(); | 20 SessionManager(); |
| 17 virtual ~SessionManager(); | 21 virtual ~SessionManager(); |
| 18 | 22 |
| 19 // Returns current SessionManager instance and NULL if it hasn't been | 23 // Returns current SessionManager instance and NULL if it hasn't been |
| 20 // initialized yet. | 24 // initialized yet. |
| 21 static SessionManager* Get(); | 25 static SessionManager* Get(); |
| 22 | 26 |
| 23 SessionState session_state() const { return session_state_; } | 27 void SetSessionState(SessionState state); |
| 24 virtual void SetSessionState(SessionState state); | 28 |
| 29 // Creates a session for the given user. The first one is for regular case | |
| 30 // and the 2nd one is for crash-and-restart case. | |
| 31 void CreateSession(const AccountId& user_account_id, | |
|
achuithb
2016/10/31 22:41:36
I feel like I'm being nitpicky, and am fine with t
xiyuan
2016/11/01 16:24:31
All sites except one are passing a false for the f
| |
| 32 const std::string& user_id_hash); | |
| 33 void CreateSession(const AccountId& user_account_id, | |
| 34 const std::string& user_id_hash, | |
| 35 bool browser_restart); | |
| 25 | 36 |
| 26 // Returns true if we're logged in and browser has been started i.e. | 37 // Returns true if we're logged in and browser has been started i.e. |
| 27 // browser_creator.LaunchBrowser(...) was called after sign in | 38 // browser_creator.LaunchBrowser(...) was called after sign in |
| 28 // or restart after crash. | 39 // or restart after crash. |
| 29 virtual bool IsSessionStarted() const; | 40 virtual bool IsSessionStarted() const; |
| 30 | 41 |
| 31 // Called when browser session is started i.e. after | 42 // Called when browser session is started i.e. after |
| 32 // browser_creator.LaunchBrowser(...) was called after user sign in. | 43 // browser_creator.LaunchBrowser(...) was called after user sign in. |
| 33 // When user is at the image screen IsUserLoggedIn() will return true | 44 // When user is at the image screen IsUserLoggedIn() will return true |
| 34 // but IsSessionStarted() will return false. During the kiosk splash screen, | 45 // but IsSessionStarted() will return false. During the kiosk splash screen, |
| 35 // we perform additional initialization after the user is logged in but | 46 // we perform additional initialization after the user is logged in but |
| 36 // before the session has been started. | 47 // before the session has been started. |
| 37 virtual void SessionStarted(); | 48 virtual void SessionStarted(); |
| 38 | 49 |
| 50 SessionState session_state() const { return session_state_; } | |
| 51 const std::vector<Session>& sessions() const { return sessions_; } | |
| 52 | |
| 39 protected: | 53 protected: |
| 54 // Notifies UserManager about a user signs in when creating a user session. | |
| 55 virtual void NotifyUserLoggedIn(const AccountId& user_account_id, | |
| 56 const std::string& user_id_hash, | |
| 57 bool browser_restart); | |
| 58 | |
| 40 // Sets SessionManager instance. | 59 // Sets SessionManager instance. |
| 41 static void SetInstance(SessionManager* session_manager); | 60 static void SetInstance(SessionManager* session_manager); |
| 42 | 61 |
| 43 private: | 62 private: |
| 44 // Pointer to the existing SessionManager instance (if any). | 63 // Pointer to the existing SessionManager instance (if any). |
| 45 // Set in ctor, reset in dtor. Not owned since specific implementation of | 64 // Set in ctor, reset in dtor. Not owned since specific implementation of |
| 46 // SessionManager should decide on its own appropriate owner of SessionManager | 65 // SessionManager should decide on its own appropriate owner of SessionManager |
| 47 // instance. For src/chrome implementation such place is | 66 // instance. For src/chrome implementation such place is |
| 48 // g_browser_process->platform_part(). | 67 // g_browser_process->platform_part(). |
| 49 static SessionManager* instance; | 68 static SessionManager* instance; |
| 50 | 69 |
| 51 SessionState session_state_ = SessionState::UNKNOWN; | 70 SessionState session_state_ = SessionState::UNKNOWN; |
| 52 | 71 |
| 53 // True if SessionStarted() has been called. | 72 // True if SessionStarted() has been called. |
| 54 bool session_started_ = false; | 73 bool session_started_ = false; |
| 55 | 74 |
| 75 // Id of the primary session, i.e. the first user session. | |
| 76 static const SessionId kPrimarySessionId = 1; | |
| 77 | |
| 78 // ID assigned to the next session. | |
| 79 SessionId next_id_ = kPrimarySessionId; | |
| 80 | |
| 81 // Keeps track of user sessions. | |
| 82 std::vector<Session> sessions_; | |
| 83 | |
| 56 DISALLOW_COPY_AND_ASSIGN(SessionManager); | 84 DISALLOW_COPY_AND_ASSIGN(SessionManager); |
| 57 }; | 85 }; |
| 58 | 86 |
| 59 } // namespace session_manager | 87 } // namespace session_manager |
| 60 | 88 |
| 61 #endif // COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ | 89 #endif // COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ |
| OLD | NEW |