Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: components/session_manager/core/session_manager.h

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

Powered by Google App Engine
This is Rietveld 408576698