OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "chrome/browser/sync/notifier/communicator/single_login_attempt.h" | 7 #include "chrome/browser/sync/notifier/communicator/single_login_attempt.h" |
8 | 8 |
| 9 #include "base/logging.h" |
9 #include "chrome/browser/sync/notifier/communicator/connection_options.h" | 10 #include "chrome/browser/sync/notifier/communicator/connection_options.h" |
10 #include "chrome/browser/sync/notifier/communicator/connection_settings.h" | 11 #include "chrome/browser/sync/notifier/communicator/connection_settings.h" |
11 #include "chrome/browser/sync/notifier/communicator/const_communicator.h" | 12 #include "chrome/browser/sync/notifier/communicator/const_communicator.h" |
12 #include "chrome/browser/sync/notifier/communicator/login_failure.h" | 13 #include "chrome/browser/sync/notifier/communicator/login_failure.h" |
13 #include "chrome/browser/sync/notifier/communicator/login_settings.h" | 14 #include "chrome/browser/sync/notifier/communicator/login_settings.h" |
14 #include "chrome/browser/sync/notifier/communicator/product_info.h" | 15 #include "chrome/browser/sync/notifier/communicator/product_info.h" |
15 #include "chrome/browser/sync/notifier/communicator/xmpp_connection_generator.h" | 16 #include "chrome/browser/sync/notifier/communicator/xmpp_connection_generator.h" |
16 #include "chrome/browser/sync/notifier/communicator/xmpp_socket_adapter.h" | 17 #include "chrome/browser/sync/notifier/communicator/xmpp_socket_adapter.h" |
17 #include "chrome/browser/sync/notifier/gaia_auth/gaiaauth.h" | 18 #include "chrome/browser/sync/notifier/gaia_auth/gaiaauth.h" |
18 #include "talk/base/asynchttprequest.h" | 19 #include "talk/base/asynchttprequest.h" |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 SignalUnexpectedDisconnect(); | 457 SignalUnexpectedDisconnect(); |
457 return; | 458 return; |
458 } else { | 459 } else { |
459 HandleConnectionError(error, error_subcode, stream_error.get(), | 460 HandleConnectionError(error, error_subcode, stream_error.get(), |
460 captcha_challenge); | 461 captcha_challenge); |
461 } | 462 } |
462 } | 463 } |
463 | 464 |
464 void SingleLoginAttempt::HandleConnectionPasswordError( | 465 void SingleLoginAttempt::HandleConnectionPasswordError( |
465 const buzz::CaptchaChallenge& captcha_challenge) { | 466 const buzz::CaptchaChallenge& captcha_challenge) { |
466 LOG(LS_VERBOSE) << "SingleLoginAttempt::HandleConnectionPasswordError"; | 467 LOG(INFO) << "SingleLoginAttempt::HandleConnectionPasswordError"; |
467 | 468 |
468 // Clear the auth cookie. | 469 // Clear the auth cookie. |
469 std::string current_auth_cookie = | 470 std::string current_auth_cookie = |
470 login_settings_->user_settings().auth_cookie(); | 471 login_settings_->user_settings().auth_cookie(); |
471 login_settings_->modifiable_user_settings()->set_auth_cookie(""); | 472 login_settings_->modifiable_user_settings()->set_auth_cookie(""); |
472 // If there was an auth cookie and it was the same as the last auth cookie, | 473 // If there was an auth cookie and it was the same as the last auth cookie, |
473 // then it is a stale cookie. Retry login. | 474 // then it is a stale cookie. Retry login. |
474 if (!current_auth_cookie.empty() && !cookie_refreshed_) { | 475 if (!current_auth_cookie.empty() && !cookie_refreshed_) { |
475 UseCurrentConnection(); | 476 UseCurrentConnection(); |
476 return; | 477 return; |
477 } | 478 } |
478 | 479 |
479 LoginFailure failure(LoginFailure::XMPP_ERROR, code_, subcode_, | 480 LoginFailure failure(LoginFailure::XMPP_ERROR, code_, subcode_, |
480 captcha_challenge); | 481 captcha_challenge); |
481 SignalLoginFailure(failure); | 482 SignalLoginFailure(failure); |
482 } | 483 } |
483 | 484 |
484 void SingleLoginAttempt::HandleConnectionError( | 485 void SingleLoginAttempt::HandleConnectionError( |
485 buzz::XmppEngine::Error code, | 486 buzz::XmppEngine::Error code, |
486 int subcode, | 487 int subcode, |
487 const buzz::XmlElement* stream_error, | 488 const buzz::XmlElement* stream_error, |
488 const buzz::CaptchaChallenge& captcha_challenge) { | 489 const buzz::CaptchaChallenge& captcha_challenge) { |
489 LOG_F(LS_VERBOSE) << "(" << code << ", " << subcode << ")"; | 490 LOG(INFO) << "(" << code << ", " << subcode << ")"; |
490 | 491 |
491 // Save off the error code information, so we can use it to tell the user | 492 // Save off the error code information, so we can use it to tell the user |
492 // what went wrong if all else fails. | 493 // what went wrong if all else fails. |
493 code_ = code; | 494 code_ = code; |
494 subcode_ = subcode; | 495 subcode_ = subcode; |
495 if ((code_ == buzz::XmppEngine::ERROR_UNAUTHORIZED) || | 496 if ((code_ == buzz::XmppEngine::ERROR_UNAUTHORIZED) || |
496 (code_ == buzz::XmppEngine::ERROR_MISSING_USERNAME)) { | 497 (code_ == buzz::XmppEngine::ERROR_MISSING_USERNAME)) { |
497 // There was a problem with credentials (username/password). | 498 // There was a problem with credentials (username/password). |
498 HandleConnectionPasswordError(captcha_challenge); | 499 HandleConnectionPasswordError(captcha_challenge); |
499 return; | 500 return; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 ASSERT(connection_generator_.get() != NULL); | 551 ASSERT(connection_generator_.get() != NULL); |
551 if (!connection_generator_.get()) { | 552 if (!connection_generator_.get()) { |
552 return; | 553 return; |
553 } | 554 } |
554 | 555 |
555 // Iterate to the next possible connection (still trying to connect). | 556 // Iterate to the next possible connection (still trying to connect). |
556 UseNextConnection(); | 557 UseNextConnection(); |
557 } | 558 } |
558 | 559 |
559 } // namespace notifier | 560 } // namespace notifier |
OLD | NEW |