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

Side by Side Diff: chrome/common/net/gaia/gaia_auth_fetcher.cc

Issue 8368018: Convert chrome/common non-debug logs to debug logs. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/common/net/gaia/gaia_auth_fetcher.h" 5 #include "chrome/common/net/gaia/gaia_auth_fetcher.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 const std::string& password, 298 const std::string& password,
299 const char* const service, 299 const char* const service,
300 const std::string& login_token, 300 const std::string& login_token,
301 const std::string& login_captcha, 301 const std::string& login_captcha,
302 HostedAccountsSetting allow_hosted_accounts) { 302 HostedAccountsSetting allow_hosted_accounts) {
303 303
304 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; 304 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!";
305 305
306 // This class is thread agnostic, so be sure to call this only on the 306 // This class is thread agnostic, so be sure to call this only on the
307 // same thread each time. 307 // same thread each time.
308 VLOG(1) << "Starting new ClientLogin fetch for:" << username; 308 DVLOG(1) << "Starting new ClientLogin fetch for:" << username;
309 309
310 // Must outlive fetcher_. 310 // Must outlive fetcher_.
311 request_body_ = MakeClientLoginBody(username, 311 request_body_ = MakeClientLoginBody(username,
312 password, 312 password,
313 source_, 313 source_,
314 service, 314 service,
315 login_token, 315 login_token,
316 login_captcha, 316 login_captcha,
317 allow_hosted_accounts); 317 allow_hosted_accounts);
318 fetcher_.reset(CreateGaiaFetcher(getter_, 318 fetcher_.reset(CreateGaiaFetcher(getter_,
319 request_body_, 319 request_body_,
320 client_login_gurl_, 320 client_login_gurl_,
321 false, 321 false,
322 this)); 322 this));
323 fetch_pending_ = true; 323 fetch_pending_ = true;
324 fetcher_->Start(); 324 fetcher_->Start();
325 } 325 }
326 326
327 void GaiaAuthFetcher::StartIssueAuthToken(const std::string& sid, 327 void GaiaAuthFetcher::StartIssueAuthToken(const std::string& sid,
328 const std::string& lsid, 328 const std::string& lsid,
329 const char* const service) { 329 const char* const service) {
330 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; 330 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!";
331 331
332 VLOG(1) << "Starting IssueAuthToken for: " << service; 332 DVLOG(1) << "Starting IssueAuthToken for: " << service;
333 requested_service_ = service; 333 requested_service_ = service;
334 request_body_ = MakeIssueAuthTokenBody(sid, lsid, service); 334 request_body_ = MakeIssueAuthTokenBody(sid, lsid, service);
335 fetcher_.reset(CreateGaiaFetcher(getter_, 335 fetcher_.reset(CreateGaiaFetcher(getter_,
336 request_body_, 336 request_body_,
337 issue_auth_token_gurl_, 337 issue_auth_token_gurl_,
338 false, 338 false,
339 this)); 339 this));
340 fetch_pending_ = true; 340 fetch_pending_ = true;
341 fetcher_->Start(); 341 fetcher_->Start();
342 } 342 }
343 343
344 void GaiaAuthFetcher::StartGetUserInfo(const std::string& lsid, 344 void GaiaAuthFetcher::StartGetUserInfo(const std::string& lsid,
345 const std::string& info_key) { 345 const std::string& info_key) {
346 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; 346 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!";
347 347
348 VLOG(1) << "Starting GetUserInfo for lsid=" << lsid; 348 DVLOG(1) << "Starting GetUserInfo for lsid=" << lsid;
349 request_body_ = MakeGetUserInfoBody(lsid); 349 request_body_ = MakeGetUserInfoBody(lsid);
350 fetcher_.reset(CreateGaiaFetcher(getter_, 350 fetcher_.reset(CreateGaiaFetcher(getter_,
351 request_body_, 351 request_body_,
352 get_user_info_gurl_, 352 get_user_info_gurl_,
353 false, 353 false,
354 this)); 354 this));
355 fetch_pending_ = true; 355 fetch_pending_ = true;
356 requested_info_key_ = info_key; 356 requested_info_key_ = info_key;
357 fetcher_->Start(); 357 fetcher_->Start();
358 } 358 }
359 359
360 void GaiaAuthFetcher::StartTokenAuth(const std::string& auth_token) { 360 void GaiaAuthFetcher::StartTokenAuth(const std::string& auth_token) {
361 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; 361 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!";
362 362
363 VLOG(1) << "Starting TokenAuth with auth_token=" << auth_token; 363 DVLOG(1) << "Starting TokenAuth with auth_token=" << auth_token;
364 364
365 // The continue URL is a required parameter of the TokenAuth API, but in this 365 // The continue URL is a required parameter of the TokenAuth API, but in this
366 // case we don't actually need or want to navigate to it. Setting it to 366 // case we don't actually need or want to navigate to it. Setting it to
367 // an arbitrary Google URL. 367 // an arbitrary Google URL.
368 std::string continue_url("http://www.google.com"); 368 std::string continue_url("http://www.google.com");
369 request_body_ = MakeTokenAuthBody(auth_token, continue_url, source_); 369 request_body_ = MakeTokenAuthBody(auth_token, continue_url, source_);
370 fetcher_.reset(CreateGaiaFetcher(getter_, 370 fetcher_.reset(CreateGaiaFetcher(getter_,
371 request_body_, 371 request_body_,
372 token_auth_gurl_, 372 token_auth_gurl_,
373 false, 373 false,
374 this)); 374 this));
375 fetch_pending_ = true; 375 fetch_pending_ = true;
376 fetcher_->Start(); 376 fetcher_->Start();
377 } 377 }
378 378
379 void GaiaAuthFetcher::StartMergeSession(const std::string& auth_token) { 379 void GaiaAuthFetcher::StartMergeSession(const std::string& auth_token) {
380 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; 380 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!";
381 381
382 VLOG(1) << "Starting MergeSession with auth_token=" << auth_token; 382 DVLOG(1) << "Starting MergeSession with auth_token=" << auth_token;
383 383
384 // The continue URL is a required parameter of the MergeSession API, but in 384 // The continue URL is a required parameter of the MergeSession API, but in
385 // this case we don't actually need or want to navigate to it. Setting it to 385 // this case we don't actually need or want to navigate to it. Setting it to
386 // an arbitrary Google URL. 386 // an arbitrary Google URL.
387 // 387 //
388 // In order for the new session to be merged correctly, the server needs to 388 // In order for the new session to be merged correctly, the server needs to
389 // know what sessions already exist in the browser. The fetcher needs to be 389 // know what sessions already exist in the browser. The fetcher needs to be
390 // created such that it sends the cookies with the request, which is 390 // created such that it sends the cookies with the request, which is
391 // different from all other requests the fetcher can make. 391 // different from all other requests the fetcher can make.
392 std::string continue_url("http://www.google.com"); 392 std::string continue_url("http://www.google.com");
393 request_body_ = MakeMergeSessionBody(auth_token, continue_url, source_); 393 request_body_ = MakeMergeSessionBody(auth_token, continue_url, source_);
394 fetcher_.reset(CreateGaiaFetcher(getter_, 394 fetcher_.reset(CreateGaiaFetcher(getter_,
395 request_body_, 395 request_body_,
396 merge_session_gurl_, 396 merge_session_gurl_,
397 true, 397 true,
398 this)); 398 this));
399 fetch_pending_ = true; 399 fetch_pending_ = true;
400 fetcher_->Start(); 400 fetcher_->Start();
401 } 401 }
402 402
403 // static 403 // static
404 GoogleServiceAuthError GaiaAuthFetcher::GenerateAuthError( 404 GoogleServiceAuthError GaiaAuthFetcher::GenerateAuthError(
405 const std::string& data, 405 const std::string& data,
406 const net::URLRequestStatus& status) { 406 const net::URLRequestStatus& status) {
407 if (!status.is_success()) { 407 if (!status.is_success()) {
408 if (status.status() == net::URLRequestStatus::CANCELED) { 408 if (status.status() == net::URLRequestStatus::CANCELED) {
409 return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED); 409 return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED);
410 } else { 410 } else {
411 LOG(WARNING) << "Could not reach Google Accounts servers: errno " 411 DLOG(WARNING) << "Could not reach Google Accounts servers: errno "
412 << status.error(); 412 << status.error();
413 return GoogleServiceAuthError::FromConnectionError(status.error()); 413 return GoogleServiceAuthError::FromConnectionError(status.error());
414 } 414 }
415 } else { 415 } else {
416 if (IsSecondFactorSuccess(data)) { 416 if (IsSecondFactorSuccess(data)) {
417 return GoogleServiceAuthError(GoogleServiceAuthError::TWO_FACTOR); 417 return GoogleServiceAuthError(GoogleServiceAuthError::TWO_FACTOR);
418 } 418 }
419 419
420 std::string error; 420 std::string error;
421 std::string url; 421 std::string url;
422 std::string captcha_url; 422 std::string captcha_url;
423 std::string captcha_token; 423 std::string captcha_token;
424 ParseClientLoginFailure(data, &error, &url, &captcha_url, &captcha_token); 424 ParseClientLoginFailure(data, &error, &url, &captcha_url, &captcha_token);
425 LOG(WARNING) << "ClientLogin failed with " << error; 425 DLOG(WARNING) << "ClientLogin failed with " << error;
426 426
427 if (error == kCaptchaError) { 427 if (error == kCaptchaError) {
428 GURL image_url( 428 GURL image_url(
429 GaiaUrls::GetInstance()->captcha_url_prefix() + captcha_url); 429 GaiaUrls::GetInstance()->captcha_url_prefix() + captcha_url);
430 GURL unlock_url(url); 430 GURL unlock_url(url);
431 return GoogleServiceAuthError::FromCaptchaChallenge( 431 return GoogleServiceAuthError::FromCaptchaChallenge(
432 captcha_token, image_url, unlock_url); 432 captcha_token, image_url, unlock_url);
433 } 433 }
434 if (error == kAccountDeletedError) 434 if (error == kAccountDeletedError)
435 return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DELETED); 435 return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DELETED);
436 if (error == kAccountDisabledError) 436 if (error == kAccountDisabledError)
437 return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DISABLED); 437 return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DISABLED);
438 if (error == kBadAuthenticationError) { 438 if (error == kBadAuthenticationError) {
439 return GoogleServiceAuthError( 439 return GoogleServiceAuthError(
440 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 440 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
441 } 441 }
442 if (error == kServiceUnavailableError) { 442 if (error == kServiceUnavailableError) {
443 return GoogleServiceAuthError( 443 return GoogleServiceAuthError(
444 GoogleServiceAuthError::SERVICE_UNAVAILABLE); 444 GoogleServiceAuthError::SERVICE_UNAVAILABLE);
445 } 445 }
446 446
447 LOG(WARNING) << "Incomprehensible response from Google Accounts servers."; 447 DLOG(WARNING) << "Incomprehensible response from Google Accounts servers.";
448 return GoogleServiceAuthError( 448 return GoogleServiceAuthError(
449 GoogleServiceAuthError::SERVICE_UNAVAILABLE); 449 GoogleServiceAuthError::SERVICE_UNAVAILABLE);
450 } 450 }
451 451
452 NOTREACHED(); 452 NOTREACHED();
453 return GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE); 453 return GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE);
454 } 454 }
455 455
456 // static 456 // static
457 GoogleServiceAuthError GaiaAuthFetcher::GenerateOAuthLoginError( 457 GoogleServiceAuthError GaiaAuthFetcher::GenerateOAuthLoginError(
458 const std::string& data, 458 const std::string& data,
459 const net::URLRequestStatus& status) { 459 const net::URLRequestStatus& status) {
460 if (!status.is_success()) { 460 if (!status.is_success()) {
461 if (status.status() == net::URLRequestStatus::CANCELED) { 461 if (status.status() == net::URLRequestStatus::CANCELED) {
462 return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED); 462 return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED);
463 } else { 463 } else {
464 LOG(WARNING) << "Could not reach Google Accounts servers: errno " 464 DLOG(WARNING) << "Could not reach Google Accounts servers: errno "
465 << status.error(); 465 << status.error();
466 return GoogleServiceAuthError::FromConnectionError(status.error()); 466 return GoogleServiceAuthError::FromConnectionError(status.error());
467 } 467 }
468 } else { 468 } else {
469 if (IsSecondFactorSuccess(data)) { 469 if (IsSecondFactorSuccess(data)) {
470 return GoogleServiceAuthError(GoogleServiceAuthError::TWO_FACTOR); 470 return GoogleServiceAuthError(GoogleServiceAuthError::TWO_FACTOR);
471 } 471 }
472 472
473 std::string error; 473 std::string error;
474 std::string url; 474 std::string url;
(...skipping 15 matching lines...) Expand all
490 return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DISABLED); 490 return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DISABLED);
491 if (error == kBadAuthenticationErrorCode) { 491 if (error == kBadAuthenticationErrorCode) {
492 return GoogleServiceAuthError( 492 return GoogleServiceAuthError(
493 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 493 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
494 } 494 }
495 if (error == kServiceUnavailableErrorCode) { 495 if (error == kServiceUnavailableErrorCode) {
496 return GoogleServiceAuthError( 496 return GoogleServiceAuthError(
497 GoogleServiceAuthError::SERVICE_UNAVAILABLE); 497 GoogleServiceAuthError::SERVICE_UNAVAILABLE);
498 } 498 }
499 499
500 LOG(WARNING) << "Incomprehensible response from Google Accounts servers."; 500 DLOG(WARNING) << "Incomprehensible response from Google Accounts servers.";
501 return GoogleServiceAuthError( 501 return GoogleServiceAuthError(
502 GoogleServiceAuthError::SERVICE_UNAVAILABLE); 502 GoogleServiceAuthError::SERVICE_UNAVAILABLE);
503 } 503 }
504 504
505 NOTREACHED(); 505 NOTREACHED();
506 return GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE); 506 return GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE);
507 } 507 }
508 508
509 void GaiaAuthFetcher::OnClientLoginFetched(const std::string& data, 509 void GaiaAuthFetcher::OnClientLoginFetched(const std::string& data,
510 const net::URLRequestStatus& status, 510 const net::URLRequestStatus& status,
511 int response_code) { 511 int response_code) {
512 if (status.is_success() && response_code == RC_REQUEST_OK) { 512 if (status.is_success() && response_code == RC_REQUEST_OK) {
513 VLOG(1) << "ClientLogin successful!"; 513 DVLOG(1) << "ClientLogin successful!";
514 std::string sid; 514 std::string sid;
515 std::string lsid; 515 std::string lsid;
516 std::string token; 516 std::string token;
517 ParseClientLoginResponse(data, &sid, &lsid, &token); 517 ParseClientLoginResponse(data, &sid, &lsid, &token);
518 consumer_->OnClientLoginSuccess( 518 consumer_->OnClientLoginSuccess(
519 GaiaAuthConsumer::ClientLoginResult(sid, lsid, token, data)); 519 GaiaAuthConsumer::ClientLoginResult(sid, lsid, token, data));
520 } else { 520 } else {
521 consumer_->OnClientLoginFailure(GenerateAuthError(data, status)); 521 consumer_->OnClientLoginFailure(GenerateAuthError(data, status));
522 } 522 }
523 } 523 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 NOTREACHED(); 603 NOTREACHED();
604 } 604 }
605 } 605 }
606 606
607 // static 607 // static
608 bool GaiaAuthFetcher::IsSecondFactorSuccess( 608 bool GaiaAuthFetcher::IsSecondFactorSuccess(
609 const std::string& alleged_error) { 609 const std::string& alleged_error) {
610 return alleged_error.find(kSecondFactor) != 610 return alleged_error.find(kSecondFactor) !=
611 std::string::npos; 611 std::string::npos;
612 } 612 }
OLDNEW
« no previous file with comments | « chrome/common/multi_process_lock_win.cc ('k') | chrome/common/net/x509_certificate_model_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698