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_harness.h" | 5 #include "chrome/browser/sync/profile_sync_service_harness.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <iterator> | 9 #include <iterator> |
10 #include <ostream> | 10 #include <ostream> |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 return os.str(); | 766 return os.str(); |
767 } | 767 } |
768 | 768 |
769 bool ProfileSyncServiceHarness::EnableEncryptionForType( | 769 bool ProfileSyncServiceHarness::EnableEncryptionForType( |
770 syncable::ModelType type) { | 770 syncable::ModelType type) { |
771 syncable::ModelTypeSet encrypted_types; | 771 syncable::ModelTypeSet encrypted_types; |
772 service_->GetEncryptedDataTypes(&encrypted_types); | 772 service_->GetEncryptedDataTypes(&encrypted_types); |
773 if (encrypted_types.count(type) > 0) | 773 if (encrypted_types.count(type) > 0) |
774 return true; | 774 return true; |
775 encrypted_types.insert(type); | 775 encrypted_types.insert(type); |
776 service_->EncryptDataTypes(encrypted_types); | 776 service_->set_pending_types_for_encryption(encrypted_types); |
| 777 |
| 778 // In order to kick off the encryption we have to reconfigure. Just grab the |
| 779 // currently synced types and use them. |
| 780 syncable::ModelTypeSet synced_datatypes; |
| 781 service_->GetPreferredDataTypes(&synced_datatypes); |
| 782 bool sync_everything = (synced_datatypes.size() == |
| 783 (syncable::MODEL_TYPE_COUNT - syncable::FIRST_REAL_MODEL_TYPE)); |
| 784 service_->OnUserChoseDatatypes(sync_everything, |
| 785 synced_datatypes); |
777 | 786 |
778 // Wait some time to let the enryption finish. | 787 // Wait some time to let the enryption finish. |
779 return WaitForTypeEncryption(type); | 788 return WaitForTypeEncryption(type); |
780 } | 789 } |
781 | 790 |
782 bool ProfileSyncServiceHarness::WaitForTypeEncryption( | 791 bool ProfileSyncServiceHarness::WaitForTypeEncryption( |
783 syncable::ModelType type) { | 792 syncable::ModelType type) { |
784 if (IsSynced() && | 793 if (IsSynced() && |
785 IsTypeEncrypted(type) && | 794 IsTypeEncrypted(type) && |
786 GetLastSessionSnapshot()->num_conflicting_updates == 0) { | 795 GetLastSessionSnapshot()->num_conflicting_updates == 0) { |
(...skipping 22 matching lines...) Expand all Loading... |
809 return true; | 818 return true; |
810 } | 819 } |
811 | 820 |
812 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 821 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
813 DictionaryValue value; | 822 DictionaryValue value; |
814 sync_ui_util::ConstructAboutInformation(service_, &value); | 823 sync_ui_util::ConstructAboutInformation(service_, &value); |
815 std::string service_status; | 824 std::string service_status; |
816 base::JSONWriter::Write(&value, true, &service_status); | 825 base::JSONWriter::Write(&value, true, &service_status); |
817 return service_status; | 826 return service_status; |
818 } | 827 } |
OLD | NEW |