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 // Pointer to the existing SessionManager instance (if any). |
| 72 // Set in ctor, reset in dtor. Not owned since specific implementation of |
| 73 // SessionManager should decide on its own appropriate owner of SessionManager |
| 74 // instance. For src/chrome implementation such place is |
| 75 // g_browser_process->platform_part(). |
| 76 static SessionManager* instance; |
| 77 |
60 SessionState session_state_; | 78 SessionState session_state_; |
61 scoped_ptr<SessionManagerDelegate> delegate_; | 79 scoped_ptr<SessionManagerDelegate> delegate_; |
62 | 80 |
63 DISALLOW_COPY_AND_ASSIGN(SessionManager); | 81 DISALLOW_COPY_AND_ASSIGN(SessionManager); |
64 }; | 82 }; |
65 | 83 |
66 class SESSION_EXPORT SessionManagerDelegate { | 84 class SESSION_EXPORT SessionManagerDelegate { |
67 public: | 85 public: |
68 SessionManagerDelegate(); | 86 SessionManagerDelegate(); |
69 virtual ~SessionManagerDelegate(); | 87 virtual ~SessionManagerDelegate(); |
70 | 88 |
71 virtual void SetSessionManager( | 89 virtual void SetSessionManager( |
72 session_manager::SessionManager* session_manager); | 90 session_manager::SessionManager* session_manager); |
73 | 91 |
74 // Executes specific actions defined by this delegate. | 92 // Executes specific actions defined by this delegate. |
75 virtual void Start() = 0; | 93 virtual void Start() = 0; |
76 | 94 |
77 protected: | 95 protected: |
78 session_manager::SessionManager* session_manager_; | 96 session_manager::SessionManager* session_manager_; |
79 | 97 |
80 private: | 98 private: |
81 DISALLOW_COPY_AND_ASSIGN(SessionManagerDelegate); | 99 DISALLOW_COPY_AND_ASSIGN(SessionManagerDelegate); |
82 }; | 100 }; |
83 | 101 |
84 } // namespace session_manager | 102 } // namespace session_manager |
85 | 103 |
86 #endif // COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ | 104 #endif // COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ |
OLD | NEW |