| OLD | NEW |
| 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/browser/sync/signin_manager.h" | 5 #include "chrome/browser/sync/signin_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/browser/net/gaia/token_service.h" | 9 #include "chrome/browser/net/gaia/token_service.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/sync/profile_sync_service.h" | 12 #include "chrome/browser/sync/profile_sync_service.h" |
| 13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "chrome/common/net/gaia/gaia_constants.h" | 14 #include "chrome/common/net/gaia/gaia_constants.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "content/common/notification_service.h" | 17 #include "content/common/notification_service.h" |
| 18 | 18 |
| 19 const char kGetInfoEmailKey[] = "email"; | 19 const char kGetInfoEmailKey[] = "email"; |
| 20 | 20 |
| 21 const char kSyncOAuth2Scope[] = "https://www.googleapis.com/auth/chromesync"; | |
| 22 | |
| 23 SigninManager::SigninManager() | 21 SigninManager::SigninManager() |
| 24 : profile_(NULL), had_two_factor_error_(false) {} | 22 : profile_(NULL), had_two_factor_error_(false) {} |
| 25 | 23 |
| 26 SigninManager::~SigninManager() {} | 24 SigninManager::~SigninManager() {} |
| 27 | 25 |
| 28 // static | 26 // static |
| 29 void SigninManager::RegisterUserPrefs(PrefService* user_prefs) { | 27 void SigninManager::RegisterUserPrefs(PrefService* user_prefs) { |
| 30 user_prefs->RegisterStringPref(prefs::kGoogleServicesUsername, | 28 user_prefs->RegisterStringPref(prefs::kGoogleServicesUsername, |
| 31 "", | 29 "", |
| 32 PrefService::UNSYNCABLE_PREF); | 30 PrefService::UNSYNCABLE_PREF); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 DCHECK(!profile_->GetTokenService()->AreCredentialsValid()); | 75 DCHECK(!profile_->GetTokenService()->AreCredentialsValid()); |
| 78 #endif | 76 #endif |
| 79 } | 77 } |
| 80 | 78 |
| 81 // Users must always sign out before they sign in again. | 79 // Users must always sign out before they sign in again. |
| 82 void SigninManager::StartOAuthSignIn() { | 80 void SigninManager::StartOAuthSignIn() { |
| 83 PrepareForSignin(); | 81 PrepareForSignin(); |
| 84 oauth_login_.reset(new GaiaOAuthFetcher(this, | 82 oauth_login_.reset(new GaiaOAuthFetcher(this, |
| 85 profile_->GetRequestContext(), | 83 profile_->GetRequestContext(), |
| 86 profile_, | 84 profile_, |
| 87 GaiaConstants::kSyncService, | 85 GaiaConstants::kSyncServiceOAuth)); |
| 88 kSyncOAuth2Scope)); | |
| 89 oauth_login_->StartGetOAuthToken(); | 86 oauth_login_->StartGetOAuthToken(); |
| 90 } | 87 } |
| 91 | 88 |
| 92 // Users must always sign out before they sign in again. | 89 // Users must always sign out before they sign in again. |
| 93 void SigninManager::StartSignIn(const std::string& username, | 90 void SigninManager::StartSignIn(const std::string& username, |
| 94 const std::string& password, | 91 const std::string& password, |
| 95 const std::string& login_token, | 92 const std::string& login_token, |
| 96 const std::string& login_captcha) { | 93 const std::string& login_captcha) { |
| 97 PrepareForSignin(); | 94 PrepareForSignin(); |
| 98 username_.assign(username); | 95 username_.assign(username); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 VLOG(1) << "SigninManager::OnOAuthGetAccessTokenFailure"; | 235 VLOG(1) << "SigninManager::OnOAuthGetAccessTokenFailure"; |
| 239 } | 236 } |
| 240 | 237 |
| 241 void SigninManager::OnOAuthWrapBridgeSuccess(const std::string& service_name, | 238 void SigninManager::OnOAuthWrapBridgeSuccess(const std::string& service_name, |
| 242 const std::string& token, | 239 const std::string& token, |
| 243 const std::string& expires_in) { | 240 const std::string& expires_in) { |
| 244 VLOG(1) << "SigninManager::OnOAuthWrapBridgeSuccess"; | 241 VLOG(1) << "SigninManager::OnOAuthWrapBridgeSuccess"; |
| 245 } | 242 } |
| 246 | 243 |
| 247 void SigninManager::OnOAuthWrapBridgeFailure( | 244 void SigninManager::OnOAuthWrapBridgeFailure( |
| 245 const std::string& service_scope, |
| 248 const GoogleServiceAuthError& error) { | 246 const GoogleServiceAuthError& error) { |
| 249 VLOG(1) << "SigninManager::OnOAuthWrapBridgeFailure"; | 247 VLOG(1) << "SigninManager::OnOAuthWrapBridgeFailure"; |
| 250 } | 248 } |
| 251 | 249 |
| 252 void SigninManager::OnUserInfoSuccess(const std::string& email) { | 250 void SigninManager::OnUserInfoSuccess(const std::string& email) { |
| 253 VLOG(1) << "SigninManager::OnUserInfoSuccess(\"" << email << "\")"; | 251 VLOG(1) << "SigninManager::OnUserInfoSuccess(\"" << email << "\")"; |
| 254 } | 252 } |
| 255 | 253 |
| 256 void SigninManager::OnUserInfoFailure(const GoogleServiceAuthError& error) { | 254 void SigninManager::OnUserInfoFailure(const GoogleServiceAuthError& error) { |
| 257 VLOG(1) << "SigninManager::OnUserInfoFailure"; | 255 VLOG(1) << "SigninManager::OnUserInfoFailure"; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 274 profile_->GetRequestContext())); | 272 profile_->GetRequestContext())); |
| 275 } | 273 } |
| 276 | 274 |
| 277 client_login_->StartTokenAuth(tok_details->token()); | 275 client_login_->StartTokenAuth(tok_details->token()); |
| 278 | 276 |
| 279 // We only want to do this once per sign-in. | 277 // We only want to do this once per sign-in. |
| 280 CleanupNotificationRegistration(); | 278 CleanupNotificationRegistration(); |
| 281 } | 279 } |
| 282 #endif | 280 #endif |
| 283 } | 281 } |
| OLD | NEW |