Index: chrome/browser/sync/profile_sync_service.cc |
=================================================================== |
--- chrome/browser/sync/profile_sync_service.cc (revision 112357) |
+++ chrome/browser/sync/profile_sync_service.cc (working copy) |
@@ -141,18 +141,27 @@ |
} |
bool ProfileSyncService::AreCredentialsAvailable() { |
+ return AreCredentialsAvailable(false); |
+} |
+ |
+bool ProfileSyncService::AreCredentialsAvailable( |
+ bool check_oauth_login_token) { |
if (IsManaged()) { |
return false; |
} |
// CrOS user is always logged in. Chrome uses signin_ to check logged in. |
- if (!cros_user_.empty() || !signin_->GetUsername().empty()) { |
- // TODO(chron): Verify CrOS unit test behavior. |
- return profile()->GetTokenService() && |
- profile()->GetTokenService()->HasTokenForService( |
- browser_sync::SyncServiceName()); |
- } |
- return false; |
+ if (cros_user_.empty() && signin_->GetUsername().empty()) |
+ return false; |
+ |
+ TokenService* token_service = profile()->GetTokenService(); |
+ if (!token_service) |
+ return false; |
+ |
+ // TODO(chron): Verify CrOS unit test behavior. |
+ if (!token_service->HasTokenForService(browser_sync::SyncServiceName())) |
+ return false; |
+ return !check_oauth_login_token || token_service->HasOAuthLoginToken(); |
} |
void ProfileSyncService::Initialize() { |
@@ -1448,7 +1457,7 @@ |
break; |
} |
case chrome::NOTIFICATION_TOKEN_AVAILABLE: { |
- if (AreCredentialsAvailable()) { |
+ if (AreCredentialsAvailable(true)) { |
if (backend_initialized_) { |
backend_->UpdateCredentials(GetCredentials()); |
} |
@@ -1458,11 +1467,16 @@ |
break; |
} |
case chrome::NOTIFICATION_TOKEN_LOADING_FINISHED: { |
- // If not in Chrome OS, and we have a username without tokens, |
- // the user will need to signin again, so sign out. |
- if (cros_user_.empty() && |
- !signin_->GetUsername().empty() && |
- !AreCredentialsAvailable()) { |
+ if (AreCredentialsAvailable()) { |
Andrew T Wilson (Slow)
2011/12/01 22:07:01
Can you add a note here about why we are intention
Munjal (Google)
2011/12/01 22:52:58
Done. The comment is a bit long but this is an imp
|
+ // Initialize the backend if sync token was loaded. |
+ if (backend_initialized_) { |
+ backend_->UpdateCredentials(GetCredentials()); |
+ } |
+ if (!sync_prefs_.IsStartSuppressed()) |
+ StartUp(); |
+ } else if (cros_user_.empty() && !signin_->GetUsername().empty()) { |
+ // If not in Chrome OS, and we have a username without tokens, |
+ // the user will need to signin again, so sign out. |
DisableForUser(); |
} |
break; |