OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/oauth2_login_verifier.h" | 5 #include "chrome/browser/chromeos/login/oauth2_login_verifier.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 90 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
91 login_token_request_ = token_service->StartRequestWithContext( | 91 login_token_request_ = token_service->StartRequestWithContext( |
92 token_service->GetPrimaryAccountId(), | 92 token_service->GetPrimaryAccountId(), |
93 system_request_context_.get(), | 93 system_request_context_.get(), |
94 scopes, | 94 scopes, |
95 this); | 95 this); |
96 } | 96 } |
97 | 97 |
98 void OAuth2LoginVerifier::StartOAuthLoginForUberToken() { | 98 void OAuth2LoginVerifier::StartOAuthLoginForUberToken() { |
99 // No service will fetch us uber auth token. | 99 // No service will fetch us uber auth token. |
100 gaia_system_fetcher_.reset( | 100 gaia_fetcher_.reset( |
101 new GaiaAuthFetcher(this, | 101 new GaiaAuthFetcher(this, |
102 std::string(GaiaConstants::kChromeOSSource), | 102 std::string(GaiaConstants::kChromeOSSource), |
103 system_request_context_.get())); | 103 user_request_context_.get())); |
104 gaia_system_fetcher_->StartTokenFetchForUberAuthExchange(access_token_); | 104 gaia_fetcher_->StartTokenFetchForUberAuthExchange(access_token_); |
105 } | 105 } |
106 | 106 |
107 | 107 |
108 void OAuth2LoginVerifier::OnUberAuthTokenSuccess( | 108 void OAuth2LoginVerifier::OnUberAuthTokenSuccess( |
109 const std::string& uber_token) { | 109 const std::string& uber_token) { |
110 LOG(INFO) << "OAuthLogin(uber_token) successful!"; | 110 LOG(INFO) << "OAuthLogin(uber_token) successful!"; |
111 retry_count_ = 0; | 111 retry_count_ = 0; |
112 gaia_token_ = uber_token; | 112 gaia_token_ = uber_token; |
113 StartMergeSession(); | 113 StartMergeSession(); |
114 } | 114 } |
115 | 115 |
116 void OAuth2LoginVerifier::OnUberAuthTokenFailure( | 116 void OAuth2LoginVerifier::OnUberAuthTokenFailure( |
117 const GoogleServiceAuthError& error) { | 117 const GoogleServiceAuthError& error) { |
118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
119 LOG(WARNING) << "OAuthLogin(uber_token) failed," | 119 LOG(WARNING) << "OAuthLogin(uber_token) failed," |
120 << " error: " << error.state(); | 120 << " error: " << error.state(); |
121 RetryOnError("OAuthLoginUberToken", error, | 121 RetryOnError("OAuthLoginUberToken", error, |
122 base::Bind(&OAuth2LoginVerifier::StartOAuthLoginForUberToken, | 122 base::Bind(&OAuth2LoginVerifier::StartOAuthLoginForUberToken, |
123 AsWeakPtr()), | 123 AsWeakPtr()), |
124 base::Bind(&Delegate::OnOAuthLoginFailure, | 124 base::Bind(&Delegate::OnOAuthLoginFailure, |
125 base::Unretained(delegate_))); | 125 base::Unretained(delegate_))); |
126 } | 126 } |
127 | 127 |
128 void OAuth2LoginVerifier::StartOAuthLoginForGaiaCredentials() { | 128 void OAuth2LoginVerifier::StartOAuthLoginForGaiaCredentials() { |
129 // No service will fetch us uber auth token. | 129 // No service will fetch us uber auth token. |
130 gaia_system_fetcher_.reset( | 130 gaia_fetcher_.reset( |
131 new GaiaAuthFetcher(this, | 131 new GaiaAuthFetcher(this, |
132 std::string(GaiaConstants::kChromeOSSource), | 132 std::string(GaiaConstants::kChromeOSSource), |
133 system_request_context_.get())); | 133 user_request_context_.get())); |
134 gaia_system_fetcher_->StartOAuthLogin(access_token_, EmptyString()); | 134 gaia_fetcher_->StartOAuthLogin(access_token_, EmptyString()); |
135 } | 135 } |
136 | 136 |
137 void OAuth2LoginVerifier::OnClientLoginSuccess( | 137 void OAuth2LoginVerifier::OnClientLoginSuccess( |
138 const ClientLoginResult& gaia_credentials) { | 138 const ClientLoginResult& gaia_credentials) { |
139 LOG(INFO) << "OAuthLogin(SID+LSID) successful!"; | 139 LOG(INFO) << "OAuthLogin(SID+LSID) successful!"; |
140 retry_count_ = 0; | 140 retry_count_ = 0; |
141 delegate_->OnOAuthLoginSuccess(gaia_credentials); | 141 delegate_->OnOAuthLoginSuccess(gaia_credentials); |
142 } | 142 } |
143 | 143 |
144 void OAuth2LoginVerifier::OnClientLoginFailure( | 144 void OAuth2LoginVerifier::OnClientLoginFailure( |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 << operation_id; | 236 << operation_id; |
237 UMA_HISTOGRAM_ENUMERATION( | 237 UMA_HISTOGRAM_ENUMERATION( |
238 base::StringPrintf("OAuth2Login.%sFailure", operation_id), | 238 base::StringPrintf("OAuth2Login.%sFailure", operation_id), |
239 error.state(), | 239 error.state(), |
240 GoogleServiceAuthError::NUM_STATES); | 240 GoogleServiceAuthError::NUM_STATES); |
241 | 241 |
242 error_handler.Run(IsConnectionOrServiceError(error)); | 242 error_handler.Run(IsConnectionOrServiceError(error)); |
243 } | 243 } |
244 | 244 |
245 } // namespace chromeos | 245 } // namespace chromeos |
OLD | NEW |