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 // Start fresh if: |
526 // sync period and can cause back-from-dead issues. | 527 // * It's the first time backup after user stopped syncing because backup |
527 if (backend_mode_ == BACKUP && !sync_prefs_.GetFirstSyncTime().is_null()) | 528 // DB may contain items deleted by user during sync period and can cause |
528 return true; | 529 // back-from-dead issues if user didn't choose rollback. |
530 // * Settings are reset because of tampering to avoid restoring settings | |
531 // from backup. | |
532 if (!sync_prefs_.GetFirstSyncTime().is_null() || | |
533 profile_->GetStartTime() <= chrome_prefs::GetResetTime(profile_)) { | |
gab
2014/07/07 20:56:12
Technically this will work if chrome_prefs::GetRes
| |
534 return true; | |
535 } | |
536 } | |
529 | 537 |
530 return false; | 538 return false; |
531 } | 539 } |
532 | 540 |
533 void ProfileSyncService::InitializeBackend(bool delete_stale_data) { | 541 void ProfileSyncService::InitializeBackend(bool delete_stale_data) { |
534 if (!backend_) { | 542 if (!backend_) { |
535 NOTREACHED(); | 543 NOTREACHED(); |
536 return; | 544 return; |
537 } | 545 } |
538 | 546 |
(...skipping 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2580 } | 2588 } |
2581 return result; | 2589 return result; |
2582 } | 2590 } |
2583 | 2591 |
2584 void ProfileSyncService::StartStopBackupForTesting() { | 2592 void ProfileSyncService::StartStopBackupForTesting() { |
2585 if (backend_mode_ == BACKUP) | 2593 if (backend_mode_ == BACKUP) |
2586 ShutdownImpl(browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD); | 2594 ShutdownImpl(browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD); |
2587 else | 2595 else |
2588 backup_rollback_controller_.Start(base::TimeDelta()); | 2596 backup_rollback_controller_.Start(base::TimeDelta()); |
2589 } | 2597 } |
OLD | NEW |