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 CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 } // namespace user_manager | 35 } // namespace user_manager |
36 | 36 |
37 namespace chromeos { | 37 namespace chromeos { |
38 | 38 |
39 class EasyUnlockKeyManager; | 39 class EasyUnlockKeyManager; |
40 | 40 |
41 class UserSessionManagerDelegate { | 41 class UserSessionManagerDelegate { |
42 public: | 42 public: |
43 // Called after profile is loaded and prepared for the session. | 43 // Called after profile is loaded and prepared for the session. |
44 virtual void OnProfilePrepared(Profile* profile) = 0; | 44 // |browser_launched| is true if browser has been actually launched. |
| 45 virtual void OnProfilePrepared(Profile* profile, |
| 46 bool browser_launched) = 0; |
45 | 47 |
46 #if defined(ENABLE_RLZ) | 48 #if defined(ENABLE_RLZ) |
47 // Called after post-profile RLZ initialization. | 49 // Called after post-profile RLZ initialization. |
48 virtual void OnRlzInitialized(); | 50 virtual void OnRlzInitialized(); |
49 #endif | 51 #endif |
50 protected: | 52 protected: |
51 virtual ~UserSessionManagerDelegate(); | 53 virtual ~UserSessionManagerDelegate(); |
52 }; | 54 }; |
53 | 55 |
54 class UserSessionStateObserver { | 56 class UserSessionStateObserver { |
55 public: | 57 public: |
56 // Called when UserManager finishes restoring user sessions after crash. | 58 // Called when UserManager finishes restoring user sessions after crash. |
57 virtual void PendingUserSessionsRestoreFinished(); | 59 virtual void PendingUserSessionsRestoreFinished(); |
58 | 60 |
59 protected: | 61 protected: |
60 virtual ~UserSessionStateObserver(); | 62 virtual ~UserSessionStateObserver(); |
61 }; | 63 }; |
62 | 64 |
63 // UserSessionManager is responsible for starting user session which includes: | 65 // UserSessionManager is responsible for starting user session which includes: |
64 // load and initialize Profile (including custom Profile preferences), | 66 // * load and initialize Profile (including custom Profile preferences), |
65 // mark user as logged in and notify observers, | 67 // * mark user as logged in and notify observers, |
66 // initialize OAuth2 authentication session, | 68 // * initialize OAuth2 authentication session, |
67 // initialize and launch user session based on the user type. | 69 // * initialize and launch user session based on the user type. |
68 // Also supports restoring active user sessions after browser crash: | 70 // Also supports restoring active user sessions after browser crash: |
69 // load profile, restore OAuth authentication session etc. | 71 // load profile, restore OAuth authentication session etc. |
70 class UserSessionManager | 72 class UserSessionManager |
71 : public OAuth2LoginManager::Observer, | 73 : public OAuth2LoginManager::Observer, |
72 public net::NetworkChangeNotifier::ConnectionTypeObserver, | 74 public net::NetworkChangeNotifier::ConnectionTypeObserver, |
73 public base::SupportsWeakPtr<UserSessionManager>, | 75 public base::SupportsWeakPtr<UserSessionManager>, |
74 public UserSessionManagerDelegate, | 76 public UserSessionManagerDelegate, |
75 public user_manager::UserManager::UserSessionStateObserver { | 77 public user_manager::UserManager::UserSessionStateObserver { |
76 public: | 78 public: |
| 79 // Context of StartSession calls. |
| 80 typedef enum { |
| 81 // Starting primary user session, through login UI. |
| 82 PRIMARY_USER_SESSION, |
| 83 |
| 84 // Starting secondary user session, through multi-profiles login UI. |
| 85 SECONDARY_USER_SESSION, |
| 86 |
| 87 // Starting primary user session after browser crash. |
| 88 PRIMARY_USER_SESSION_AFTER_CRASH, |
| 89 |
| 90 // Starting secondary user session after browser crash. |
| 91 SECONDARY_USER_SESSION_AFTER_CRASH, |
| 92 } StartSessionType; |
| 93 |
77 // Returns UserSessionManager instance. | 94 // Returns UserSessionManager instance. |
78 static UserSessionManager* GetInstance(); | 95 static UserSessionManager* GetInstance(); |
79 | 96 |
80 // Called when user is logged in to override base::DIR_HOME path. | 97 // Called when user is logged in to override base::DIR_HOME path. |
81 static void OverrideHomedir(); | 98 static void OverrideHomedir(); |
82 | 99 |
83 // Registers session related preferences. | 100 // Registers session related preferences. |
84 static void RegisterPrefs(PrefRegistrySimple* registry); | 101 static void RegisterPrefs(PrefRegistrySimple* registry); |
85 | 102 |
86 // Invoked after the tmpfs is successfully mounted. | 103 // Invoked after the tmpfs is successfully mounted. |
87 // Asks session_manager to restart Chrome in Guest session mode. | 104 // Asks session_manager to restart Chrome in Guest session mode. |
88 // |start_url| is an optional URL to be opened in Guest session browser. | 105 // |start_url| is an optional URL to be opened in Guest session browser. |
89 void CompleteGuestSessionLogin(const GURL& start_url); | 106 void CompleteGuestSessionLogin(const GURL& start_url); |
90 | 107 |
91 // Start user session given |user_context| and |authenticator| which holds | 108 // Start user session given |user_context| and |authenticator| which holds |
92 // authentication context (profile). | 109 // authentication context (profile). |
93 void StartSession(const UserContext& user_context, | 110 void StartSession(const UserContext& user_context, |
| 111 StartSessionType start_session_type, |
94 scoped_refptr<Authenticator> authenticator, | 112 scoped_refptr<Authenticator> authenticator, |
95 bool has_auth_cookies, | 113 bool has_auth_cookies, |
96 bool has_active_session, | 114 bool has_active_session, |
97 UserSessionManagerDelegate* delegate); | 115 UserSessionManagerDelegate* delegate); |
98 | 116 |
99 // Perform additional actions once system wide notification | 117 // Perform additional actions once system wide notification |
100 // "UserLoggedIn" has been sent. | 118 // "UserLoggedIn" has been sent. |
101 void PerformPostUserLoggedInActions(); | 119 void PerformPostUserLoggedInActions(); |
102 | 120 |
103 // Restores authentication session after crash. | 121 // Restores authentication session after crash. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 Profile* user_profile, | 209 Profile* user_profile, |
192 OAuth2LoginManager::SessionRestoreState state) override; | 210 OAuth2LoginManager::SessionRestoreState state) override; |
193 virtual void OnNewRefreshTokenAvaiable(Profile* user_profile) override; | 211 virtual void OnNewRefreshTokenAvaiable(Profile* user_profile) override; |
194 | 212 |
195 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides: | 213 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides: |
196 virtual void OnConnectionTypeChanged( | 214 virtual void OnConnectionTypeChanged( |
197 net::NetworkChangeNotifier::ConnectionType type) override; | 215 net::NetworkChangeNotifier::ConnectionType type) override; |
198 | 216 |
199 // UserSessionManagerDelegate overrides: | 217 // UserSessionManagerDelegate overrides: |
200 // Used when restoring user sessions after crash. | 218 // Used when restoring user sessions after crash. |
201 virtual void OnProfilePrepared(Profile* profile) override; | 219 virtual void OnProfilePrepared(Profile* profile, |
| 220 bool browser_launched) override; |
202 | 221 |
203 void CreateUserSession(const UserContext& user_context, | 222 void CreateUserSession(const UserContext& user_context, |
204 bool has_auth_cookies); | 223 bool has_auth_cookies); |
205 void PreStartSession(); | 224 void PreStartSession(); |
206 void StartCrosSession(); | 225 void StartCrosSession(); |
207 void NotifyUserLoggedIn(); | 226 void NotifyUserLoggedIn(); |
208 void PrepareProfile(); | 227 void PrepareProfile(); |
209 | 228 |
210 // Callback for asynchronous profile creation. | 229 // Callback for asynchronous profile creation. |
211 void OnProfileCreated(const UserContext& user_context, | 230 void OnProfileCreated(const UserContext& user_context, |
(...skipping 14 matching lines...) Expand all Loading... |
226 bool is_incognito_profile, | 245 bool is_incognito_profile, |
227 const std::string& user_id); | 246 const std::string& user_id); |
228 | 247 |
229 // Callback to resume profile creation after transferring auth data from | 248 // Callback to resume profile creation after transferring auth data from |
230 // the authentication profile. | 249 // the authentication profile. |
231 void CompleteProfileCreateAfterAuthTransfer(Profile* profile); | 250 void CompleteProfileCreateAfterAuthTransfer(Profile* profile); |
232 | 251 |
233 // Finalized profile preparation. | 252 // Finalized profile preparation. |
234 void FinalizePrepareProfile(Profile* profile); | 253 void FinalizePrepareProfile(Profile* profile); |
235 | 254 |
| 255 // Starts out-of-box flow with the specified screen. |
| 256 void ActivateWizard(const std::string& screen_name); |
| 257 |
| 258 // Adds first-time login URLs. |
| 259 void InitializeStartUrls() const; |
| 260 |
| 261 // Perform session initialization and either move to additional login flows |
| 262 // such as TOS (public sessions), priority pref sync UI (new users) or |
| 263 // launch browser. |
| 264 // Returns true if browser has been launched or false otherwise. |
| 265 bool InitializeUserSession(Profile* profile); |
| 266 |
236 // Initializes member variables needed for session restore process via | 267 // Initializes member variables needed for session restore process via |
237 // OAuthLoginManager. | 268 // OAuthLoginManager. |
238 void InitSessionRestoreStrategy(); | 269 void InitSessionRestoreStrategy(); |
239 | 270 |
240 // Restores GAIA auth cookies for the created user profile from OAuth2 token. | 271 // Restores GAIA auth cookies for the created user profile from OAuth2 token. |
241 void RestoreAuthSessionImpl(Profile* profile, | 272 void RestoreAuthSessionImpl(Profile* profile, |
242 bool restore_from_auth_cookies); | 273 bool restore_from_auth_cookies); |
243 | 274 |
244 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. | 275 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. |
245 void InitRlzImpl(Profile* profile, bool disabled); | 276 void InitRlzImpl(Profile* profile, bool disabled); |
(...skipping 17 matching lines...) Expand all Loading... |
263 | 294 |
264 // Callback invoked when Easy unlock key operations are finished. | 295 // Callback invoked when Easy unlock key operations are finished. |
265 void OnEasyUnlockKeyOpsFinished(const std::string& user_id, | 296 void OnEasyUnlockKeyOpsFinished(const std::string& user_id, |
266 bool success); | 297 bool success); |
267 | 298 |
268 UserSessionManagerDelegate* delegate_; | 299 UserSessionManagerDelegate* delegate_; |
269 | 300 |
270 // Authentication/user context. | 301 // Authentication/user context. |
271 UserContext user_context_; | 302 UserContext user_context_; |
272 scoped_refptr<Authenticator> authenticator_; | 303 scoped_refptr<Authenticator> authenticator_; |
| 304 StartSessionType start_session_type_; |
273 | 305 |
274 // True if the authentication context's cookie jar contains authentication | 306 // True if the authentication context's cookie jar contains authentication |
275 // cookies from the authentication extension login flow. | 307 // cookies from the authentication extension login flow. |
276 bool has_auth_cookies_; | 308 bool has_auth_cookies_; |
277 | 309 |
278 // Active user session restoration related members. | 310 // Active user session restoration related members. |
279 | 311 |
280 // True if user sessions has been restored after crash. | 312 // True if user sessions has been restored after crash. |
281 // On a normal boot then login into user sessions this will be false. | 313 // On a normal boot then login into user sessions this will be false. |
282 bool user_sessions_restored_; | 314 bool user_sessions_restored_; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 scoped_ptr<EasyUnlockKeyManager> easy_unlock_key_manager_; | 350 scoped_ptr<EasyUnlockKeyManager> easy_unlock_key_manager_; |
319 bool running_easy_unlock_key_ops_; | 351 bool running_easy_unlock_key_ops_; |
320 base::Closure easy_unlock_key_ops_finished_callback_; | 352 base::Closure easy_unlock_key_ops_finished_callback_; |
321 | 353 |
322 DISALLOW_COPY_AND_ASSIGN(UserSessionManager); | 354 DISALLOW_COPY_AND_ASSIGN(UserSessionManager); |
323 }; | 355 }; |
324 | 356 |
325 } // namespace chromeos | 357 } // namespace chromeos |
326 | 358 |
327 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_ | 359 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_ |
OLD | NEW |