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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 { | 434 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { |
435 // Currently on passwords are an encrypted datatype, so | 435 return encrypted_types_.size() > 0; |
436 // we check to see if it is enabled. | |
437 syncable::ModelTypeSet types; | |
438 GetPreferredDataTypes(&types); | |
439 return types.count(syncable::PASSWORDS) != 0; | |
440 } | 436 } |
441 | 437 |
442 void ProfileSyncService::StartUp() { | 438 void ProfileSyncService::StartUp() { |
443 // Don't start up multiple times. | 439 // Don't start up multiple times. |
444 if (backend_.get()) { | 440 if (backend_.get()) { |
445 VLOG(1) << "Skipping bringing up backend host."; | 441 VLOG(1) << "Skipping bringing up backend host."; |
446 return; | 442 return; |
447 } | 443 } |
448 | 444 |
449 DCHECK(AreCredentialsAvailable()); | 445 DCHECK(AreCredentialsAvailable()); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 data_type_manager_->Configure(types); | 731 data_type_manager_->Configure(types); |
736 | 732 |
737 NotifyObservers(); | 733 NotifyObservers(); |
738 observed_passphrase_required_ = false; | 734 observed_passphrase_required_ = false; |
739 tried_setting_explicit_passphrase_ = false; | 735 tried_setting_explicit_passphrase_ = false; |
740 tried_creating_explicit_passphrase_ = false; | 736 tried_creating_explicit_passphrase_ = false; |
741 | 737 |
742 wizard_.Step(SyncSetupWizard::DONE); | 738 wizard_.Step(SyncSetupWizard::DONE); |
743 } | 739 } |
744 | 740 |
| 741 void ProfileSyncService::OnEncryptionComplete( |
| 742 const syncable::ModelTypeSet& encrypted_types) { |
| 743 encrypted_types_ = encrypted_types; |
| 744 NotifyObservers(); |
| 745 } |
| 746 |
745 void ProfileSyncService::ShowLoginDialog(gfx::NativeWindow parent_window) { | 747 void ProfileSyncService::ShowLoginDialog(gfx::NativeWindow parent_window) { |
746 // TODO(johnnyg): File a bug to make sure this doesn't happen. | 748 // TODO(johnnyg): File a bug to make sure this doesn't happen. |
747 if (!cros_user_.empty()) { | 749 if (!cros_user_.empty()) { |
748 LOG(WARNING) << "ShowLoginDialog called on Chrome OS."; | 750 LOG(WARNING) << "ShowLoginDialog called on Chrome OS."; |
749 return; | 751 return; |
750 } | 752 } |
751 | 753 |
752 if (WizardIsVisible()) { | 754 if (WizardIsVisible()) { |
753 wizard_.Focus(); | 755 wizard_.Focus(); |
754 return; | 756 return; |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 cached_passphrase_.is_explicit = is_explicit; | 1154 cached_passphrase_.is_explicit = is_explicit; |
1153 cached_passphrase_.is_creation = is_creation; | 1155 cached_passphrase_.is_creation = is_creation; |
1154 } | 1156 } |
1155 | 1157 |
1156 if (is_explicit && is_creation) | 1158 if (is_explicit && is_creation) |
1157 tried_creating_explicit_passphrase_ = true; | 1159 tried_creating_explicit_passphrase_ = true; |
1158 else if (is_explicit) | 1160 else if (is_explicit) |
1159 tried_setting_explicit_passphrase_ = true; | 1161 tried_setting_explicit_passphrase_ = true; |
1160 } | 1162 } |
1161 | 1163 |
| 1164 void ProfileSyncService::EncryptDataTypes( |
| 1165 const syncable::ModelTypeSet& encrypted_types) { |
| 1166 backend_->EncryptDataTypes(encrypted_types); |
| 1167 } |
| 1168 |
| 1169 void ProfileSyncService::GetEncryptedDataTypes( |
| 1170 syncable::ModelTypeSet* encrypted_types) const { |
| 1171 *encrypted_types = encrypted_types_; |
| 1172 } |
| 1173 |
1162 void ProfileSyncService::Observe(NotificationType type, | 1174 void ProfileSyncService::Observe(NotificationType type, |
1163 const NotificationSource& source, | 1175 const NotificationSource& source, |
1164 const NotificationDetails& details) { | 1176 const NotificationDetails& details) { |
1165 switch (type.value) { | 1177 switch (type.value) { |
1166 case NotificationType::SYNC_CONFIGURE_START: { | 1178 case NotificationType::SYNC_CONFIGURE_START: { |
1167 NotifyObservers(); | 1179 NotifyObservers(); |
1168 // TODO(sync): Maybe toast? | 1180 // TODO(sync): Maybe toast? |
1169 break; | 1181 break; |
1170 } | 1182 } |
1171 case NotificationType::SYNC_CONFIGURE_DONE: { | 1183 case NotificationType::SYNC_CONFIGURE_DONE: { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 // is initialized, all enabled data types are consistent with one | 1315 // is initialized, all enabled data types are consistent with one |
1304 // another, and no unrecoverable error has transpired. | 1316 // another, and no unrecoverable error has transpired. |
1305 if (unrecoverable_error_detected_) | 1317 if (unrecoverable_error_detected_) |
1306 return false; | 1318 return false; |
1307 | 1319 |
1308 if (!data_type_manager_.get()) | 1320 if (!data_type_manager_.get()) |
1309 return false; | 1321 return false; |
1310 | 1322 |
1311 return data_type_manager_->state() == DataTypeManager::CONFIGURED; | 1323 return data_type_manager_->state() == DataTypeManager::CONFIGURED; |
1312 } | 1324 } |
OLD | NEW |