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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 data_type_manager_->Configure(types); | 737 data_type_manager_->Configure(types); |
742 | 738 |
743 NotifyObservers(); | 739 NotifyObservers(); |
744 observed_passphrase_required_ = false; | 740 observed_passphrase_required_ = false; |
745 tried_setting_explicit_passphrase_ = false; | 741 tried_setting_explicit_passphrase_ = false; |
746 tried_creating_explicit_passphrase_ = false; | 742 tried_creating_explicit_passphrase_ = false; |
747 | 743 |
748 wizard_.Step(SyncSetupWizard::DONE); | 744 wizard_.Step(SyncSetupWizard::DONE); |
749 } | 745 } |
750 | 746 |
| 747 void ProfileSyncService::OnEncryptionComplete( |
| 748 const syncable::ModelTypeSet& encrypted_types) { |
| 749 if (encrypted_types_ != encrypted_types) { |
| 750 encrypted_types_ = encrypted_types; |
| 751 NotifyObservers(); |
| 752 } |
| 753 } |
| 754 |
751 void ProfileSyncService::ShowLoginDialog(gfx::NativeWindow parent_window) { | 755 void ProfileSyncService::ShowLoginDialog(gfx::NativeWindow parent_window) { |
752 // TODO(johnnyg): File a bug to make sure this doesn't happen. | 756 // TODO(johnnyg): File a bug to make sure this doesn't happen. |
753 if (!cros_user_.empty()) { | 757 if (!cros_user_.empty()) { |
754 LOG(WARNING) << "ShowLoginDialog called on Chrome OS."; | 758 LOG(WARNING) << "ShowLoginDialog called on Chrome OS."; |
755 return; | 759 return; |
756 } | 760 } |
757 | 761 |
758 if (WizardIsVisible()) { | 762 if (WizardIsVisible()) { |
759 wizard_.Focus(); | 763 wizard_.Focus(); |
760 return; | 764 return; |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 cached_passphrase_.is_explicit = is_explicit; | 1162 cached_passphrase_.is_explicit = is_explicit; |
1159 cached_passphrase_.is_creation = is_creation; | 1163 cached_passphrase_.is_creation = is_creation; |
1160 } | 1164 } |
1161 | 1165 |
1162 if (is_explicit && is_creation) | 1166 if (is_explicit && is_creation) |
1163 tried_creating_explicit_passphrase_ = true; | 1167 tried_creating_explicit_passphrase_ = true; |
1164 else if (is_explicit) | 1168 else if (is_explicit) |
1165 tried_setting_explicit_passphrase_ = true; | 1169 tried_setting_explicit_passphrase_ = true; |
1166 } | 1170 } |
1167 | 1171 |
| 1172 void ProfileSyncService::EncryptDataTypes( |
| 1173 const syncable::ModelTypeSet& encrypted_types) { |
| 1174 backend_->EncryptDataTypes(encrypted_types); |
| 1175 } |
| 1176 |
| 1177 void ProfileSyncService::GetEncryptedDataTypes( |
| 1178 syncable::ModelTypeSet* encrypted_types) const { |
| 1179 *encrypted_types = encrypted_types_; |
| 1180 } |
| 1181 |
1168 void ProfileSyncService::Observe(NotificationType type, | 1182 void ProfileSyncService::Observe(NotificationType type, |
1169 const NotificationSource& source, | 1183 const NotificationSource& source, |
1170 const NotificationDetails& details) { | 1184 const NotificationDetails& details) { |
1171 switch (type.value) { | 1185 switch (type.value) { |
1172 case NotificationType::SYNC_CONFIGURE_START: { | 1186 case NotificationType::SYNC_CONFIGURE_START: { |
1173 NotifyObservers(); | 1187 NotifyObservers(); |
1174 // TODO(sync): Maybe toast? | 1188 // TODO(sync): Maybe toast? |
1175 break; | 1189 break; |
1176 } | 1190 } |
1177 case NotificationType::SYNC_CONFIGURE_DONE: { | 1191 case NotificationType::SYNC_CONFIGURE_DONE: { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 // is initialized, all enabled data types are consistent with one | 1327 // is initialized, all enabled data types are consistent with one |
1314 // another, and no unrecoverable error has transpired. | 1328 // another, and no unrecoverable error has transpired. |
1315 if (unrecoverable_error_detected_) | 1329 if (unrecoverable_error_detected_) |
1316 return false; | 1330 return false; |
1317 | 1331 |
1318 if (!data_type_manager_.get()) | 1332 if (!data_type_manager_.get()) |
1319 return false; | 1333 return false; |
1320 | 1334 |
1321 return data_type_manager_->state() == DataTypeManager::CONFIGURED; | 1335 return data_type_manager_->state() == DataTypeManager::CONFIGURED; |
1322 } | 1336 } |
OLD | NEW |