Chromium Code Reviews| Index: chrome/browser/sync/profile_sync_service.cc |
| diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc |
| index 7488ed95565a73a899e2dbfa79bc42219266ca2a..332db1fb39b62732661bc20fb10afd4abd73c693 100644 |
| --- a/chrome/browser/sync/profile_sync_service.cc |
| +++ b/chrome/browser/sync/profile_sync_service.cc |
| @@ -73,6 +73,13 @@ const char* ProfileSyncService::kDevServerUrl = |
| static const int kSyncClearDataTimeoutInSeconds = 60; // 1 minute. |
| +namespace { |
|
akalin
2011/08/11 18:03:37
since this is used in 3 places, can you maybe move
Rick Campbell
2011/08/11 21:04:08
Done.
|
| +bool IsUsingOAuth() { |
| + return CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableSyncOAuth); |
| +} |
| +} |
| + |
| ProfileSyncService::ProfileSyncService(ProfileSyncFactory* factory, |
| Profile* profile, |
| SigninManager* signin_manager, |
| @@ -117,11 +124,11 @@ bool ProfileSyncService::AreCredentialsAvailable() { |
| // 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. |
| - if (profile()->GetTokenService() && |
| + return profile()->GetTokenService() && |
| profile()->GetTokenService()->HasTokenForService( |
| - GaiaConstants::kSyncService)) { |
| - return true; |
| - } |
| + IsUsingOAuth() ? |
| + GaiaConstants::kSyncServiceOAuth : |
| + GaiaConstants::kSyncService); |
| } |
| return false; |
| } |
| @@ -265,6 +272,9 @@ void ProfileSyncService::RegisterPreferences() { |
| pref_service->RegisterBooleanPref(prefs::kSyncHasSetupCompleted, |
| false, |
| PrefService::UNSYNCABLE_PREF); |
| + pref_service->RegisterBooleanPref(prefs::kSyncUsingOAuth, |
| + false, |
| + PrefService::UNSYNCABLE_PREF); |
| pref_service->RegisterBooleanPref(prefs::kSyncSuppressStart, |
| false, |
| PrefService::UNSYNCABLE_PREF); |
| @@ -353,10 +363,12 @@ void ProfileSyncService::ClearPreferences() { |
| SyncCredentials ProfileSyncService::GetCredentials() { |
| SyncCredentials credentials; |
| - credentials.email = !cros_user_.empty() ? cros_user_ : signin_->GetUsername(); |
| + credentials.email = cros_user_.empty() ? signin_->GetUsername() : cros_user_; |
| DCHECK(!credentials.email.empty()); |
| TokenService* service = profile_->GetTokenService(); |
| credentials.sync_token = service->GetTokenForService( |
| + IsUsingOAuth() ? |
|
akalin
2011/08/11 18:03:37
this code is also repeated
Rick Campbell
2011/08/11 21:04:08
Done.
|
| + GaiaConstants::kSyncServiceOAuth : |
| GaiaConstants::kSyncService); |
| return credentials; |
| } |
| @@ -1341,7 +1353,13 @@ void ProfileSyncService::Observe(int type, |
| // update the implicit passphrase (idempotent if the passphrase didn't |
| // actually change), or the user has an explicit passphrase set so this |
| // becomes a no-op. |
| - SetPassphrase(successful->password, false, true); |
| + if (IsUsingOAuth()) { |
| + // TODO(rickcam): Bug 92323: Fetch password through special Gaia request |
| + DCHECK(successful->password.empty()); |
| + LOG(WARNING) << "Not initializing sync passphrase."; |
| + } else { |
| + SetPassphrase(successful->password, false, true); |
| + } |
| break; |
| } |
| case chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED: { |
| @@ -1361,7 +1379,6 @@ void ProfileSyncService::Observe(int type, |
| if (backend_initialized_) { |
| backend_->UpdateCredentials(GetCredentials()); |
| } |
| - |
| if (!profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart)) |
| StartUp(); |
| } |