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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 credentials, | 426 credentials, |
427 delete_sync_data_folder, | 427 delete_sync_data_folder, |
428 notifier_options_); | 428 notifier_options_); |
429 } | 429 } |
430 | 430 |
431 void ProfileSyncService::CreateBackend() { | 431 void ProfileSyncService::CreateBackend() { |
432 backend_.reset(new SyncBackendHost(profile_)); | 432 backend_.reset(new SyncBackendHost(profile_)); |
433 } | 433 } |
434 | 434 |
435 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { | 435 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { |
436 // Currently on passwords are an encrypted datatype, so | 436 return encrypted_types_.size() > 0; |
437 // we check to see if it is enabled. | |
438 syncable::ModelTypeSet types; | |
439 GetPreferredDataTypes(&types); | |
440 return types.count(syncable::PASSWORDS) != 0; | |
441 } | 437 } |
442 | 438 |
443 void ProfileSyncService::StartUp() { | 439 void ProfileSyncService::StartUp() { |
444 // Don't start up multiple times. | 440 // Don't start up multiple times. |
445 if (backend_.get()) { | 441 if (backend_.get()) { |
446 VLOG(1) << "Skipping bringing up backend host."; | 442 VLOG(1) << "Skipping bringing up backend host."; |
447 return; | 443 return; |
448 } | 444 } |
449 | 445 |
450 DCHECK(AreCredentialsAvailable()); | 446 DCHECK(AreCredentialsAvailable()); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 data_type_manager_->Configure(types); | 740 data_type_manager_->Configure(types); |
745 | 741 |
746 NotifyObservers(); | 742 NotifyObservers(); |
747 observed_passphrase_required_ = false; | 743 observed_passphrase_required_ = false; |
748 tried_setting_explicit_passphrase_ = false; | 744 tried_setting_explicit_passphrase_ = false; |
749 tried_creating_explicit_passphrase_ = false; | 745 tried_creating_explicit_passphrase_ = false; |
750 | 746 |
751 wizard_.Step(SyncSetupWizard::DONE); | 747 wizard_.Step(SyncSetupWizard::DONE); |
752 } | 748 } |
753 | 749 |
| 750 void ProfileSyncService::OnEncryptionComplete( |
| 751 const syncable::ModelTypeSet& encrypted_types) { |
| 752 if (encrypted_types_ != encrypted_types) { |
| 753 encrypted_types_ = encrypted_types; |
| 754 NotifyObservers(); |
| 755 } |
| 756 } |
| 757 |
754 void ProfileSyncService::ShowLoginDialog(gfx::NativeWindow parent_window) { | 758 void ProfileSyncService::ShowLoginDialog(gfx::NativeWindow parent_window) { |
755 if (!cros_user_.empty()) { | 759 if (!cros_user_.empty()) { |
756 // For ChromeOS, any login UI needs to be handled by the settings page. | 760 // For ChromeOS, any login UI needs to be handled by the settings page. |
757 Browser* browser = BrowserList::GetLastActiveWithProfile(profile()); | 761 Browser* browser = BrowserList::GetLastActiveWithProfile(profile()); |
758 if (browser) | 762 if (browser) |
759 browser->ShowOptionsTab(chrome::kPersonalOptionsSubPage); | 763 browser->ShowOptionsTab(chrome::kPersonalOptionsSubPage); |
760 return; | 764 return; |
761 } | 765 } |
762 | 766 |
763 if (WizardIsVisible()) { | 767 if (WizardIsVisible()) { |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 cached_passphrase_.is_explicit = is_explicit; | 1167 cached_passphrase_.is_explicit = is_explicit; |
1164 cached_passphrase_.is_creation = is_creation; | 1168 cached_passphrase_.is_creation = is_creation; |
1165 } | 1169 } |
1166 | 1170 |
1167 if (is_explicit && is_creation) | 1171 if (is_explicit && is_creation) |
1168 tried_creating_explicit_passphrase_ = true; | 1172 tried_creating_explicit_passphrase_ = true; |
1169 else if (is_explicit) | 1173 else if (is_explicit) |
1170 tried_setting_explicit_passphrase_ = true; | 1174 tried_setting_explicit_passphrase_ = true; |
1171 } | 1175 } |
1172 | 1176 |
| 1177 void ProfileSyncService::EncryptDataTypes( |
| 1178 const syncable::ModelTypeSet& encrypted_types) { |
| 1179 backend_->EncryptDataTypes(encrypted_types); |
| 1180 } |
| 1181 |
| 1182 void ProfileSyncService::GetEncryptedDataTypes( |
| 1183 syncable::ModelTypeSet* encrypted_types) const { |
| 1184 *encrypted_types = encrypted_types_; |
| 1185 } |
| 1186 |
1173 void ProfileSyncService::Observe(NotificationType type, | 1187 void ProfileSyncService::Observe(NotificationType type, |
1174 const NotificationSource& source, | 1188 const NotificationSource& source, |
1175 const NotificationDetails& details) { | 1189 const NotificationDetails& details) { |
1176 switch (type.value) { | 1190 switch (type.value) { |
1177 case NotificationType::SYNC_CONFIGURE_START: { | 1191 case NotificationType::SYNC_CONFIGURE_START: { |
1178 NotifyObservers(); | 1192 NotifyObservers(); |
1179 // TODO(sync): Maybe toast? | 1193 // TODO(sync): Maybe toast? |
1180 break; | 1194 break; |
1181 } | 1195 } |
1182 case NotificationType::SYNC_CONFIGURE_DONE: { | 1196 case NotificationType::SYNC_CONFIGURE_DONE: { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 // is initialized, all enabled data types are consistent with one | 1332 // is initialized, all enabled data types are consistent with one |
1319 // another, and no unrecoverable error has transpired. | 1333 // another, and no unrecoverable error has transpired. |
1320 if (unrecoverable_error_detected_) | 1334 if (unrecoverable_error_detected_) |
1321 return false; | 1335 return false; |
1322 | 1336 |
1323 if (!data_type_manager_.get()) | 1337 if (!data_type_manager_.get()) |
1324 return false; | 1338 return false; |
1325 | 1339 |
1326 return data_type_manager_->state() == DataTypeManager::CONFIGURED; | 1340 return data_type_manager_->state() == DataTypeManager::CONFIGURED; |
1327 } | 1341 } |
OLD | NEW |