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" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "chrome/browser/chromeos/base/locale_util.h" | 16 #include "chrome/browser/chromeos/base/locale_util.h" |
17 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" | 17 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" |
| 18 #include "chrome/browser/chromeos/login/signin/token_handle_util.h" |
18 #include "chromeos/dbus/session_manager_client.h" | 19 #include "chromeos/dbus/session_manager_client.h" |
19 #include "chromeos/login/auth/authenticator.h" | 20 #include "chromeos/login/auth/authenticator.h" |
20 #include "chromeos/login/auth/user_context.h" | 21 #include "chromeos/login/auth/user_context.h" |
21 #include "components/user_manager/user.h" | 22 #include "components/user_manager/user.h" |
22 #include "components/user_manager/user_manager.h" | 23 #include "components/user_manager/user_manager.h" |
23 #include "net/base/network_change_notifier.h" | 24 #include "net/base/network_change_notifier.h" |
24 #include "ui/base/ime/chromeos/input_method_manager.h" | 25 #include "ui/base/ime/chromeos/input_method_manager.h" |
25 | 26 |
26 class GURL; | 27 class GURL; |
27 class PrefRegistrySimple; | 28 class PrefRegistrySimple; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 212 |
212 // Returns true if there are pending Easy unlock key operations and | 213 // Returns true if there are pending Easy unlock key operations and |
213 // |callback| will be invoked when it is done. | 214 // |callback| will be invoked when it is done. |
214 bool CheckEasyUnlockKeyOps(const base::Closure& callback); | 215 bool CheckEasyUnlockKeyOps(const base::Closure& callback); |
215 | 216 |
216 void AddSessionStateObserver(chromeos::UserSessionStateObserver* observer); | 217 void AddSessionStateObserver(chromeos::UserSessionStateObserver* observer); |
217 void RemoveSessionStateObserver(chromeos::UserSessionStateObserver* observer); | 218 void RemoveSessionStateObserver(chromeos::UserSessionStateObserver* observer); |
218 | 219 |
219 void ActiveUserChanged(const user_manager::User* active_user) override; | 220 void ActiveUserChanged(const user_manager::User* active_user) override; |
220 | 221 |
| 222 // This method will be called when user have obtained oauth2 tokens. |
| 223 void OnOAuth2TokensFetched(UserContext context); |
| 224 |
221 // Returns default IME state for user session. | 225 // Returns default IME state for user session. |
222 scoped_refptr<input_method::InputMethodManager::State> GetDefaultIMEState( | 226 scoped_refptr<input_method::InputMethodManager::State> GetDefaultIMEState( |
223 Profile* profile); | 227 Profile* profile); |
224 | 228 |
225 // Note this could return NULL if not enabled. | 229 // Note this could return NULL if not enabled. |
226 EasyUnlockKeyManager* GetEasyUnlockKeyManager(); | 230 EasyUnlockKeyManager* GetEasyUnlockKeyManager(); |
227 | 231 |
228 // Update Easy unlock cryptohome keys for given user context. | 232 // Update Easy unlock cryptohome keys for given user context. |
229 void UpdateEasyUnlockKeys(const UserContext& user_context); | 233 void UpdateEasyUnlockKeys(const UserContext& user_context); |
230 | 234 |
231 // Returns the auth request context associated with auth data. | 235 // Returns the auth request context associated with auth data. |
232 net::URLRequestContextGetter* GetAuthRequestContext() const; | 236 net::URLRequestContextGetter* GetAuthRequestContext() const; |
233 | 237 |
234 // Removes a profile from the per-user input methods states map. | 238 // Removes a profile from the per-user input methods states map. |
235 void RemoveProfileForTesting(Profile* profile); | 239 void RemoveProfileForTesting(Profile* profile); |
236 | 240 |
237 const UserContext& user_context() const { return user_context_; } | 241 const UserContext& user_context() const { return user_context_; } |
238 bool has_auth_cookies() const { return has_auth_cookies_; } | 242 bool has_auth_cookies() const { return has_auth_cookies_; } |
239 | 243 |
| 244 void Shutdown(); |
| 245 |
240 private: | 246 private: |
241 friend class test::UserSessionManagerTestApi; | 247 friend class test::UserSessionManagerTestApi; |
242 friend struct DefaultSingletonTraits<UserSessionManager>; | 248 friend struct DefaultSingletonTraits<UserSessionManager>; |
243 | 249 |
244 typedef std::set<std::string> SigninSessionRestoreStateSet; | 250 typedef std::set<std::string> SigninSessionRestoreStateSet; |
245 | 251 |
246 UserSessionManager(); | 252 UserSessionManager(); |
247 ~UserSessionManager() override; | 253 ~UserSessionManager() override; |
248 | 254 |
249 // OAuth2LoginManager::Observer overrides: | 255 // OAuth2LoginManager::Observer overrides: |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // completed this method is called with |locale_pref_checked| set to true. | 359 // completed this method is called with |locale_pref_checked| set to true. |
354 void DoBrowserLaunchInternal(Profile* profile, | 360 void DoBrowserLaunchInternal(Profile* profile, |
355 LoginDisplayHost* login_host, | 361 LoginDisplayHost* login_host, |
356 bool locale_pref_checked); | 362 bool locale_pref_checked); |
357 | 363 |
358 static void RunCallbackOnLocaleLoaded( | 364 static void RunCallbackOnLocaleLoaded( |
359 const base::Closure& callback, | 365 const base::Closure& callback, |
360 InputEventsBlocker* input_events_blocker, | 366 InputEventsBlocker* input_events_blocker, |
361 const locale_util::LanguageSwitchResult& result); | 367 const locale_util::LanguageSwitchResult& result); |
362 | 368 |
| 369 // Callback invoked when |token_handle_util_| has finished. |
| 370 void OnTokenHandleObtained(const user_manager::UserID& id, |
| 371 TokenHandleUtil::TokenHandleStatus status); |
| 372 |
| 373 // Returns |true| if token handles should be used on this device. |
| 374 bool TokenHandlesEnabled(); |
| 375 |
363 // Test API methods. | 376 // Test API methods. |
364 | 377 |
365 // Injects |user_context| that will be used to create StubAuthenticator | 378 // Injects |user_context| that will be used to create StubAuthenticator |
366 // instance when CreateAuthenticator() is called. | 379 // instance when CreateAuthenticator() is called. |
367 void InjectStubUserContext(const UserContext& user_context); | 380 void InjectStubUserContext(const UserContext& user_context); |
368 | 381 |
369 // Controls whether browser instance should be launched after sign in | 382 // Controls whether browser instance should be launched after sign in |
370 // (used in tests). | 383 // (used in tests). |
371 void set_should_launch_browser_in_tests(bool should_launch_browser) { | 384 void set_should_launch_browser_in_tests(bool should_launch_browser) { |
372 should_launch_browser_ = should_launch_browser; | 385 should_launch_browser_ = should_launch_browser; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 | 450 |
438 // Per-user-session Input Methods states. | 451 // Per-user-session Input Methods states. |
439 std::map<Profile*, scoped_refptr<input_method::InputMethodManager::State>, | 452 std::map<Profile*, scoped_refptr<input_method::InputMethodManager::State>, |
440 ProfileCompare> default_ime_states_; | 453 ProfileCompare> default_ime_states_; |
441 | 454 |
442 // Manages Easy unlock cryptohome keys. | 455 // Manages Easy unlock cryptohome keys. |
443 scoped_ptr<EasyUnlockKeyManager> easy_unlock_key_manager_; | 456 scoped_ptr<EasyUnlockKeyManager> easy_unlock_key_manager_; |
444 bool running_easy_unlock_key_ops_; | 457 bool running_easy_unlock_key_ops_; |
445 base::Closure easy_unlock_key_ops_finished_callback_; | 458 base::Closure easy_unlock_key_ops_finished_callback_; |
446 | 459 |
| 460 scoped_ptr<TokenHandleUtil> token_handle_util_; |
| 461 |
447 // Whether should launch browser, tests may override this value. | 462 // Whether should launch browser, tests may override this value. |
448 bool should_launch_browser_; | 463 bool should_launch_browser_; |
449 | 464 |
450 // Child account status is necessary for InitializeStartUrls call. | 465 // Child account status is necessary for InitializeStartUrls call. |
451 bool waiting_for_child_account_status_; | 466 bool waiting_for_child_account_status_; |
452 | 467 |
453 base::WeakPtrFactory<UserSessionManager> weak_factory_; | 468 base::WeakPtrFactory<UserSessionManager> weak_factory_; |
454 | 469 |
455 DISALLOW_COPY_AND_ASSIGN(UserSessionManager); | 470 DISALLOW_COPY_AND_ASSIGN(UserSessionManager); |
456 }; | 471 }; |
457 | 472 |
458 } // namespace chromeos | 473 } // namespace chromeos |
459 | 474 |
460 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_ | 475 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_ |
OLD | NEW |