| 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/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "chrome/browser/net/gaia/token_service.h" | 8 #include "chrome/browser/net/gaia/token_service.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/net/gaia/gaia_constants.h" | 11 #include "chrome/common/net/gaia/gaia_constants.h" |
| 12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 13 #include "content/common/notification_service.h" | 13 #include "content/common/notification_service.h" |
| 14 | 14 |
| 15 const char kGetInfoEmailKey[] = "email"; | 15 const char kGetInfoEmailKey[] = "email"; |
| 16 | 16 |
| 17 SigninManager::SigninManager() | 17 SigninManager::SigninManager() |
| 18 : profile_(NULL), had_two_factor_error_(false) {} | 18 : profile_(NULL), had_two_factor_error_(false) {} |
| 19 | 19 |
| 20 SigninManager::~SigninManager() {} | 20 SigninManager::~SigninManager() {} |
| 21 | 21 |
| 22 // static | 22 // static |
| 23 void SigninManager::RegisterUserPrefs(PrefService* user_prefs) { | 23 void SigninManager::RegisterUserPrefs(PrefService* user_prefs) { |
| 24 user_prefs->RegisterStringPref(prefs::kGoogleServicesUsername, ""); | 24 user_prefs->RegisterStringPref(prefs::kGoogleServicesUsername, |
| 25 "", |
| 26 PrefService::UNSYNCABLE_PREF); |
| 25 } | 27 } |
| 26 | 28 |
| 27 void SigninManager::Initialize(Profile* profile) { | 29 void SigninManager::Initialize(Profile* profile) { |
| 28 profile_ = profile; | 30 profile_ = profile; |
| 29 username_ = profile_->GetPrefs()->GetString(prefs::kGoogleServicesUsername); | 31 username_ = profile_->GetPrefs()->GetString(prefs::kGoogleServicesUsername); |
| 30 profile_->GetTokenService()->Initialize( | 32 profile_->GetTokenService()->Initialize( |
| 31 GaiaConstants::kChromeSource, profile_); | 33 GaiaConstants::kChromeSource, profile_); |
| 32 if (!username_.empty()) { | 34 if (!username_.empty()) { |
| 33 profile_->GetTokenService()->LoadTokensFromDB(); | 35 profile_->GetTokenService()->LoadTokensFromDB(); |
| 34 } | 36 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 bool invalid_gaia = error.state() == | 154 bool invalid_gaia = error.state() == |
| 153 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS; | 155 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS; |
| 154 if (error.state() == GoogleServiceAuthError::TWO_FACTOR || | 156 if (error.state() == GoogleServiceAuthError::TWO_FACTOR || |
| 155 (had_two_factor_error_ && invalid_gaia)) { | 157 (had_two_factor_error_ && invalid_gaia)) { |
| 156 had_two_factor_error_ = true; | 158 had_two_factor_error_ = true; |
| 157 return; | 159 return; |
| 158 } | 160 } |
| 159 | 161 |
| 160 SignOut(); | 162 SignOut(); |
| 161 } | 163 } |
| OLD | NEW |