| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/session_manager/session_manager_export.h" | 11 #include "components/session_manager/session_manager_export.h" |
| 12 #include "components/session_manager/session_manager_types.h" | 12 #include "components/session_manager/session_manager_types.h" |
| 13 | 13 |
| 14 namespace session_manager { | 14 namespace session_manager { |
| 15 | 15 |
| 16 class SessionManagerDelegate; | 16 class SessionManagerDelegate; |
| 17 | 17 |
| 18 class SESSION_EXPORT SessionManager { | 18 class SESSION_EXPORT SessionManager { |
| 19 public: | 19 public: |
| 20 SessionManager(); | 20 SessionManager(); |
| 21 virtual ~SessionManager(); | 21 virtual ~SessionManager(); |
| 22 | 22 |
| 23 // Returns current SessionManager instance and NULL if it hasn't been | 23 // Returns current SessionManager instance and NULL if it hasn't been |
| 24 // initialized yet. | 24 // initialized yet. |
| 25 static SessionManager* Get(); | 25 static SessionManager* Get(); |
| 26 | 26 |
| 27 SessionState session_state() const { return session_state_; } | 27 SessionState session_state() const { return session_state_; } |
| 28 virtual void SetSessionState(SessionState state); | 28 virtual void SetSessionState(SessionState state); |
| 29 | 29 |
| 30 // Returns true if we're logged in and browser has been started i.e. |
| 31 // browser_creator.LaunchBrowser(...) was called after sign in |
| 32 // or restart after crash. |
| 33 virtual bool IsSessionStarted() const; |
| 34 |
| 35 // Called when browser session is started i.e. after |
| 36 // browser_creator.LaunchBrowser(...) was called after user sign in. |
| 37 // When user is at the image screen IsUserLoggedIn() will return true |
| 38 // but IsSessionStarted() will return false. During the kiosk splash screen, |
| 39 // we perform additional initialization after the user is logged in but |
| 40 // before the session has been started. |
| 41 virtual void SessionStarted(); |
| 42 |
| 30 // Let session delegate executed on its plan of actions depending on the | 43 // Let session delegate executed on its plan of actions depending on the |
| 31 // current session type / state. | 44 // current session type / state. |
| 32 void Start(); | 45 void Start(); |
| 33 | 46 |
| 34 protected: | 47 protected: |
| 35 // Initializes SessionManager with delegate. | 48 // Initializes SessionManager with delegate. |
| 36 void Initialize(SessionManagerDelegate* delegate); | 49 void Initialize(SessionManagerDelegate* delegate); |
| 37 | 50 |
| 38 // Sets SessionManager instance. | 51 // Sets SessionManager instance. |
| 39 static void SetInstance(SessionManager* session_manager); | 52 static void SetInstance(SessionManager* session_manager); |
| 40 | 53 |
| 41 private: | 54 private: |
| 42 // Pointer to the existing SessionManager instance (if any). | 55 // Pointer to the existing SessionManager instance (if any). |
| 43 // Set in ctor, reset in dtor. Not owned since specific implementation of | 56 // Set in ctor, reset in dtor. Not owned since specific implementation of |
| 44 // SessionManager should decide on its own appropriate owner of SessionManager | 57 // SessionManager should decide on its own appropriate owner of SessionManager |
| 45 // instance. For src/chrome implementation such place is | 58 // instance. For src/chrome implementation such place is |
| 46 // g_browser_process->platform_part(). | 59 // g_browser_process->platform_part(). |
| 47 static SessionManager* instance; | 60 static SessionManager* instance; |
| 48 | 61 |
| 49 SessionState session_state_; | 62 SessionState session_state_ = SessionState::UNKNOWN; |
| 50 std::unique_ptr<SessionManagerDelegate> delegate_; | 63 std::unique_ptr<SessionManagerDelegate> delegate_; |
| 51 | 64 |
| 65 // True if SessionStarted() has been called. |
| 66 bool session_started_ = false; |
| 67 |
| 52 DISALLOW_COPY_AND_ASSIGN(SessionManager); | 68 DISALLOW_COPY_AND_ASSIGN(SessionManager); |
| 53 }; | 69 }; |
| 54 | 70 |
| 55 class SESSION_EXPORT SessionManagerDelegate { | 71 class SESSION_EXPORT SessionManagerDelegate { |
| 56 public: | 72 public: |
| 57 SessionManagerDelegate(); | 73 SessionManagerDelegate(); |
| 58 virtual ~SessionManagerDelegate(); | 74 virtual ~SessionManagerDelegate(); |
| 59 | 75 |
| 60 virtual void SetSessionManager( | 76 virtual void SetSessionManager( |
| 61 session_manager::SessionManager* session_manager); | 77 session_manager::SessionManager* session_manager); |
| 62 | 78 |
| 63 // Executes specific actions defined by this delegate. | 79 // Executes specific actions defined by this delegate. |
| 64 virtual void Start() = 0; | 80 virtual void Start() = 0; |
| 65 | 81 |
| 66 protected: | 82 protected: |
| 67 session_manager::SessionManager* session_manager_; | 83 session_manager::SessionManager* session_manager_ = nullptr; |
| 68 | 84 |
| 69 private: | 85 private: |
| 70 DISALLOW_COPY_AND_ASSIGN(SessionManagerDelegate); | 86 DISALLOW_COPY_AND_ASSIGN(SessionManagerDelegate); |
| 71 }; | 87 }; |
| 72 | 88 |
| 73 } // namespace session_manager | 89 } // namespace session_manager |
| 74 | 90 |
| 75 #endif // COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ | 91 #endif // COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ |
| OLD | NEW |