| 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/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 return false; | 275 return false; |
| 276 | 276 |
| 277 // Sync is logged in if there is a non-empty effective username. | 277 // Sync is logged in if there is a non-empty effective username. |
| 278 return !signin_->GetEffectiveUsername().empty(); | 278 return !signin_->GetEffectiveUsername().empty(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 bool ProfileSyncService::IsOAuthRefreshTokenAvailable() { | 281 bool ProfileSyncService::IsOAuthRefreshTokenAvailable() { |
| 282 if (!oauth2_token_service_) | 282 if (!oauth2_token_service_) |
| 283 return false; | 283 return false; |
| 284 | 284 |
| 285 return oauth2_token_service_->RefreshTokenIsAvailable( | 285 std::string account_id = signin_->GetAccountIdToUse(); |
| 286 signin_->GetAccountIdToUse()); | 286 return !account_id.empty() && |
| 287 oauth2_token_service_->RefreshTokenIsAvailable(account_id); |
| 287 } | 288 } |
| 288 | 289 |
| 289 void ProfileSyncService::Initialize() { | 290 void ProfileSyncService::Initialize() { |
| 290 // We clear this here (vs Shutdown) because we want to remember that an error | 291 // We clear this here (vs Shutdown) because we want to remember that an error |
| 291 // happened on shutdown so we can display details (message, location) about it | 292 // happened on shutdown so we can display details (message, location) about it |
| 292 // in about:sync. | 293 // in about:sync. |
| 293 ClearStaleErrors(); | 294 ClearStaleErrors(); |
| 294 | 295 |
| 295 sync_prefs_.AddSyncPrefObserver(this); | 296 sync_prefs_.AddSyncPrefObserver(this); |
| 296 | 297 |
| (...skipping 2413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2710 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { | 2711 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { |
| 2711 return device_info_sync_service_->GetLocalDeviceBackupTime(); | 2712 return device_info_sync_service_->GetLocalDeviceBackupTime(); |
| 2712 } | 2713 } |
| 2713 | 2714 |
| 2714 void ProfileSyncService::FlushDirectory() const { | 2715 void ProfileSyncService::FlushDirectory() const { |
| 2715 // backend_initialized_ implies backend_ isn't NULL and the manager exists. | 2716 // backend_initialized_ implies backend_ isn't NULL and the manager exists. |
| 2716 // If sync is not initialized yet, we fail silently. | 2717 // If sync is not initialized yet, we fail silently. |
| 2717 if (backend_initialized_) | 2718 if (backend_initialized_) |
| 2718 backend_->FlushDirectory(); | 2719 backend_->FlushDirectory(); |
| 2719 } | 2720 } |
| OLD | NEW |