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