| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 "chrome/browser/sync/engine/authenticator.h" | 5 #include "chrome/browser/sync/engine/authenticator.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/engine/net/gaia_authenticator.h" | 7 #include "chrome/browser/sync/engine/net/gaia_authenticator.h" |
| 8 #include "chrome/browser/sync/engine/net/server_connection_manager.h" | 8 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
| 9 #include "chrome/browser/sync/engine/syncproto.h" | 9 #include "chrome/browser/sync/engine/syncproto.h" |
| 10 #include "chrome/browser/sync/protocol/sync.pb.h" | 10 #include "chrome/browser/sync/protocol/sync.pb.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // TODO(sync): Pull and work with saved credentials. | 28 // TODO(sync): Pull and work with saved credentials. |
| 29 return NO_SAVED_CREDENTIALS; | 29 return NO_SAVED_CREDENTIALS; |
| 30 } | 30 } |
| 31 | 31 |
| 32 Authenticator::AuthenticationResult Authenticator::Authenticate( | 32 Authenticator::AuthenticationResult Authenticator::Authenticate( |
| 33 string username, string password, bool save_credentials) { | 33 string username, string password, bool save_credentials) { |
| 34 // TODO(sync): need to figure out if this routine is used anywhere other | 34 // TODO(sync): need to figure out if this routine is used anywhere other |
| 35 // than the test code. | 35 // than the test code. |
| 36 GaiaAuthenticator auth_service("ChromiumBrowser", "chromiumsync", | 36 GaiaAuthenticator auth_service("ChromiumBrowser", "chromiumsync", |
| 37 "https://www.google.com:443/accounts/ClientLogin"); | 37 "https://www.google.com:443/accounts/ClientLogin"); |
| 38 auth_service.set_message_loop(MessageLoop::current()); |
| 38 const SignIn signin_type = | 39 const SignIn signin_type = |
| 39 settings_->RecallSigninType(username, GMAIL_SIGNIN); | 40 settings_->RecallSigninType(username, GMAIL_SIGNIN); |
| 40 if (!auth_service.Authenticate(username, password, SAVE_IN_MEMORY_ONLY, | 41 if (!auth_service.Authenticate(username, password, SAVE_IN_MEMORY_ONLY, |
| 41 true, signin_type)) { | 42 signin_type)) { |
| 42 return UNSPECIFIC_ERROR_RETURN; | 43 return UNSPECIFIC_ERROR_RETURN; |
| 43 } | 44 } |
| 44 CHECK(!auth_service.auth_token().empty()); | 45 CHECK(!auth_service.auth_token().empty()); |
| 45 return AuthenticateToken(auth_service.auth_token()); | 46 return AuthenticateToken(auth_service.auth_token()); |
| 46 } | 47 } |
| 47 | 48 |
| 48 COMPILE_ASSERT(sync_pb::ClientToServerResponse::ERROR_TYPE_MAX == 6, | 49 COMPILE_ASSERT(sync_pb::ClientToServerResponse::ERROR_TYPE_MAX == 6, |
| 49 client_to_server_response_errors_changed); | 50 client_to_server_response_errors_changed); |
| 50 | 51 |
| 51 Authenticator::AuthenticationResult Authenticator::HandleSuccessfulTokenRequest( | 52 Authenticator::AuthenticationResult Authenticator::HandleSuccessfulTokenRequest( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // should never happen (only for stores). | 98 // should never happen (only for stores). |
| 98 case sync_pb::ClientToServerResponse::ACCESS_DENIED: | 99 case sync_pb::ClientToServerResponse::ACCESS_DENIED: |
| 99 default: | 100 default: |
| 100 LOG(ERROR) << "Corrupt Server packet received by auth, error code " << | 101 LOG(ERROR) << "Corrupt Server packet received by auth, error code " << |
| 101 response.error_code(); | 102 response.error_code(); |
| 102 return CORRUPT_SERVER_RESPONSE; | 103 return CORRUPT_SERVER_RESPONSE; |
| 103 } | 104 } |
| 104 } | 105 } |
| 105 | 106 |
| 106 } // namespace browser_sync | 107 } // namespace browser_sync |
| OLD | NEW |