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

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

Issue 2510983002: session_manager: Add SessionManagerObserver interface (Closed)
Patch Set: add default ctor 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 <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/observer_list.h"
11 #include "components/session_manager/session_manager_export.h" 12 #include "components/session_manager/session_manager_export.h"
12 #include "components/session_manager/session_manager_types.h" 13 #include "components/session_manager/session_manager_types.h"
13 14
14 class AccountId; 15 class AccountId;
15 16
16 namespace session_manager { 17 namespace session_manager {
17 18
19 class SessionManagerObserver;
20
18 class SESSION_EXPORT SessionManager { 21 class SESSION_EXPORT SessionManager {
19 public: 22 public:
20 SessionManager(); 23 SessionManager();
21 virtual ~SessionManager(); 24 virtual ~SessionManager();
22 25
23 // Returns current SessionManager instance and NULL if it hasn't been 26 // Returns current SessionManager instance and NULL if it hasn't been
24 // initialized yet. 27 // initialized yet.
25 static SessionManager* Get(); 28 static SessionManager* Get();
26 29
27 void SetSessionState(SessionState state); 30 void SetSessionState(SessionState state);
(...skipping 11 matching lines...) Expand all
39 virtual bool IsSessionStarted() const; 42 virtual bool IsSessionStarted() const;
40 43
41 // Called when browser session is started i.e. after 44 // Called when browser session is started i.e. after
42 // browser_creator.LaunchBrowser(...) was called after user sign in. 45 // browser_creator.LaunchBrowser(...) was called after user sign in.
43 // When user is at the image screen IsUserLoggedIn() will return true 46 // When user is at the image screen IsUserLoggedIn() will return true
44 // but IsSessionStarted() will return false. During the kiosk splash screen, 47 // but IsSessionStarted() will return false. During the kiosk splash screen,
45 // we perform additional initialization after the user is logged in but 48 // we perform additional initialization after the user is logged in but
46 // before the session has been started. 49 // before the session has been started.
47 virtual void SessionStarted(); 50 virtual void SessionStarted();
48 51
52 void AddObserver(SessionManagerObserver* observer);
53 void RemoveObserver(SessionManagerObserver* observer);
54
49 SessionState session_state() const { return session_state_; } 55 SessionState session_state() const { return session_state_; }
50 const std::vector<Session>& sessions() const { return sessions_; } 56 const std::vector<Session>& sessions() const { return sessions_; }
51 57
52 protected: 58 protected:
53 // Notifies UserManager about a user signs in when creating a user session. 59 // Notifies UserManager about a user signs in when creating a user session.
54 virtual void NotifyUserLoggedIn(const AccountId& user_account_id, 60 virtual void NotifyUserLoggedIn(const AccountId& user_account_id,
55 const std::string& user_id_hash, 61 const std::string& user_id_hash,
56 bool browser_restart); 62 bool browser_restart);
57 63
58 // Sets SessionManager instance. 64 // Sets SessionManager instance.
(...skipping 18 matching lines...) Expand all
77 83
78 // Id of the primary session, i.e. the first user session. 84 // Id of the primary session, i.e. the first user session.
79 static const SessionId kPrimarySessionId = 1; 85 static const SessionId kPrimarySessionId = 1;
80 86
81 // ID assigned to the next session. 87 // ID assigned to the next session.
82 SessionId next_id_ = kPrimarySessionId; 88 SessionId next_id_ = kPrimarySessionId;
83 89
84 // Keeps track of user sessions. 90 // Keeps track of user sessions.
85 std::vector<Session> sessions_; 91 std::vector<Session> sessions_;
86 92
93 base::ObserverList<SessionManagerObserver> observers_;
94
87 DISALLOW_COPY_AND_ASSIGN(SessionManager); 95 DISALLOW_COPY_AND_ASSIGN(SessionManager);
88 }; 96 };
89 97
90 } // namespace session_manager 98 } // namespace session_manager
91 99
92 #endif // COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_ 100 #endif // COMPONENTS_SESSION_MANAGER_CORE_SESSION_MANAGER_H_
OLDNEW
« no previous file with comments | « components/session_manager/core/BUILD.gn ('k') | components/session_manager/core/session_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698