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 <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "base/threading/thread_restrictions.h" | 25 #include "base/threading/thread_restrictions.h" |
26 #include "build/build_config.h" | 26 #include "build/build_config.h" |
27 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" | 27 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" |
28 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
29 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 29 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
30 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 30 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
31 #include "chrome/browser/chrome_notification_types.h" | 31 #include "chrome/browser/chrome_notification_types.h" |
32 #include "chrome/browser/defaults.h" | 32 #include "chrome/browser/defaults.h" |
33 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 33 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
34 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 34 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
| 35 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
35 #include "chrome/browser/prefs/pref_service_syncable.h" | 36 #include "chrome/browser/prefs/pref_service_syncable.h" |
36 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
37 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 38 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
38 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 39 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
39 #include "chrome/browser/signin/about_signin_internals_factory.h" | 40 #include "chrome/browser/signin/about_signin_internals_factory.h" |
40 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 41 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
41 #include "chrome/browser/signin/signin_manager_factory.h" | 42 #include "chrome/browser/signin/signin_manager_factory.h" |
42 #include "chrome/browser/sync/backend_migrator.h" | 43 #include "chrome/browser/sync/backend_migrator.h" |
43 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" | 44 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" |
44 #include "chrome/browser/sync/glue/device_info.h" | 45 #include "chrome/browser/sync/glue/device_info.h" |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 credentials.scope_set.insert(signin_->GetSyncScopeToUse()); | 515 credentials.scope_set.insert(signin_->GetSyncScopeToUse()); |
515 } | 516 } |
516 | 517 |
517 return credentials; | 518 return credentials; |
518 } | 519 } |
519 | 520 |
520 bool ProfileSyncService::ShouldDeleteSyncFolder() { | 521 bool ProfileSyncService::ShouldDeleteSyncFolder() { |
521 if (backend_mode_ == SYNC) | 522 if (backend_mode_ == SYNC) |
522 return !HasSyncSetupCompleted(); | 523 return !HasSyncSetupCompleted(); |
523 | 524 |
524 // Start fresh if it's the first time backup after user stopped syncing. | 525 if (backend_mode_ == BACKUP) { |
525 // This is needed because backup DB may contain items deleted by user during | 526 base::Time reset_time = chrome_prefs::GetResetTime(profile_); |
526 // sync period and can cause back-from-dead issues. | 527 |
527 if (backend_mode_ == BACKUP && !sync_prefs_.GetFirstSyncTime().is_null()) | 528 // Start fresh if: |
528 return true; | 529 // * It's the first time backup after user stopped syncing because backup |
| 530 // DB may contain items deleted by user during sync period and can cause |
| 531 // back-from-dead issues if user didn't choose rollback. |
| 532 // * Settings are reset during startup because of tampering to avoid |
| 533 // restoring settings from backup. |
| 534 if (!sync_prefs_.GetFirstSyncTime().is_null() || |
| 535 (!reset_time.is_null() && profile_->GetStartTime() <= reset_time)) { |
| 536 return true; |
| 537 } |
| 538 } |
529 | 539 |
530 return false; | 540 return false; |
531 } | 541 } |
532 | 542 |
533 void ProfileSyncService::InitializeBackend(bool delete_stale_data) { | 543 void ProfileSyncService::InitializeBackend(bool delete_stale_data) { |
534 if (!backend_) { | 544 if (!backend_) { |
535 NOTREACHED(); | 545 NOTREACHED(); |
536 return; | 546 return; |
537 } | 547 } |
538 | 548 |
(...skipping 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2580 } | 2590 } |
2581 return result; | 2591 return result; |
2582 } | 2592 } |
2583 | 2593 |
2584 void ProfileSyncService::StartStopBackupForTesting() { | 2594 void ProfileSyncService::StartStopBackupForTesting() { |
2585 if (backend_mode_ == BACKUP) | 2595 if (backend_mode_ == BACKUP) |
2586 ShutdownImpl(browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD); | 2596 ShutdownImpl(browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD); |
2587 else | 2597 else |
2588 backup_rollback_controller_.Start(base::TimeDelta()); | 2598 backup_rollback_controller_.Start(base::TimeDelta()); |
2589 } | 2599 } |
OLD | NEW |