Chromium Code Reviews| Index: chrome/browser/chromeos/login/login_utils.cc |
| diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc |
| index ad8da19133e170798d0bb0f04218bb1e029fe6a5..d1e735b4f075d55f34705f13dd3a95e2f091a492 100644 |
| --- a/chrome/browser/chromeos/login/login_utils.cc |
| +++ b/chrome/browser/chromeos/login/login_utils.cc |
| @@ -107,7 +107,8 @@ class LoginUtilsImpl : public LoginUtils { |
| virtual void CompleteLogin( |
| const std::string& username, |
| const std::string& password, |
| - const GaiaAuthConsumer::ClientLoginResult& credentials); |
| + const GaiaAuthConsumer::ClientLoginResult& credentials, |
| + bool pending_requests); |
| // Invoked after the tmpfs is successfully mounted. |
| // Launches a browser in the off the record (incognito) mode. |
| @@ -131,6 +132,17 @@ class LoginUtilsImpl : public LoginUtils { |
| // Warms the url used by authentication. |
| virtual void PrewarmAuthentication(); |
| + // Given the credentials try to exchange them for |
| + // full-fledged Google authentication cookies. |
| + virtual void FetchCookies( |
| + Profile* profile, |
| + const GaiaAuthConsumer::ClientLoginResult& credentials); |
| + |
| + // Supply credentials for sync and others to use. |
| + virtual void FetchTokens( |
| + Profile* profile, |
| + const GaiaAuthConsumer::ClientLoginResult& credentials); |
| + |
| private: |
| // Check user's profile for kApplicationLocale setting. |
| void RespectLocalePreference(PrefService* pref); |
| @@ -166,7 +178,8 @@ class LoginUtilsWrapper { |
| void LoginUtilsImpl::CompleteLogin( |
| const std::string& username, |
| const std::string& password, |
| - const GaiaAuthConsumer::ClientLoginResult& credentials) { |
| + const GaiaAuthConsumer::ClientLoginResult& credentials, |
| + bool pending_requests) { |
| BootTimesLoader* btl = BootTimesLoader::Get(); |
| VLOG(1) << "Completing login for " << username; |
| @@ -217,15 +230,13 @@ void LoginUtilsImpl::CompleteLogin( |
| new ResetDefaultProxyConfigServiceTask( |
| proxy_config_service)); |
| - // Take the credentials passed in and try to exchange them for |
| - // full-fledged Google authentication cookies. This is |
| - // best-effort; it's possible that we'll fail due to network |
| - // troubles or some such. Either way, |cf| will call |
| - // DoBrowserLaunch on the UI thread when it's done, and then |
| - // delete itself. |
| - CookieFetcher* cf = new CookieFetcher(profile); |
| - cf->AttemptFetch(credentials.data); |
| - btl->AddLoginTimeMarker("CookieFetchStarted", false); |
| + // Since we're doing parallel authentication, only new user sign in |
| + // would perform online auth before calling CompleteLogin. |
| + // For existing users there's usually a pending online auth request. |
| + // Cookies will be fetched after it's is succeeded. |
| + if (!pending_requests) { |
|
Nikita (slow)
2010/12/03 16:52:42
Note:
When network is not connected, only online a
Nikita (slow)
2010/12/03 16:53:25
only offline auth would pass and pending_requests
Chris Masone
2010/12/03 18:47:38
They would not work, no. I'm pretty sure they're
|
| + FetchCookies(profile, credentials); |
| + } |
| // Init extension event routers; this normally happens in browser_main |
| // but on Chrome OS it has to be deferred until the user finishes |
| @@ -241,9 +252,11 @@ void LoginUtilsImpl::CompleteLogin( |
| token_service->Initialize(GaiaConstants::kChromeOSSource, |
| profile); |
| token_service->LoadTokensFromDB(); |
| - token_service->UpdateCredentials(credentials); |
| - if (token_service->AreCredentialsValid()) { |
| - token_service->StartFetchingTokens(); |
| + |
| + // For existing users there's usually a pending online auth request. |
| + // Tokens will be fetched after it's is succeeded. |
| + if (!pending_requests) { |
| + FetchTokens(profile, credentials); |
| } |
| btl->AddLoginTimeMarker("TokensGotten", false); |
| @@ -287,6 +300,29 @@ void LoginUtilsImpl::CompleteLogin( |
| DoBrowserLaunch(profile); |
| } |
| +void LoginUtilsImpl::FetchCookies( |
| + Profile* profile, |
| + const GaiaAuthConsumer::ClientLoginResult& credentials) { |
| + // Take the credentials passed in and try to exchange them for |
| + // full-fledged Google authentication cookies. This is |
| + // best-effort; it's possible that we'll fail due to network |
| + // troubles or some such. |
| + // CookieFetcher will delete itself once done. |
| + CookieFetcher* cf = new CookieFetcher(profile); |
| + cf->AttemptFetch(credentials.data); |
| + BootTimesLoader::Get()->AddLoginTimeMarker("CookieFetchStarted", false); |
| +} |
| + |
| +void LoginUtilsImpl::FetchTokens( |
| + Profile* profile, |
| + const GaiaAuthConsumer::ClientLoginResult& credentials) { |
| + TokenService* token_service = profile->GetTokenService(); |
| + token_service->UpdateCredentials(credentials); |
| + if (token_service->AreCredentialsValid()) { |
| + token_service->StartFetchingTokens(); |
| + } |
| +} |
| + |
| void LoginUtilsImpl::RespectLocalePreference(PrefService* pref) { |
| std::string pref_locale = pref->GetString(prefs::kApplicationLocale); |
| if (pref_locale.empty()) { |