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

Side by Side Diff: chrome/browser/chromeos/login/session/user_session_manager.h

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

Powered by Google App Engine
This is Rietveld 408576698