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

Side by Side Diff: chrome/browser/chromeos/login/login_utils.cc

Issue 10008079: [cros] Use system request context for OAuth1 access token verification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use system request context Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <vector> 7 #include <vector>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 virtual void OnUserCookiesFetchFailed(const std::string& user_name) {} 195 virtual void OnUserCookiesFetchFailed(const std::string& user_name) {}
196 }; 196 };
197 197
198 OAuthLoginVerifier(OAuthLoginVerifier::Delegate* delegate, 198 OAuthLoginVerifier(OAuthLoginVerifier::Delegate* delegate,
199 Profile* user_profile, 199 Profile* user_profile,
200 const std::string& oauth1_token, 200 const std::string& oauth1_token,
201 const std::string& oauth1_secret, 201 const std::string& oauth1_secret,
202 const std::string& username) 202 const std::string& username)
203 : delegate_(delegate), 203 : delegate_(delegate),
204 oauth_fetcher_(this, 204 oauth_fetcher_(this,
205 user_profile->GetOffTheRecordProfile()->GetRequestContext(), 205 g_browser_process->system_request_context(),
Nikita (slow) 2012/04/13 12:45:55 Zel, what was the reason why we initially were usi
206 user_profile->GetOffTheRecordProfile(), 206 user_profile->GetOffTheRecordProfile(),
207 kServiceScopeChromeOS), 207 kServiceScopeChromeOS),
208 gaia_fetcher_(this, 208 gaia_fetcher_(this,
209 std::string(GaiaConstants::kChromeOSSource), 209 std::string(GaiaConstants::kChromeOSSource),
210 user_profile->GetRequestContext()), 210 user_profile->GetRequestContext()),
211 oauth1_token_(oauth1_token), 211 oauth1_token_(oauth1_token),
212 oauth1_secret_(oauth1_secret), 212 oauth1_secret_(oauth1_secret),
213 username_(username), 213 username_(username),
214 user_profile_(user_profile), 214 user_profile_(user_profile),
215 verification_count_(0), 215 verification_count_(0),
216 step_(VERIFICATION_STEP_UNVERIFIED) { 216 step_(VERIFICATION_STEP_UNVERIFIED) {
217 } 217 }
218 virtual ~OAuthLoginVerifier() {} 218 virtual ~OAuthLoginVerifier() {}
219 219
220 bool is_done() { 220 bool is_done() {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 void StartCookiesRetreival() { 285 void StartCookiesRetreival() {
286 DCHECK(!sid_.empty()); 286 DCHECK(!sid_.empty());
287 DCHECK(!lsid_.empty()); 287 DCHECK(!lsid_.empty());
288 gaia_fetcher_.StartIssueAuthToken(sid_, lsid_, GaiaConstants::kGaiaService); 288 gaia_fetcher_.StartIssueAuthToken(sid_, lsid_, GaiaConstants::kGaiaService);
289 } 289 }
290 290
291 // Decides how to proceed on GAIA response and other errors. It can schedule 291 // Decides how to proceed on GAIA response and other errors. It can schedule
292 // to rerun the verification process if detects transient network or service 292 // to rerun the verification process if detects transient network or service
293 // errors. 293 // errors.
294 bool RetryOnError(const GoogleServiceAuthError& error) { 294 bool RetryOnError(const GoogleServiceAuthError& error) {
295 // If we can't connect to GAIA due to network or service related reasons,
296 // we should attempt OAuth token verification again.
297 if (error.state() == GoogleServiceAuthError::CONNECTION_FAILED || 295 if (error.state() == GoogleServiceAuthError::CONNECTION_FAILED ||
298 error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE) { 296 error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE ||
297 error.state() == GoogleServiceAuthError::REQUEST_CANCELED) {
299 if (verification_count_ < kMaxOAuthTokenVerificationAttemptCount) { 298 if (verification_count_ < kMaxOAuthTokenVerificationAttemptCount) {
300 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, 299 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE,
301 base::Bind(&OAuthLoginVerifier::ContinueVerification, AsWeakPtr()), 300 base::Bind(&OAuthLoginVerifier::ContinueVerification, AsWeakPtr()),
302 kOAuthVerificationRestartDelay); 301 kOAuthVerificationRestartDelay);
303 return true; 302 return true;
304 } 303 }
305 } 304 }
306 step_ = VERIFICATION_STEP_FAILED; 305 step_ = VERIFICATION_STEP_FAILED;
307 return false; 306 return false;
308 } 307 }
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 bool LoginUtils::IsWhitelisted(const std::string& username) { 1441 bool LoginUtils::IsWhitelisted(const std::string& username) {
1443 CrosSettings* cros_settings = CrosSettings::Get(); 1442 CrosSettings* cros_settings = CrosSettings::Get();
1444 bool allow_new_user = false; 1443 bool allow_new_user = false;
1445 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 1444 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
1446 if (allow_new_user) 1445 if (allow_new_user)
1447 return true; 1446 return true;
1448 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); 1447 return cros_settings->FindEmailInList(kAccountsPrefUsers, username);
1449 } 1448 }
1450 1449
1451 } // namespace chromeos 1450 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698