Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/login/login_utils.h" | 5 #include "chrome/browser/chromeos/login/login_utils.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #include "base/stringprintf.h" | 23 #include "base/stringprintf.h" |
| 24 #include "base/synchronization/lock.h" | 24 #include "base/synchronization/lock.h" |
| 25 #include "base/task_runner_util.h" | 25 #include "base/task_runner_util.h" |
| 26 #include "base/threading/worker_pool.h" | 26 #include "base/threading/worker_pool.h" |
| 27 #include "base/time.h" | 27 #include "base/time.h" |
| 28 #include "base/utf_string_conversions.h" | 28 #include "base/utf_string_conversions.h" |
| 29 #include "cc/switches.h" | 29 #include "cc/switches.h" |
| 30 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
| 31 #include "chrome/browser/browser_shutdown.h" | 31 #include "chrome/browser/browser_shutdown.h" |
| 32 #include "chrome/browser/chromeos/boot_times_loader.h" | 32 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 33 #include "chrome/browser/chromeos/cros/cert_library.h" | |
| 34 #include "chrome/browser/chromeos/cros/cros_library.h" | 33 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 35 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 34 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
| 36 #include "chrome/browser/chromeos/cros/network_library.h" | 35 #include "chrome/browser/chromeos/cros/network_library.h" |
| 37 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" | 36 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" |
| 38 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 37 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 39 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 38 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 40 #include "chrome/browser/chromeos/login/language_switch_menu.h" | 39 #include "chrome/browser/chromeos/login/language_switch_menu.h" |
| 41 #include "chrome/browser/chromeos/login/login_display_host.h" | 40 #include "chrome/browser/chromeos/login/login_display_host.h" |
| 42 #include "chrome/browser/chromeos/login/oauth1_token_fetcher.h" | 41 #include "chrome/browser/chromeos/login/oauth_login_manager.h" |
| 43 #include "chrome/browser/chromeos/login/oauth_login_verifier.h" | |
| 44 #include "chrome/browser/chromeos/login/parallel_authenticator.h" | 42 #include "chrome/browser/chromeos/login/parallel_authenticator.h" |
| 45 #include "chrome/browser/chromeos/login/policy_oauth_fetcher.h" | |
| 46 #include "chrome/browser/chromeos/login/profile_auth_data.h" | 43 #include "chrome/browser/chromeos/login/profile_auth_data.h" |
| 47 #include "chrome/browser/chromeos/login/screen_locker.h" | 44 #include "chrome/browser/chromeos/login/screen_locker.h" |
| 48 #include "chrome/browser/chromeos/login/user_manager.h" | 45 #include "chrome/browser/chromeos/login/user_manager.h" |
| 49 #include "chrome/browser/chromeos/settings/cros_settings.h" | 46 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 50 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 47 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
| 51 #include "chrome/browser/extensions/extension_service.h" | 48 #include "chrome/browser/extensions/extension_service.h" |
| 52 #include "chrome/browser/first_run/first_run.h" | 49 #include "chrome/browser/first_run/first_run.h" |
| 53 #include "chrome/browser/google/google_util_chromeos.h" | 50 #include "chrome/browser/google/google_util_chromeos.h" |
| 54 #include "chrome/browser/net/chrome_url_request_context.h" | 51 #include "chrome/browser/net/chrome_url_request_context.h" |
| 55 #include "chrome/browser/net/preconnect.h" | 52 #include "chrome/browser/net/preconnect.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 75 #include "chrome/common/pref_names.h" | 72 #include "chrome/common/pref_names.h" |
| 76 #include "chrome/common/url_constants.h" | 73 #include "chrome/common/url_constants.h" |
| 77 #include "chromeos/chromeos_switches.h" | 74 #include "chromeos/chromeos_switches.h" |
| 78 #include "chromeos/dbus/dbus_thread_manager.h" | 75 #include "chromeos/dbus/dbus_thread_manager.h" |
| 79 #include "chromeos/dbus/session_manager_client.h" | 76 #include "chromeos/dbus/session_manager_client.h" |
| 80 #include "content/public/browser/browser_thread.h" | 77 #include "content/public/browser/browser_thread.h" |
| 81 #include "content/public/browser/notification_observer.h" | 78 #include "content/public/browser/notification_observer.h" |
| 82 #include "content/public/browser/notification_service.h" | 79 #include "content/public/browser/notification_service.h" |
| 83 #include "content/public/common/content_switches.h" | 80 #include "content/public/common/content_switches.h" |
| 84 #include "google_apis/gaia/gaia_auth_consumer.h" | 81 #include "google_apis/gaia/gaia_auth_consumer.h" |
| 82 #include "google_apis/gaia/gaia_constants.h" | |
| 85 #include "google_apis/gaia/gaia_urls.h" | 83 #include "google_apis/gaia/gaia_urls.h" |
| 86 #include "googleurl/src/gurl.h" | 84 #include "googleurl/src/gurl.h" |
| 87 #include "media/base/media_switches.h" | 85 #include "media/base/media_switches.h" |
| 88 #include "net/base/network_change_notifier.h" | 86 #include "net/base/network_change_notifier.h" |
| 89 #include "net/url_request/url_request_context.h" | 87 #include "net/url_request/url_request_context.h" |
| 90 #include "net/url_request/url_request_context_getter.h" | 88 #include "net/url_request/url_request_context_getter.h" |
| 91 #include "ui/base/ui_base_switches.h" | 89 #include "ui/base/ui_base_switches.h" |
| 92 #include "ui/compositor/compositor_switches.h" | 90 #include "ui/compositor/compositor_switches.h" |
| 93 #include "ui/gfx/switches.h" | 91 #include "ui/gfx/switches.h" |
| 94 #include "ui/gl/gl_switches.h" | 92 #include "ui/gl/gl_switches.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 } | 170 } |
| 173 | 171 |
| 174 int pid_; | 172 int pid_; |
| 175 std::string command_line_; | 173 std::string command_line_; |
| 176 PrefService* local_state_; | 174 PrefService* local_state_; |
| 177 base::OneShotTimer<JobRestartRequest> timer_; | 175 base::OneShotTimer<JobRestartRequest> timer_; |
| 178 }; | 176 }; |
| 179 | 177 |
| 180 class LoginUtilsImpl | 178 class LoginUtilsImpl |
| 181 : public LoginUtils, | 179 : public LoginUtils, |
| 182 public OAuth1TokenFetcher::Delegate, | 180 public OAuthLoginManager::Delegate, |
| 183 public OAuthLoginVerifier::Delegate, | |
| 184 public net::NetworkChangeNotifier::ConnectionTypeObserver, | 181 public net::NetworkChangeNotifier::ConnectionTypeObserver, |
| 185 public content::NotificationObserver, | 182 public content::NotificationObserver, |
| 186 public base::SupportsWeakPtr<LoginUtilsImpl> { | 183 public base::SupportsWeakPtr<LoginUtilsImpl> { |
| 187 public: | 184 public: |
| 188 LoginUtilsImpl() | 185 LoginUtilsImpl() |
| 189 : pending_requests_(false), | 186 : pending_requests_(false), |
| 190 using_oauth_(false), | 187 using_oauth_(false), |
| 188 force_oauth2_(CommandLine::ForCurrentProcess()->HasSwitch( | |
| 189 ::switches::kForceOAuth2)), | |
| 191 has_web_auth_cookies_(false), | 190 has_web_auth_cookies_(false), |
| 191 login_manager_(OAuthLoginManagerFactory::Create(this)), | |
| 192 delegate_(NULL), | 192 delegate_(NULL), |
| 193 job_restart_request_(NULL), | 193 job_restart_request_(NULL), |
| 194 should_restore_auth_session_(false), | 194 should_restore_auth_session_(false), |
| 195 url_request_context_getter_(NULL) { | 195 url_request_context_getter_(NULL) { |
| 196 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 196 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
| 197 // During tests, the browser_process may not be initialized yet causing | 197 // During tests, the browser_process may not be initialized yet causing |
| 198 // this to fail. | 198 // this to fail. |
| 199 if (g_browser_process) { | 199 if (g_browser_process) { |
| 200 registrar_.Add( | 200 registrar_.Add( |
| 201 this, | 201 this, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 220 bool has_cookies, | 220 bool has_cookies, |
| 221 LoginUtils::Delegate* delegate) OVERRIDE; | 221 LoginUtils::Delegate* delegate) OVERRIDE; |
| 222 virtual void DelegateDeleted(LoginUtils::Delegate* delegate) OVERRIDE; | 222 virtual void DelegateDeleted(LoginUtils::Delegate* delegate) OVERRIDE; |
| 223 virtual void CompleteOffTheRecordLogin(const GURL& start_url) OVERRIDE; | 223 virtual void CompleteOffTheRecordLogin(const GURL& start_url) OVERRIDE; |
| 224 virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE; | 224 virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE; |
| 225 virtual scoped_refptr<Authenticator> CreateAuthenticator( | 225 virtual scoped_refptr<Authenticator> CreateAuthenticator( |
| 226 LoginStatusConsumer* consumer) OVERRIDE; | 226 LoginStatusConsumer* consumer) OVERRIDE; |
| 227 virtual void PrewarmAuthentication() OVERRIDE; | 227 virtual void PrewarmAuthentication() OVERRIDE; |
| 228 virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; | 228 virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; |
| 229 virtual void StartTokenServices(Profile* user_profile) OVERRIDE; | 229 virtual void StartTokenServices(Profile* user_profile) OVERRIDE; |
| 230 virtual void StartSignedInServices( | |
| 231 Profile* profile, | |
| 232 const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE; | |
| 233 virtual void StopBackgroundFetchers() OVERRIDE; | 230 virtual void StopBackgroundFetchers() OVERRIDE; |
| 234 virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; | 231 virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; |
| 235 virtual void CompleteProfileCreate(Profile* user_profile) OVERRIDE; | 232 virtual void CompleteProfileCreate(Profile* user_profile) OVERRIDE; |
| 236 | 233 |
| 237 // OAuth1TokenFetcher::Delegate overrides. | 234 // OAuthLoginManager::Delegate overrides. |
| 238 void OnOAuth1AccessTokenAvailable(const std::string& token, | 235 virtual void OnCompletedAuthentication(Profile* user_profile) OVERRIDE; |
| 239 const std::string& secret) OVERRIDE; | 236 virtual void OnFoundStoredTokens() OVERRIDE; |
| 240 void OnOAuth1AccessTokenFetchFailed() OVERRIDE; | |
| 241 | |
| 242 // OAuthLoginVerifier::Delegate overrides. | |
| 243 virtual void OnOAuthVerificationSucceeded(const std::string& user_name, | |
| 244 const std::string& sid, | |
| 245 const std::string& lsid, | |
| 246 const std::string& auth) OVERRIDE; | |
| 247 virtual void OnOAuthVerificationFailed(const std::string& user_name) OVERRIDE; | |
| 248 | 237 |
| 249 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. | 238 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. |
| 250 virtual void OnConnectionTypeChanged( | 239 virtual void OnConnectionTypeChanged( |
| 251 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; | 240 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
| 252 | 241 |
| 253 // content::NotificationObserver overrides. | 242 // content::NotificationObserver overrides. |
| 254 virtual void Observe(int type, | 243 virtual void Observe(int type, |
| 255 const content::NotificationSource& source, | 244 const content::NotificationSource& source, |
| 256 const content::NotificationDetails& details) OVERRIDE; | 245 const content::NotificationDetails& details) OVERRIDE; |
| 257 | 246 |
| 258 protected: | 247 protected: |
| 259 virtual std::string GetOffTheRecordCommandLine( | 248 virtual std::string GetOffTheRecordCommandLine( |
| 260 const GURL& start_url, | 249 const GURL& start_url, |
| 261 const CommandLine& base_command_line, | 250 const CommandLine& base_command_line, |
| 262 CommandLine *command_line); | 251 CommandLine *command_line); |
| 263 | 252 |
| 264 private: | 253 private: |
| 265 // Restarts OAuth session authentication check. | 254 // Restarts OAuth session authentication check. |
| 266 void KickStartAuthentication(Profile* profile); | 255 void KickStartAuthentication(Profile* profile); |
| 267 | 256 |
| 268 // Reads OAuth1 token from user profile's prefs. | |
| 269 bool ReadOAuth1AccessToken(Profile* user_profile, | |
| 270 std::string* token, | |
| 271 std::string* secret); | |
| 272 | |
| 273 // Stores OAuth1 token + secret in profile's prefs. | |
| 274 void StoreOAuth1AccessToken(Profile* user_profile, | |
| 275 const std::string& token, | |
| 276 const std::string& secret); | |
| 277 | |
| 278 // Verifies OAuth1 token by doing OAuthLogin and fetching credentials. | |
| 279 void VerifyOAuth1AccessToken(Profile* user_profile, | |
| 280 const std::string& token, | |
| 281 const std::string& secret); | |
| 282 | |
| 283 // Fetch all secondary (OAuth2) tokens given OAuth1 access |token| and | |
| 284 // |secret|. | |
| 285 void FetchSecondaryTokens(Profile* offrecord_profile, | |
| 286 const std::string& token, | |
| 287 const std::string& secret); | |
| 288 | |
| 289 // Fetch user credentials (sid/lsid) given OAuth1 access |token| and |secret|. | |
| 290 void FetchCredentials(Profile* user_profile, | |
| 291 const std::string& token, | |
| 292 const std::string& secret); | |
| 293 | |
| 294 // Fetch enterprise policy OAuth2 given OAuth1 access |token| and |secret|. | |
| 295 void FetchPolicyToken(Profile* offrecord_profile, | |
| 296 const std::string& token, | |
| 297 const std::string& secret); | |
| 298 | |
| 299 // Check user's profile for kApplicationLocale setting. | 257 // Check user's profile for kApplicationLocale setting. |
| 300 void RespectLocalePreference(Profile* pref); | 258 void RespectLocalePreference(Profile* pref); |
| 301 | 259 |
| 302 // Initializes basic preferences for newly created profile. | 260 // Initializes basic preferences for newly created profile. |
| 303 void InitProfilePreferences(Profile* user_profile); | 261 void InitProfilePreferences(Profile* user_profile); |
| 304 | 262 |
| 305 // Callback for asynchronous profile creation. | 263 // Callback for asynchronous profile creation. |
| 306 void OnProfileCreated(Profile* profile, | 264 void OnProfileCreated(Profile* profile, |
| 307 Profile::CreateStatus status); | 265 Profile::CreateStatus status); |
| 308 | 266 |
| 309 // Finalized profile preparation. | 267 // Finalized profile preparation. |
| 310 void FinalizePrepareProfile(Profile* user_profile); | 268 void FinalizePrepareProfile(Profile* user_profile); |
| 311 | 269 |
| 312 // Restores GAIA auth cookies for the created profile. | 270 // Restores GAIA auth cookies for the created user profile from OAuth2 token. |
| 313 void RestoreAuthCookies(Profile* user_profile); | 271 void RestoreAuthSession(Profile* user_profile, |
| 272 bool restore_from_auth_cookies); | |
| 273 | |
| 274 // Removed deprecated OAuth1 token and secret form preference store. | |
|
Joao da Silva
2013/01/11 16:45:07
*Removes, *from
zel
2013/01/11 19:51:16
Done.
| |
| 275 void RemoveOAuth1Tokens(Profile* user_profile); | |
| 314 | 276 |
| 315 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. | 277 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. |
| 316 void InitRlz(Profile* user_profile, bool disabled); | 278 void InitRlz(Profile* user_profile, bool disabled); |
| 317 | 279 |
| 280 // Starts signing related services. Initiates TokenService token retreival. | |
|
Joao da Silva
2013/01/11 16:45:07
*retrieval
zel
2013/01/11 19:51:16
Done.
| |
| 281 void StartSignedInServices(Profile* profile); | |
| 282 | |
| 318 std::string password_; | 283 std::string password_; |
| 319 bool pending_requests_; | 284 bool pending_requests_; |
|
Joao da Silva
2013/01/11 16:45:07
pending_requests_ is dead code and can be removed.
zel
2013/01/11 19:51:16
Done.
| |
| 320 bool using_oauth_; | 285 bool using_oauth_; |
| 286 bool force_oauth2_; | |
| 321 // True if the authenrication profile's cookie jar should contain | 287 // True if the authenrication profile's cookie jar should contain |
| 322 // authentication cookies from the authentication extension log in flow. | 288 // authentication cookies from the authentication extension log in flow. |
| 323 bool has_web_auth_cookies_; | 289 bool has_web_auth_cookies_; |
| 324 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). | 290 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). |
| 325 scoped_refptr<Authenticator> authenticator_; | 291 scoped_refptr<Authenticator> authenticator_; |
| 326 scoped_ptr<PolicyOAuthFetcher> policy_oauth_fetcher_; | 292 scoped_ptr<OAuthLoginManager> login_manager_; |
| 327 scoped_ptr<OAuth1TokenFetcher> oauth1_token_fetcher_; | |
| 328 scoped_ptr<OAuthLoginVerifier> oauth_login_verifier_; | |
| 329 | 293 |
| 330 // Delegate to be fired when the profile will be prepared. | 294 // Delegate to be fired when the profile will be prepared. |
| 331 LoginUtils::Delegate* delegate_; | 295 LoginUtils::Delegate* delegate_; |
| 332 | 296 |
| 333 // Used to restart Chrome to switch to the guest mode. | 297 // Used to restart Chrome to switch to the guest mode. |
| 334 JobRestartRequest* job_restart_request_; | 298 JobRestartRequest* job_restart_request_; |
| 335 | 299 |
| 336 // True if should restore authentication session when notified about | 300 // True if should restore authentication session when notified about |
| 337 // online state change. | 301 // online state change. |
| 338 bool should_restore_auth_session_; | 302 bool should_restore_auth_session_; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 // requires the DeviceManagement token. Try to fetch it now. | 438 // requires the DeviceManagement token. Try to fetch it now. |
| 475 // TODO(atwilson): This is somewhat racy, as we are trying to fetch a | 439 // TODO(atwilson): This is somewhat racy, as we are trying to fetch a |
| 476 // DMToken in parallel with loading the cached policy blob (there could | 440 // DMToken in parallel with loading the cached policy blob (there could |
| 477 // already be a DMToken in the cached policy). Once the legacy policy | 441 // already be a DMToken in the cached policy). Once the legacy policy |
| 478 // framework is removed, this code can register a | 442 // framework is removed, this code can register a |
| 479 // CloudPolicyService::Observer to check whether the CloudPolicyClient was | 443 // CloudPolicyService::Observer to check whether the CloudPolicyClient was |
| 480 // able to register itself using the cached policy data, and then only | 444 // able to register itself using the cached policy data, and then only |
| 481 // create a PolicyOAuthFetcher if the client is still unregistered | 445 // create a PolicyOAuthFetcher if the client is still unregistered |
| 482 // (http://crbug.com/143187). | 446 // (http://crbug.com/143187). |
| 483 VLOG(1) << "Profile creation requires policy token, fetching now"; | 447 VLOG(1) << "Profile creation requires policy token, fetching now"; |
| 484 policy_oauth_fetcher_.reset( | 448 login_manager_->RestorePolicyTokens( |
| 485 new PolicyOAuthFetcher(authenticator_->authentication_profile())); | 449 authenticator_->authentication_profile()->GetRequestContext()); |
| 486 policy_oauth_fetcher_->Start(); | |
| 487 } | 450 } |
| 488 } | 451 } |
| 489 | 452 |
| 490 void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) { | 453 void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) { |
| 491 if (delegate_ == delegate) | 454 if (delegate_ == delegate) |
| 492 delegate_ = NULL; | 455 delegate_ = NULL; |
| 493 } | 456 } |
| 494 | 457 |
| 495 void LoginUtilsImpl::InitProfilePreferences(Profile* user_profile) { | 458 void LoginUtilsImpl::InitProfilePreferences(Profile* user_profile) { |
| 496 if (UserManager::Get()->IsCurrentUserNew()) | 459 if (UserManager::Get()->IsCurrentUserNew()) |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 514 GetNetworkConfigurationUpdater(); | 477 GetNetworkConfigurationUpdater(); |
| 515 if (network_configuration_updater) | 478 if (network_configuration_updater) |
| 516 network_configuration_updater->OnUserPolicyInitialized(); | 479 network_configuration_updater->OnUserPolicyInitialized(); |
| 517 RespectLocalePreference(user_profile); | 480 RespectLocalePreference(user_profile); |
| 518 } | 481 } |
| 519 | 482 |
| 520 void LoginUtilsImpl::OnProfileCreated( | 483 void LoginUtilsImpl::OnProfileCreated( |
| 521 Profile* user_profile, | 484 Profile* user_profile, |
| 522 Profile::CreateStatus status) { | 485 Profile::CreateStatus status) { |
| 523 CHECK(user_profile); | 486 CHECK(user_profile); |
| 524 | |
| 525 if (delegate_) | 487 if (delegate_) |
| 526 delegate_->OnProfileCreated(user_profile); | 488 delegate_->OnProfileCreated(user_profile); |
| 527 | 489 |
| 528 switch (status) { | 490 switch (status) { |
| 529 case Profile::CREATE_STATUS_INITIALIZED: | 491 case Profile::CREATE_STATUS_INITIALIZED: |
| 530 break; | 492 break; |
| 531 case Profile::CREATE_STATUS_CREATED: { | 493 case Profile::CREATE_STATUS_CREATED: { |
| 532 InitProfilePreferences(user_profile); | 494 InitProfilePreferences(user_profile); |
| 533 return; | 495 return; |
| 534 } | 496 } |
| 535 case Profile::CREATE_STATUS_FAIL: | 497 case Profile::CREATE_STATUS_FAIL: |
| 536 default: | 498 default: |
| 537 NOTREACHED(); | 499 NOTREACHED(); |
| 538 return; | 500 return; |
| 539 } | 501 } |
| 540 | 502 |
| 541 BootTimesLoader* btl = BootTimesLoader::Get(); | 503 BootTimesLoader* btl = BootTimesLoader::Get(); |
| 542 btl->AddLoginTimeMarker("UserProfileGotten", false); | 504 btl->AddLoginTimeMarker("UserProfileGotten", false); |
| 543 | 505 |
| 544 if (using_oauth_) { | 506 if (using_oauth_) { |
| 545 // Reuse the access token fetched by the PolicyOAuthFetcher, if it was | |
| 546 // used to fetch policies before Profile creation. | |
| 547 if (policy_oauth_fetcher_.get() && | |
| 548 !policy_oauth_fetcher_->oauth1_token().empty()) { | |
| 549 VLOG(1) << "Resuming profile creation after fetching policy token"; | |
| 550 StoreOAuth1AccessToken(user_profile, | |
| 551 policy_oauth_fetcher_->oauth1_token(), | |
| 552 policy_oauth_fetcher_->oauth1_secret()); | |
| 553 } | |
| 554 | |
| 555 // Transfer proxy authentication cache, cookies (optionally) and server | 507 // Transfer proxy authentication cache, cookies (optionally) and server |
| 556 // bound certs from the profile that was used for authentication. This | 508 // bound certs from the profile that was used for authentication. This |
| 557 // profile contains cookies that auth extension should have already put in | 509 // profile contains cookies that auth extension should have already put in |
| 558 // place that will ensure that the newly created session is authenticated | 510 // place that will ensure that the newly created session is authenticated |
| 559 // for the websites that work with the used authentication schema. | 511 // for the websites that work with the used authentication schema. |
| 560 ProfileAuthData::Transfer(authenticator_->authentication_profile(), | 512 ProfileAuthData::Transfer(authenticator_->authentication_profile(), |
| 561 user_profile, | 513 user_profile, |
| 562 has_web_auth_cookies_, // transfer_cookies | 514 has_web_auth_cookies_, // transfer_cookies |
| 563 base::Bind( | 515 base::Bind( |
| 564 &LoginUtilsImpl::CompleteProfileCreate, | 516 &LoginUtilsImpl::CompleteProfileCreate, |
| 565 AsWeakPtr(), | 517 AsWeakPtr(), |
| 566 user_profile)); | 518 user_profile)); |
| 567 return; | 519 return; |
| 568 } | 520 } |
| 569 | 521 |
| 570 FinalizePrepareProfile(user_profile); | 522 FinalizePrepareProfile(user_profile); |
| 571 } | 523 } |
| 572 | 524 |
| 573 void LoginUtilsImpl::RestoreAuthCookies(Profile* user_profile) { | 525 void LoginUtilsImpl::CompleteProfileCreate(Profile* user_profile) { |
| 574 std::string oauth1_token; | 526 RestoreAuthSession(user_profile, has_web_auth_cookies_); |
| 575 std::string oauth1_secret; | 527 FinalizePrepareProfile(user_profile); |
| 576 if (ReadOAuth1AccessToken(user_profile, &oauth1_token, &oauth1_secret) || | |
| 577 !has_web_auth_cookies_) { | |
| 578 // Verify OAuth access token when we find it in the profile and always if | |
| 579 // if we don't have cookies. | |
| 580 // TODO(xiyuan): Change back to use authenticator to verify token when | |
| 581 // we support Gaia in lock screen. | |
| 582 VerifyOAuth1AccessToken(user_profile, oauth1_token, oauth1_secret); | |
| 583 } else { | |
| 584 // If we don't have it, fetch OAuth1 access token. | |
| 585 // Once we get that, we will kick off individual requests for OAuth2 | |
| 586 // tokens for all our services. | |
| 587 // Use off-the-record profile that was used for this step. It should | |
| 588 // already contain all needed cookies that will let us skip GAIA's user | |
| 589 // authentication UI. | |
| 590 // | |
| 591 // TODO(rickcam) We should use an isolated App here. | |
| 592 oauth1_token_fetcher_.reset( | |
| 593 new OAuth1TokenFetcher(this, | |
| 594 authenticator_->authentication_profile())); | |
| 595 oauth1_token_fetcher_->Start(); | |
| 596 } | |
| 597 } | 528 } |
| 598 | 529 |
| 599 void LoginUtilsImpl::CompleteProfileCreate(Profile* user_profile) { | 530 void LoginUtilsImpl::RestoreAuthSession(Profile* user_profile, |
| 600 RestoreAuthCookies(user_profile); | 531 bool restore_from_auth_cookies) { |
| 601 FinalizePrepareProfile(user_profile); | 532 DCHECK(authenticator_ || !restore_from_auth_cookies); |
| 533 // Remove legacy OAuth1 token if we have one. If it's valid, we should already | |
| 534 // have OAuth2 refresh token in TokenService that could be used to retreive | |
|
Joao da Silva
2013/01/11 16:45:07
*retrieve
zel
2013/01/11 19:51:16
Done.
| |
| 535 // all other tokens and credentials. | |
| 536 login_manager_->RestoreSession( | |
| 537 user_profile, | |
| 538 authenticator_ ? | |
| 539 authenticator_->authentication_profile()->GetRequestContext() : | |
| 540 NULL, | |
| 541 restore_from_auth_cookies); | |
| 602 } | 542 } |
| 603 | 543 |
| 604 void LoginUtilsImpl::FinalizePrepareProfile(Profile* user_profile) { | 544 void LoginUtilsImpl::FinalizePrepareProfile(Profile* user_profile) { |
| 605 BootTimesLoader* btl = BootTimesLoader::Get(); | 545 BootTimesLoader* btl = BootTimesLoader::Get(); |
| 606 // Own TPM device if, for any reason, it has not been done in EULA | 546 // Own TPM device if, for any reason, it has not been done in EULA |
| 607 // wizard screen. | 547 // wizard screen. |
| 608 CryptohomeLibrary* cryptohome = CrosLibrary::Get()->GetCryptohomeLibrary(); | 548 CryptohomeLibrary* cryptohome = CrosLibrary::Get()->GetCryptohomeLibrary(); |
| 609 btl->AddLoginTimeMarker("TPMOwn-Start", false); | 549 btl->AddLoginTimeMarker("TPMOwn-Start", false); |
| 610 if (cryptohome->TpmIsEnabled() && !cryptohome->TpmIsBeingOwned()) { | 550 if (cryptohome->TpmIsEnabled() && !cryptohome->TpmIsBeingOwned()) { |
| 611 if (cryptohome->TpmIsOwned()) { | 551 if (cryptohome->TpmIsOwned()) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 // recorded. | 612 // recorded. |
| 673 RLZTracker::InitRlzFromProfileDelayed( | 613 RLZTracker::InitRlzFromProfileDelayed( |
| 674 user_profile, UserManager::Get()->IsCurrentUserNew(), | 614 user_profile, UserManager::Get()->IsCurrentUserNew(), |
| 675 ping_delay < 0, base::TimeDelta::FromMilliseconds(abs(ping_delay))); | 615 ping_delay < 0, base::TimeDelta::FromMilliseconds(abs(ping_delay))); |
| 676 if (delegate_) | 616 if (delegate_) |
| 677 delegate_->OnRlzInitialized(user_profile); | 617 delegate_->OnRlzInitialized(user_profile); |
| 678 #endif | 618 #endif |
| 679 } | 619 } |
| 680 | 620 |
| 681 void LoginUtilsImpl::StartTokenServices(Profile* user_profile) { | 621 void LoginUtilsImpl::StartTokenServices(Profile* user_profile) { |
| 622 RestoreAuthSession(user_profile, false); | |
| 623 /* | |
|
Joao da Silva
2013/01/11 16:45:07
I guess this will be removed?
zel
2013/01/11 19:51:16
Done.
| |
| 682 std::string oauth1_token; | 624 std::string oauth1_token; |
| 683 std::string oauth1_secret; | 625 std::string oauth1_secret; |
| 684 if (!ReadOAuth1AccessToken(user_profile, &oauth1_token, &oauth1_secret)) | 626 if (!ReadOAuth1AccessToken(user_profile, &oauth1_token, &oauth1_secret)) |
| 685 return; | 627 return; |
| 686 | 628 |
| 687 FetchSecondaryTokens(user_profile->GetOffTheRecordProfile(), | 629 FetchSecondaryTokens(user_profile->GetOffTheRecordProfile(), |
| 688 oauth1_token, oauth1_secret); | 630 oauth1_token, oauth1_secret); |
| 631 */ | |
| 689 } | 632 } |
| 690 | 633 |
| 691 void LoginUtilsImpl::StartSignedInServices( | 634 void LoginUtilsImpl::StartSignedInServices(Profile* user_profile) { |
| 692 Profile* user_profile, | |
| 693 const GaiaAuthConsumer::ClientLoginResult& credentials) { | |
| 694 // Fetch/Create the SigninManager - this will cause the TokenService to load | 635 // Fetch/Create the SigninManager - this will cause the TokenService to load |
| 695 // tokens for the currently signed-in user if the SigninManager hasn't already | 636 // tokens for the currently signed-in user if the SigninManager hasn't already |
| 696 // been initialized. | 637 // been initialized. |
| 697 SigninManager* signin = SigninManagerFactory::GetForProfile(user_profile); | 638 SigninManager* signin = SigninManagerFactory::GetForProfile(user_profile); |
| 698 DCHECK(signin); | 639 DCHECK(signin); |
| 699 // Make sure SigninManager is connected to our current user (this should | 640 // Make sure SigninManager is connected to our current user (this should |
| 700 // happen automatically because we set kGoogleServicesUsername in | 641 // happen automatically because we set kGoogleServicesUsername in |
| 701 // OnProfileCreated()). | 642 // OnProfileCreated()). |
| 702 DCHECK_EQ(UserManager::Get()->GetLoggedInUser()->display_email(), | 643 DCHECK_EQ(UserManager::Get()->GetLoggedInUser()->display_email(), |
| 703 signin->GetAuthenticatedUsername()); | 644 signin->GetAuthenticatedUsername()); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 715 GoogleServiceSigninSuccessDetails details( | 656 GoogleServiceSigninSuccessDetails details( |
| 716 signin->GetAuthenticatedUsername(), | 657 signin->GetAuthenticatedUsername(), |
| 717 password_); | 658 password_); |
| 718 content::NotificationService::current()->Notify( | 659 content::NotificationService::current()->Notify( |
| 719 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, | 660 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, |
| 720 content::Source<Profile>(user_profile), | 661 content::Source<Profile>(user_profile), |
| 721 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); | 662 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); |
| 722 } | 663 } |
| 723 } | 664 } |
| 724 password_.clear(); | 665 password_.clear(); |
| 725 TokenService* token_service = | |
| 726 TokenServiceFactory::GetForProfile(user_profile); | |
| 727 token_service->UpdateCredentials(credentials); | |
| 728 if (token_service->AreCredentialsValid()) | |
| 729 token_service->StartFetchingTokens(); | |
| 730 } | 666 } |
| 731 | 667 |
| 732 void LoginUtilsImpl::RespectLocalePreference(Profile* profile) { | 668 void LoginUtilsImpl::RespectLocalePreference(Profile* profile) { |
| 733 DCHECK(profile != NULL); | 669 DCHECK(profile != NULL); |
| 734 PrefService* prefs = profile->GetPrefs(); | 670 PrefService* prefs = profile->GetPrefs(); |
| 735 DCHECK(prefs != NULL); | 671 DCHECK(prefs != NULL); |
| 736 if (g_browser_process == NULL) | 672 if (g_browser_process == NULL) |
| 737 return; | 673 return; |
| 738 | 674 |
| 739 std::string pref_locale = prefs->GetString(prefs::kApplicationLocale); | 675 std::string pref_locale = prefs->GetString(prefs::kApplicationLocale); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1018 void LoginUtilsImpl::RestoreAuthenticationSession(Profile* user_profile) { | 954 void LoginUtilsImpl::RestoreAuthenticationSession(Profile* user_profile) { |
| 1019 // We don't need to restore session for demo/guest users. | 955 // We don't need to restore session for demo/guest users. |
| 1020 if (!UserManager::Get()->IsUserLoggedIn() || | 956 if (!UserManager::Get()->IsUserLoggedIn() || |
| 1021 UserManager::Get()->IsLoggedInAsGuest() || | 957 UserManager::Get()->IsLoggedInAsGuest() || |
| 1022 UserManager::Get()->IsLoggedInAsDemoUser()) { | 958 UserManager::Get()->IsLoggedInAsDemoUser()) { |
| 1023 return; | 959 return; |
| 1024 } | 960 } |
| 1025 | 961 |
| 1026 if (!net::NetworkChangeNotifier::IsOffline()) { | 962 if (!net::NetworkChangeNotifier::IsOffline()) { |
| 1027 should_restore_auth_session_ = false; | 963 should_restore_auth_session_ = false; |
| 1028 KickStartAuthentication(user_profile); | 964 RestoreAuthSession(user_profile, false); |
| 1029 } else { | 965 } else { |
| 1030 // Even if we're online we should wait till initial | 966 // Even if we're online we should wait till initial |
| 1031 // OnConnectionTypeChanged() call. Otherwise starting fetchers too early may | 967 // OnConnectionTypeChanged() call. Otherwise starting fetchers too early may |
| 1032 // end up cancelling all request when initial network connection type is | 968 // end up cancelling all request when initial network connection type is |
| 1033 // processed. See http://crbug.com/121643. | 969 // processed. See http://crbug.com/121643. |
| 1034 should_restore_auth_session_ = true; | 970 should_restore_auth_session_ = true; |
| 1035 } | 971 } |
| 1036 } | 972 } |
| 1037 | 973 |
| 1038 void LoginUtilsImpl::KickStartAuthentication(Profile* user_profile) { | 974 void LoginUtilsImpl::StopBackgroundFetchers() { |
| 1039 std::string oauth1_token; | 975 login_manager_.reset(); |
|
Joao da Silva
2013/01/11 16:45:07
This only happens at shutdown and should be safe,
zel
2013/01/11 19:51:16
Good catch. Added check to OnConnectionTypeChanged
| |
| 1040 std::string oauth1_secret; | |
| 1041 if (ReadOAuth1AccessToken(user_profile, &oauth1_token, &oauth1_secret)) | |
| 1042 VerifyOAuth1AccessToken(user_profile, oauth1_token, oauth1_secret); | |
| 1043 } | 976 } |
| 1044 | 977 |
| 1045 void LoginUtilsImpl::StopBackgroundFetchers() { | 978 void LoginUtilsImpl::OnCompletedAuthentication(Profile* user_profile) { |
| 1046 policy_oauth_fetcher_.reset(); | 979 StartSignedInServices(user_profile); |
| 1047 oauth1_token_fetcher_.reset(); | |
| 1048 oauth_login_verifier_.reset(); | |
| 1049 } | 980 } |
| 1050 | 981 |
| 1051 void LoginUtilsImpl::FetchSecondaryTokens(Profile* offrecord_profile, | 982 void LoginUtilsImpl::OnFoundStoredTokens() { |
| 1052 const std::string& token, | 983 // We don't need authenticator instance any more since its cookie jar |
| 1053 const std::string& secret) { | 984 // is not going to needed to mint OAuth tokens. Reset it so that |
| 1054 FetchPolicyToken(offrecord_profile, token, secret); | |
| 1055 // TODO(rickcam, zelidrag): Wire TokenService there when it becomes | |
| 1056 // capable of handling OAuth1 tokens directly. | |
| 1057 } | |
| 1058 | |
| 1059 bool LoginUtilsImpl::ReadOAuth1AccessToken(Profile* user_profile, | |
| 1060 std::string* token, | |
| 1061 std::string* secret) { | |
| 1062 // Skip reading oauth token if user does not have a valid status. | |
| 1063 if (UserManager::Get()->IsUserLoggedIn() && | |
| 1064 UserManager::Get()->GetLoggedInUser()->oauth_token_status() != | |
| 1065 User::OAUTH_TOKEN_STATUS_VALID) { | |
| 1066 return false; | |
| 1067 } | |
| 1068 | |
| 1069 PrefService* pref_service = user_profile->GetPrefs(); | |
| 1070 std::string encoded_token = pref_service->GetString(prefs::kOAuth1Token); | |
| 1071 std::string encoded_secret = pref_service->GetString(prefs::kOAuth1Secret); | |
| 1072 if (!encoded_token.length() || !encoded_secret.length()) | |
| 1073 return false; | |
| 1074 | |
| 1075 std::string decoded_token = | |
| 1076 CrosLibrary::Get()->GetCertLibrary()->DecryptToken(encoded_token); | |
| 1077 std::string decoded_secret = | |
| 1078 CrosLibrary::Get()->GetCertLibrary()->DecryptToken(encoded_secret); | |
| 1079 if (!decoded_token.length() || !decoded_secret.length()) | |
| 1080 return false; | |
| 1081 | |
| 1082 *token = decoded_token; | |
| 1083 *secret = decoded_secret; | |
| 1084 return true; | |
| 1085 } | |
| 1086 | |
| 1087 void LoginUtilsImpl::StoreOAuth1AccessToken(Profile* user_profile, | |
| 1088 const std::string& token, | |
| 1089 const std::string& secret) { | |
| 1090 // First store OAuth1 token + service for the current user profile... | |
| 1091 std::string encrypted_token = | |
| 1092 CrosLibrary::Get()->GetCertLibrary()->EncryptToken(token); | |
| 1093 std::string encrypted_secret = | |
| 1094 CrosLibrary::Get()->GetCertLibrary()->EncryptToken(secret); | |
| 1095 PrefService* pref_service = user_profile->GetPrefs(); | |
| 1096 User* user = UserManager::Get()->GetLoggedInUser(); | |
| 1097 if (!encrypted_token.empty() && !encrypted_secret.empty()) { | |
| 1098 pref_service->SetString(prefs::kOAuth1Token, encrypted_token); | |
| 1099 pref_service->SetString(prefs::kOAuth1Secret, encrypted_secret); | |
| 1100 | |
| 1101 // ...then record the presence of valid OAuth token for this account in | |
| 1102 // local state as well. | |
| 1103 UserManager::Get()->SaveUserOAuthStatus( | |
| 1104 user->email(), User::OAUTH_TOKEN_STATUS_VALID); | |
| 1105 } else { | |
| 1106 LOG(WARNING) << "Failed to get OAuth1 token/secret encrypted."; | |
| 1107 // Set the OAuth status invalid so that the user will go through full | |
| 1108 // GAIA login next time. | |
| 1109 UserManager::Get()->SaveUserOAuthStatus( | |
| 1110 user->email(), User::OAUTH_TOKEN_STATUS_INVALID); | |
| 1111 } | |
| 1112 } | |
| 1113 | |
| 1114 void LoginUtilsImpl::VerifyOAuth1AccessToken(Profile* user_profile, | |
| 1115 const std::string& token, | |
| 1116 const std::string& secret) { | |
| 1117 // Kick off verification of OAuth1 access token (via OAuthLogin), this should | |
| 1118 // let us fetch credentials that will be used to initialize sync engine. | |
| 1119 FetchCredentials(user_profile, token, secret); | |
| 1120 | |
| 1121 FetchSecondaryTokens(user_profile->GetOffTheRecordProfile(), token, secret); | |
| 1122 } | |
| 1123 | |
| 1124 void LoginUtilsImpl::FetchCredentials(Profile* user_profile, | |
| 1125 const std::string& token, | |
| 1126 const std::string& secret) { | |
| 1127 oauth_login_verifier_.reset(new OAuthLoginVerifier( | |
| 1128 this, user_profile, token, secret, | |
| 1129 UserManager::Get()->GetLoggedInUser()->email())); | |
| 1130 oauth_login_verifier_->StartOAuthVerification(); | |
| 1131 } | |
| 1132 | |
| 1133 | |
| 1134 void LoginUtilsImpl::FetchPolicyToken(Profile* offrecord_profile, | |
| 1135 const std::string& token, | |
| 1136 const std::string& secret) { | |
| 1137 // Fetch dm service token now, if it hasn't been fetched yet. | |
| 1138 if (!policy_oauth_fetcher_.get() || policy_oauth_fetcher_->failed()) { | |
| 1139 // Get the default system profile to use with the policy fetching. If there | |
| 1140 // is no |authenticator_| profile, manually load default system profile. | |
| 1141 // Otherwise, just use |authenticator_|'s profile. | |
| 1142 Profile* profile = NULL; | |
| 1143 if (authenticator_) | |
| 1144 profile = authenticator_->authentication_profile(); | |
| 1145 | |
| 1146 if (!profile) { | |
| 1147 FilePath user_data_dir; | |
| 1148 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | |
| 1149 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 1150 // Temporarily allow until fix: http://crosbug.com/30391. | |
| 1151 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
| 1152 profile = profile_manager->GetProfile(user_data_dir)-> | |
| 1153 GetOffTheRecordProfile(); | |
| 1154 } | |
| 1155 | |
| 1156 // Trigger oauth token fetch for user policy. | |
| 1157 policy_oauth_fetcher_.reset(new PolicyOAuthFetcher(profile, token, secret)); | |
| 1158 policy_oauth_fetcher_->Start(); | |
| 1159 } | |
| 1160 | |
| 1161 // TODO(zelidrag): We should add initialization of other services somewhere | |
| 1162 // here as well. This could be handled with TokenService class once it is | |
| 1163 // ready to handle OAuth tokens. | |
| 1164 | |
| 1165 // We don't need authenticator instance any more, reset it so that | |
| 1166 // ScreenLocker would create a separate instance. | 985 // ScreenLocker would create a separate instance. |
| 1167 // TODO(nkostylev): There's a potential race if SL would be created before | |
| 1168 // OAuth tokens are fetched. It would use incorrect Authenticator instance. | |
| 1169 authenticator_ = NULL; | 986 authenticator_ = NULL; |
| 1170 } | 987 } |
| 1171 | 988 |
| 1172 void LoginUtilsImpl::OnOAuthVerificationFailed(const std::string& user_name) { | |
| 1173 UserManager::Get()->SaveUserOAuthStatus(user_name, | |
| 1174 User::OAUTH_TOKEN_STATUS_INVALID); | |
| 1175 } | |
| 1176 | |
| 1177 void LoginUtilsImpl::OnOAuth1AccessTokenAvailable(const std::string& token, | |
| 1178 const std::string& secret) { | |
| 1179 Profile* user_profile = ProfileManager::GetDefaultProfile(); | |
| 1180 StoreOAuth1AccessToken(user_profile, token, secret); | |
| 1181 | |
| 1182 // Verify OAuth1 token by doing OAuthLogin and fetching credentials. If we | |
| 1183 // have just transfered auth cookies out of authenticated cookie jar, there | |
| 1184 // is no need to try to mint them from OAuth token again. | |
| 1185 VerifyOAuth1AccessToken(user_profile, token, secret); | |
| 1186 } | |
| 1187 | |
| 1188 void LoginUtilsImpl::OnOAuth1AccessTokenFetchFailed() { | |
| 1189 // TODO(kochi): Show failure notification UI here? | |
| 1190 LOG(ERROR) << "Failed to fetch OAuth1 access token."; | |
| 1191 g_browser_process->browser_policy_connector()->RegisterForUserPolicy( | |
| 1192 EmptyString()); | |
| 1193 } | |
| 1194 | |
| 1195 void LoginUtilsImpl::OnOAuthVerificationSucceeded( | |
| 1196 const std::string& user_name, const std::string& sid, | |
| 1197 const std::string& lsid, const std::string& auth) { | |
| 1198 // Kick off sync engine. | |
| 1199 GaiaAuthConsumer::ClientLoginResult credentials(sid, lsid, auth, | |
| 1200 std::string()); | |
| 1201 StartSignedInServices(ProfileManager::GetDefaultProfile(), credentials); | |
| 1202 } | |
| 1203 | |
| 1204 | |
| 1205 void LoginUtilsImpl::OnConnectionTypeChanged( | 989 void LoginUtilsImpl::OnConnectionTypeChanged( |
| 1206 net::NetworkChangeNotifier::ConnectionType type) { | 990 net::NetworkChangeNotifier::ConnectionType type) { |
| 1207 if (type != net::NetworkChangeNotifier::CONNECTION_NONE && | 991 if (type != net::NetworkChangeNotifier::CONNECTION_NONE && |
| 1208 UserManager::Get()->IsUserLoggedIn()) { | 992 UserManager::Get()->IsUserLoggedIn()) { |
| 1209 if (oauth_login_verifier_.get() && | 993 if (login_manager_->state() == |
| 1210 !oauth_login_verifier_->is_done()) { | 994 OAuthLoginManager::SESSION_RESTORE_IN_PROGRESS) { |
| 1211 // If we come online for the first time after successful offline login, | 995 // If we come online for the first time after successful offline login, |
| 1212 // we need to kick off OAuth token verification process again. | 996 // we need to kick off OAuth token verification process again. |
| 1213 oauth_login_verifier_->ContinueVerification(); | 997 login_manager_->ContinueSessionRestore(); |
| 1214 } else if (should_restore_auth_session_) { | 998 } else if (should_restore_auth_session_) { |
| 1215 should_restore_auth_session_ = false; | 999 should_restore_auth_session_ = false; |
| 1216 Profile* user_profile = ProfileManager::GetDefaultProfile(); | 1000 Profile* user_profile = ProfileManager::GetDefaultProfile(); |
| 1217 KickStartAuthentication(user_profile); | 1001 RestoreAuthSession(user_profile, has_web_auth_cookies_); |
| 1218 } | 1002 } |
| 1219 } | 1003 } |
| 1220 } | 1004 } |
| 1221 | 1005 |
| 1222 void LoginUtilsImpl::Observe(int type, | 1006 void LoginUtilsImpl::Observe(int type, |
| 1223 const content::NotificationSource& source, | 1007 const content::NotificationSource& source, |
| 1224 const content::NotificationDetails& details) { | 1008 const content::NotificationDetails& details) { |
| 1225 switch (type) { | 1009 switch (type) { |
| 1226 case chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED: { | 1010 case chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED: { |
| 1227 Profile* profile = content::Source<Profile>(source).ptr(); | 1011 Profile* profile = content::Source<Profile>(source).ptr(); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1251 bool LoginUtils::IsWhitelisted(const std::string& username) { | 1035 bool LoginUtils::IsWhitelisted(const std::string& username) { |
| 1252 CrosSettings* cros_settings = CrosSettings::Get(); | 1036 CrosSettings* cros_settings = CrosSettings::Get(); |
| 1253 bool allow_new_user = false; | 1037 bool allow_new_user = false; |
| 1254 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1038 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 1255 if (allow_new_user) | 1039 if (allow_new_user) |
| 1256 return true; | 1040 return true; |
| 1257 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 1041 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
| 1258 } | 1042 } |
| 1259 | 1043 |
| 1260 } // namespace chromeos | 1044 } // namespace chromeos |
| OLD | NEW |