| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 profile_->GetRequestContext(), | 424 profile_->GetRequestContext(), |
| 425 credentials, | 425 credentials, |
| 426 delete_sync_data_folder, | 426 delete_sync_data_folder, |
| 427 notifier_options_); | 427 notifier_options_); |
| 428 } | 428 } |
| 429 | 429 |
| 430 void ProfileSyncService::CreateBackend() { | 430 void ProfileSyncService::CreateBackend() { |
| 431 backend_.reset(new SyncBackendHost(profile_)); | 431 backend_.reset(new SyncBackendHost(profile_)); |
| 432 } | 432 } |
| 433 | 433 |
| 434 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { |
| 435 // Currently on passwords are an encrypted datatype, so |
| 436 // we check to see if it is enabled. |
| 437 syncable::ModelTypeSet types; |
| 438 GetPreferredDataTypes(&types); |
| 439 return types.count(syncable::PASSWORDS) != 0; |
| 440 } |
| 441 |
| 434 void ProfileSyncService::StartUp() { | 442 void ProfileSyncService::StartUp() { |
| 435 // Don't start up multiple times. | 443 // Don't start up multiple times. |
| 436 if (backend_.get()) { | 444 if (backend_.get()) { |
| 437 VLOG(1) << "Skipping bringing up backend host."; | 445 VLOG(1) << "Skipping bringing up backend host."; |
| 438 return; | 446 return; |
| 439 } | 447 } |
| 440 | 448 |
| 441 DCHECK(AreCredentialsAvailable()); | 449 DCHECK(AreCredentialsAvailable()); |
| 442 | 450 |
| 443 last_synced_time_ = base::Time::FromInternalValue( | 451 last_synced_time_ = base::Time::FromInternalValue( |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 passphrase_required_for_decryption_ = for_decryption; | 704 passphrase_required_for_decryption_ = for_decryption; |
| 697 | 705 |
| 698 if (!cached_passphrase_.value.empty()) { | 706 if (!cached_passphrase_.value.empty()) { |
| 699 SetPassphrase(cached_passphrase_.value, | 707 SetPassphrase(cached_passphrase_.value, |
| 700 cached_passphrase_.is_explicit, | 708 cached_passphrase_.is_explicit, |
| 701 cached_passphrase_.is_creation); | 709 cached_passphrase_.is_creation); |
| 702 cached_passphrase_ = CachedPassphrase(); | 710 cached_passphrase_ = CachedPassphrase(); |
| 703 return; | 711 return; |
| 704 } | 712 } |
| 705 | 713 |
| 714 // We will skip the passphrase prompt and suppress the warning |
| 715 // if the passphrase is needed for decryption but the user is |
| 716 // not syncing an encrypted data type on this machine. |
| 717 // Otherwise we prompt. |
| 718 if (!IsEncryptedDatatypeEnabled() && for_decryption) { |
| 719 OnPassphraseAccepted(); |
| 720 return; |
| 721 } |
| 722 |
| 706 if (WizardIsVisible()) { | 723 if (WizardIsVisible()) { |
| 707 wizard_.Step(SyncSetupWizard::ENTER_PASSPHRASE); | 724 wizard_.Step(SyncSetupWizard::ENTER_PASSPHRASE); |
| 708 } | 725 } |
| 709 | 726 |
| 710 NotifyObservers(); | 727 NotifyObservers(); |
| 711 } | 728 } |
| 712 | 729 |
| 713 void ProfileSyncService::OnPassphraseAccepted() { | 730 void ProfileSyncService::OnPassphraseAccepted() { |
| 714 // Make sure the data types that depend on the passphrase are started at | 731 // Make sure the data types that depend on the passphrase are started at |
| 715 // this time. | 732 // this time. |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 // is initialized, all enabled data types are consistent with one | 1303 // is initialized, all enabled data types are consistent with one |
| 1287 // another, and no unrecoverable error has transpired. | 1304 // another, and no unrecoverable error has transpired. |
| 1288 if (unrecoverable_error_detected_) | 1305 if (unrecoverable_error_detected_) |
| 1289 return false; | 1306 return false; |
| 1290 | 1307 |
| 1291 if (!data_type_manager_.get()) | 1308 if (!data_type_manager_.get()) |
| 1292 return false; | 1309 return false; |
| 1293 | 1310 |
| 1294 return data_type_manager_->state() == DataTypeManager::CONFIGURED; | 1311 return data_type_manager_->state() == DataTypeManager::CONFIGURED; |
| 1295 } | 1312 } |
| OLD | NEW |