| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/signin/signin_tracker.h" | 5 #include "chrome/browser/signin/signin_tracker.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/signin/signin_manager.h" | 8 #include "chrome/browser/signin/signin_manager.h" |
| 9 #include "chrome/browser/signin/signin_manager_factory.h" | 9 #include "chrome/browser/signin/signin_manager_factory.h" |
| 10 #include "chrome/browser/signin/token_service.h" | 10 #include "chrome/browser/signin/token_service.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // static | 165 // static |
| 166 bool SigninTracker::AreServicesSignedIn(Profile* profile) { | 166 bool SigninTracker::AreServicesSignedIn(Profile* profile) { |
| 167 if (!AreServiceTokensLoaded(profile)) | 167 if (!AreServiceTokensLoaded(profile)) |
| 168 return false; | 168 return false; |
| 169 // Don't care about the sync state if sync is disabled by policy. | 169 // Don't care about the sync state if sync is disabled by policy. |
| 170 if (!profile->IsSyncAccessible()) | 170 if (!profile->IsSyncAccessible()) |
| 171 return true; | 171 return true; |
| 172 ProfileSyncService* service = | 172 ProfileSyncService* service = |
| 173 ProfileSyncServiceFactory::GetForProfile(profile); | 173 ProfileSyncServiceFactory::GetForProfile(profile); |
| 174 return (service->IsSyncEnabledAndLoggedIn() && | 174 return (service->IsSyncEnabledAndLoggedIn() && |
| 175 service->IsSyncTokenAvailable() && | 175 service->IsOAuthRefreshTokenAvailable() && |
| 176 service->GetAuthError().state() == GoogleServiceAuthError::NONE && | 176 service->GetAuthError().state() == GoogleServiceAuthError::NONE && |
| 177 !service->HasUnrecoverableError()); | 177 !service->HasUnrecoverableError()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 // static | 180 // static |
| 181 SigninTracker::LoginState SigninTracker::GetSigninState( | 181 SigninTracker::LoginState SigninTracker::GetSigninState( |
| 182 Profile* profile, | 182 Profile* profile, |
| 183 GoogleServiceAuthError* error) { | 183 GoogleServiceAuthError* error) { |
| 184 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); | 184 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); |
| 185 if (signin->GetAuthenticatedUsername().empty()) { | 185 if (signin->GetAuthenticatedUsername().empty()) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 212 if (error) | 212 if (error) |
| 213 *error = signin->signin_global_error()->GetLastAuthError(); | 213 *error = signin->signin_global_error()->GetLastAuthError(); |
| 214 return WAITING_FOR_GAIA_VALIDATION; | 214 return WAITING_FOR_GAIA_VALIDATION; |
| 215 } | 215 } |
| 216 | 216 |
| 217 if (!service || service->sync_initialized()) | 217 if (!service || service->sync_initialized()) |
| 218 return SIGNIN_COMPLETE; | 218 return SIGNIN_COMPLETE; |
| 219 | 219 |
| 220 return SERVICES_INITIALIZING; | 220 return SERVICES_INITIALIZING; |
| 221 } | 221 } |
| OLD | NEW |