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