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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 return os.str(); | 789 return os.str(); |
790 } | 790 } |
791 | 791 |
792 bool ProfileSyncServiceHarness::EnableEncryptionForType( | 792 bool ProfileSyncServiceHarness::EnableEncryptionForType( |
793 syncable::ModelType type) { | 793 syncable::ModelType type) { |
794 syncable::ModelTypeSet encrypted_types; | 794 syncable::ModelTypeSet encrypted_types; |
795 service_->GetEncryptedDataTypes(&encrypted_types); | 795 service_->GetEncryptedDataTypes(&encrypted_types); |
796 if (encrypted_types.count(type) > 0) | 796 if (encrypted_types.count(type) > 0) |
797 return true; | 797 return true; |
798 encrypted_types.insert(type); | 798 encrypted_types.insert(type); |
799 service_->EncryptDataTypes(encrypted_types); | 799 service_->set_pending_types_for_encryption(encrypted_types); |
| 800 |
| 801 // In order to kick off the encryption we have to reconfigure. Just grab the |
| 802 // currently synced types and use them. |
| 803 syncable::ModelTypeSet synced_datatypes; |
| 804 service_->GetPreferredDataTypes(&synced_datatypes); |
| 805 bool sync_everything = (synced_datatypes.size() == |
| 806 (syncable::MODEL_TYPE_COUNT - syncable::FIRST_REAL_MODEL_TYPE)); |
| 807 service_->OnUserChoseDatatypes(sync_everything, |
| 808 synced_datatypes); |
800 | 809 |
801 // Wait some time to let the enryption finish. | 810 // Wait some time to let the enryption finish. |
802 return WaitForTypeEncryption(type); | 811 return WaitForTypeEncryption(type); |
803 } | 812 } |
804 | 813 |
805 bool ProfileSyncServiceHarness::WaitForTypeEncryption( | 814 bool ProfileSyncServiceHarness::WaitForTypeEncryption( |
806 syncable::ModelType type) { | 815 syncable::ModelType type) { |
807 if (IsSynced() && | 816 if (IsSynced() && |
808 IsTypeEncrypted(type) && | 817 IsTypeEncrypted(type) && |
809 GetLastSessionSnapshot()->num_conflicting_updates == 0) { | 818 GetLastSessionSnapshot()->num_conflicting_updates == 0) { |
(...skipping 22 matching lines...) Expand all Loading... |
832 return true; | 841 return true; |
833 } | 842 } |
834 | 843 |
835 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 844 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
836 DictionaryValue value; | 845 DictionaryValue value; |
837 sync_ui_util::ConstructAboutInformation(service_, &value); | 846 sync_ui_util::ConstructAboutInformation(service_, &value); |
838 std::string service_status; | 847 std::string service_status; |
839 base::JSONWriter::Write(&value, true, &service_status); | 848 base::JSONWriter::Write(&value, true, &service_status); |
840 return service_status; | 849 return service_status; |
841 } | 850 } |
OLD | NEW |