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

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

Issue 745613002: [cros] Cleanup: remove LoginUtils (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get rid of FakeChromeUserManager usage in ExistingUserController* tests Created 5 years, 10 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 11 matching lines...) Expand all
22 #include "components/user_manager/user_manager.h" 22 #include "components/user_manager/user_manager.h"
23 #include "net/base/network_change_notifier.h" 23 #include "net/base/network_change_notifier.h"
24 #include "ui/base/ime/chromeos/input_method_manager.h" 24 #include "ui/base/ime/chromeos/input_method_manager.h"
25 25
26 class GURL; 26 class GURL;
27 class PrefRegistrySimple; 27 class PrefRegistrySimple;
28 class PrefService; 28 class PrefService;
29 class Profile; 29 class Profile;
30 30
31 namespace user_manager { 31 namespace user_manager {
32
33 class User; 32 class User;
34
35 } // namespace user_manager 33 } // namespace user_manager
36 34
37 namespace chromeos { 35 namespace chromeos {
38 36
37 namespace test {
38 class UserSessionManagerTestApi;
39 } // namespace test
40
39 class EasyUnlockKeyManager; 41 class EasyUnlockKeyManager;
40 class InputEventsBlocker; 42 class InputEventsBlocker;
41 class LoginDisplayHost; 43 class LoginDisplayHost;
42 44
43 class UserSessionManagerDelegate { 45 class UserSessionManagerDelegate {
44 public: 46 public:
45 // Called after profile is loaded and prepared for the session. 47 // Called after profile is loaded and prepared for the session.
46 // |browser_launched| will be true is browser has been launched, otherwise 48 // |browser_launched| will be true is browser has been launched, otherwise
47 // it will return false and client is responsible on launching browser. 49 // it will return false and client is responsible on launching browser.
48 virtual void OnProfilePrepared(Profile* profile, 50 virtual void OnProfilePrepared(Profile* profile,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 static void OverrideHomedir(); 99 static void OverrideHomedir();
98 100
99 // Registers session related preferences. 101 // Registers session related preferences.
100 static void RegisterPrefs(PrefRegistrySimple* registry); 102 static void RegisterPrefs(PrefRegistrySimple* registry);
101 103
102 // Invoked after the tmpfs is successfully mounted. 104 // Invoked after the tmpfs is successfully mounted.
103 // Asks session_manager to restart Chrome in Guest session mode. 105 // Asks session_manager to restart Chrome in Guest session mode.
104 // |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.
105 void CompleteGuestSessionLogin(const GURL& start_url); 107 void CompleteGuestSessionLogin(const GURL& start_url);
106 108
107 // Start user session given |user_context| and |authenticator| which holds 109 // Creates and returns the authenticator to use.
108 // authentication context (profile). 110 // Single Authenticator instance is used for entire login process,
111 // even for multiple retries. Authenticator instance holds reference to
112 // login profile and is later used during fetching of OAuth tokens.
113 scoped_refptr<Authenticator> CreateAuthenticator(
114 AuthStatusConsumer* consumer);
115
116 // Start user session given |user_context|.
117 // OnProfilePrepared() will be called on |delegate| once Profile is ready.
109 void StartSession(const UserContext& user_context, 118 void StartSession(const UserContext& user_context,
110 StartSessionType start_session_type, 119 StartSessionType start_session_type,
111 scoped_refptr<Authenticator> authenticator,
112 bool has_auth_cookies, 120 bool has_auth_cookies,
113 bool has_active_session, 121 bool has_active_session,
114 UserSessionManagerDelegate* delegate); 122 UserSessionManagerDelegate* delegate);
115 123
124 // Invalidates |delegate|, which was passed to StartSession method call.
125 void DelegateDeleted(UserSessionManagerDelegate* delegate);
126
116 // Perform additional actions once system wide notification 127 // Perform additional actions once system wide notification
117 // "UserLoggedIn" has been sent. 128 // "UserLoggedIn" has been sent.
118 void PerformPostUserLoggedInActions(); 129 void PerformPostUserLoggedInActions();
119 130
120 // Restores authentication session after crash. 131 // Restores authentication session after crash.
121 void RestoreAuthenticationSession(Profile* profile); 132 void RestoreAuthenticationSession(Profile* profile);
122 133
123 // Usually is called when Chrome is restarted after a crash and there's an 134 // Usually is called when Chrome is restarted after a crash and there's an
124 // active session. First user (one that is passed with --login-user) Chrome 135 // active session. First user (one that is passed with --login-user) Chrome
125 // session has been already restored at this point. This method asks session 136 // session has been already restored at this point. This method asks session
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // Note this could return NULL if not enabled. 217 // Note this could return NULL if not enabled.
207 EasyUnlockKeyManager* GetEasyUnlockKeyManager(); 218 EasyUnlockKeyManager* GetEasyUnlockKeyManager();
208 219
209 // Update Easy unlock cryptohome keys for given user context. 220 // Update Easy unlock cryptohome keys for given user context.
210 void UpdateEasyUnlockKeys(const UserContext& user_context); 221 void UpdateEasyUnlockKeys(const UserContext& user_context);
211 222
212 // Removes a profile from the per-user input methods states map. 223 // Removes a profile from the per-user input methods states map.
213 void RemoveProfileForTesting(Profile* profile); 224 void RemoveProfileForTesting(Profile* profile);
214 225
215 private: 226 private:
227 friend class test::UserSessionManagerTestApi;
216 friend struct DefaultSingletonTraits<UserSessionManager>; 228 friend struct DefaultSingletonTraits<UserSessionManager>;
217 229
218 typedef std::set<std::string> SigninSessionRestoreStateSet; 230 typedef std::set<std::string> SigninSessionRestoreStateSet;
219 231
220 UserSessionManager(); 232 UserSessionManager();
221 ~UserSessionManager() override; 233 ~UserSessionManager() override;
222 234
223 // OAuth2LoginManager::Observer overrides: 235 // OAuth2LoginManager::Observer overrides:
224 void OnSessionRestoreStateChanged( 236 void OnSessionRestoreStateChanged(
225 Profile* user_profile, 237 Profile* user_profile,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 333
322 // Switch to the locale that |profile| wishes to use and invoke |callback|. 334 // Switch to the locale that |profile| wishes to use and invoke |callback|.
323 void RespectLocalePreferenceWrapper(Profile* profile, 335 void RespectLocalePreferenceWrapper(Profile* profile,
324 const base::Closure& callback); 336 const base::Closure& callback);
325 337
326 static void RunCallbackOnLocaleLoaded( 338 static void RunCallbackOnLocaleLoaded(
327 const base::Closure& callback, 339 const base::Closure& callback,
328 InputEventsBlocker* input_events_blocker, 340 InputEventsBlocker* input_events_blocker,
329 const locale_util::LanguageSwitchResult& result); 341 const locale_util::LanguageSwitchResult& result);
330 342
343 // Test API methods.
344
345 // Injects |user_context| that will be used to create StubAuthenticator
346 // instance when CreateAuthenticator() is called.
347 void InjectStubUserContext(const UserContext& user_context);
348
349 // Controls whether browser instance should be launched after sign in
350 // (used in tests).
351 void set_should_launch_browser_in_tests(bool should_launch_browser) {
352 should_launch_browser_ = should_launch_browser;
353 }
354
331 UserSessionManagerDelegate* delegate_; 355 UserSessionManagerDelegate* delegate_;
332 356
333 // Authentication/user context. 357 // Authentication/user context.
334 UserContext user_context_; 358 UserContext user_context_;
335 scoped_refptr<Authenticator> authenticator_; 359 scoped_refptr<Authenticator> authenticator_;
336 StartSessionType start_session_type_; 360 StartSessionType start_session_type_;
337 361
362 // Injected user context for stub authenticator.
363 scoped_ptr<UserContext> injected_user_context_;
364
338 // True if the authentication context's cookie jar contains authentication 365 // True if the authentication context's cookie jar contains authentication
339 // cookies from the authentication extension login flow. 366 // cookies from the authentication extension login flow.
340 bool has_auth_cookies_; 367 bool has_auth_cookies_;
341 368
342 // Active user session restoration related members. 369 // Active user session restoration related members.
343 370
344 // True if user sessions has been restored after crash. 371 // True if user sessions has been restored after crash.
345 // On a normal boot then login into user sessions this will be false. 372 // On a normal boot then login into user sessions this will be false.
346 bool user_sessions_restored_; 373 bool user_sessions_restored_;
347 374
(...skipping 28 matching lines...) Expand all
376 403
377 // Per-user-session Input Methods states. 404 // Per-user-session Input Methods states.
378 std::map<Profile*, scoped_refptr<input_method::InputMethodManager::State>, 405 std::map<Profile*, scoped_refptr<input_method::InputMethodManager::State>,
379 ProfileCompare> default_ime_states_; 406 ProfileCompare> default_ime_states_;
380 407
381 // Manages Easy unlock cryptohome keys. 408 // Manages Easy unlock cryptohome keys.
382 scoped_ptr<EasyUnlockKeyManager> easy_unlock_key_manager_; 409 scoped_ptr<EasyUnlockKeyManager> easy_unlock_key_manager_;
383 bool running_easy_unlock_key_ops_; 410 bool running_easy_unlock_key_ops_;
384 base::Closure easy_unlock_key_ops_finished_callback_; 411 base::Closure easy_unlock_key_ops_finished_callback_;
385 412
413 // Whether should launch browser, tests may override this value.
414 bool should_launch_browser_;
415
386 DISALLOW_COPY_AND_ASSIGN(UserSessionManager); 416 DISALLOW_COPY_AND_ASSIGN(UserSessionManager);
387 }; 417 };
388 418
389 } // namespace chromeos 419 } // namespace chromeos
390 420
391 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_ 421 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698