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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "components/session_manager/session_manager_export.h" | 9 #include "components/session_manager/session_manager_export.h" |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 // Same as SESSION_STATE_LOGIN_PRIMARY but for multi-profiles sign in i.e. | 38 // Same as SESSION_STATE_LOGIN_PRIMARY but for multi-profiles sign in i.e. |
| 39 // when there's at least one user already active in the session. | 39 // when there's at least one user already active in the session. |
| 40 SESSION_STATE_LOGIN_SECONDARY, | 40 SESSION_STATE_LOGIN_SECONDARY, |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 class SESSION_EXPORT SessionManager { | 43 class SESSION_EXPORT SessionManager { |
| 44 public: | 44 public: |
| 45 SessionManager(); | 45 SessionManager(); |
| 46 virtual ~SessionManager(); | 46 virtual ~SessionManager(); |
| 47 | 47 |
| 48 // Returns current SessionManager instance and NULL if it hasn't been | |
| 49 // initialized yet. | |
| 50 static SessionManager* Get(); | |
| 51 | |
| 48 SessionState session_state() const { return session_state_; } | 52 SessionState session_state() const { return session_state_; } |
| 49 virtual void SetSessionState(SessionState state); | 53 virtual void SetSessionState(SessionState state); |
| 50 | 54 |
| 51 // Let session delegate executed on its plan of actions depending on the | 55 // Let session delegate executed on its plan of actions depending on the |
| 52 // current session type / state. | 56 // current session type / state. |
| 53 void Start(); | 57 void Start(); |
| 54 | 58 |
| 59 // Returns true when the browser has crashed and restarted during the current | |
| 60 // user's session. | |
| 61 static bool HasBrowserRestarted(); | |
| 62 | |
| 55 protected: | 63 protected: |
| 56 // Initializes SessionManager with delegate. | 64 // Initializes SessionManager with delegate. |
| 57 void Initialize(SessionManagerDelegate* delegate); | 65 void Initialize(SessionManagerDelegate* delegate); |
| 58 | 66 |
| 67 // Sets SessionManager instance. | |
| 68 static void SetInstance(SessionManager* session_manager); | |
| 69 | |
| 59 private: | 70 private: |
| 71 static SessionManager* instance; | |
|
Dmitry Polukhin
2014/07/28 09:32:39
Please comment about lifetime and ownership.
Nikita (slow)
2014/07/29 09:27:28
Done.
| |
| 72 | |
| 60 SessionState session_state_; | 73 SessionState session_state_; |
| 61 scoped_ptr<SessionManagerDelegate> delegate_; | 74 scoped_ptr<SessionManagerDelegate> delegate_; |
| 62 | 75 |
| 63 DISALLOW_COPY_AND_ASSIGN(SessionManager); | 76 DISALLOW_COPY_AND_ASSIGN(SessionManager); |
| 64 }; | 77 }; |
| 65 | 78 |
| 66 class SESSION_EXPORT SessionManagerDelegate { | 79 class SESSION_EXPORT SessionManagerDelegate { |
| 67 public: | 80 public: |
| 68 SessionManagerDelegate(); | 81 SessionManagerDelegate(); |
| 69 virtual ~SessionManagerDelegate(); | 82 virtual ~SessionManagerDelegate(); |
| 70 | 83 |
| 71 virtual void SetSessionManager( | 84 virtual void SetSessionManager( |
| 72 session_manager::SessionManager* session_manager); | 85 session_manager::SessionManager* session_manager); |
| 73 | 86 |
| 74 // Executes specific actions defined by this delegate. | 87 // Executes specific actions defined by this delegate. |
| 75 virtual void Start() = 0; | 88 virtual void Start() = 0; |
| 76 | 89 |
| 77 protected: | 90 protected: |
| 78 session_manager::SessionManager* session_manager_; | 91 session_manager::SessionManager* session_manager_; |
| 79 | 92 |
| 80 private: | 93 private: |
| 81 DISALLOW_COPY_AND_ASSIGN(SessionManagerDelegate); | 94 DISALLOW_COPY_AND_ASSIGN(SessionManagerDelegate); |
| 82 }; | 95 }; |
| 83 | 96 |
| 84 } // namespace session_manager | 97 } // namespace session_manager |
| 85 | 98 |
| 86 #endif // COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ | 99 #endif // COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ |
| OLD | NEW |