OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 for (int i = 0; i < timestamps_count; ++i) { | 600 for (int i = 0; i < timestamps_count; ++i) { |
601 timestamps.push_back(Time::FromInternalValue( | 601 timestamps.push_back(Time::FromInternalValue( |
602 autofill.usage_timestamp(i))); | 602 autofill.usage_timestamp(i))); |
603 } | 603 } |
604 entries->push_back( | 604 entries->push_back( |
605 AutofillEntry(key, timestamps.front(), timestamps.back())); | 605 AutofillEntry(key, timestamps.front(), timestamps.back())); |
606 } else if (autofill.has_profile()) { | 606 } else if (autofill.has_profile()) { |
607 AutofillProfile p; | 607 AutofillProfile p; |
608 p.set_guid(autofill.profile().guid()); | 608 p.set_guid(autofill.profile().guid()); |
609 AutofillProfileSyncableService::OverwriteProfileWithServerData( | 609 AutofillProfileSyncableService::OverwriteProfileWithServerData( |
610 autofill.profile(), &p, "en-US"); | 610 autofill.profile(), &p); |
611 profiles->push_back(p); | 611 profiles->push_back(p); |
612 } | 612 } |
613 child_id = child_node.GetSuccessorId(); | 613 child_id = child_node.GetSuccessorId(); |
614 } | 614 } |
615 return true; | 615 return true; |
616 } | 616 } |
617 | 617 |
618 bool GetAutofillProfilesFromSyncDBUnderProfileNode( | 618 bool GetAutofillProfilesFromSyncDBUnderProfileNode( |
619 std::vector<AutofillProfile>* profiles) { | 619 std::vector<AutofillProfile>* profiles) { |
620 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 620 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
621 syncer::ReadNode autofill_root(&trans); | 621 syncer::ReadNode autofill_root(&trans); |
622 if (autofill_root.InitTypeRoot(AUTOFILL_PROFILE) != BaseNode::INIT_OK) { | 622 if (autofill_root.InitTypeRoot(AUTOFILL_PROFILE) != BaseNode::INIT_OK) { |
623 return false; | 623 return false; |
624 } | 624 } |
625 | 625 |
626 int64_t child_id = autofill_root.GetFirstChildId(); | 626 int64_t child_id = autofill_root.GetFirstChildId(); |
627 while (child_id != syncer::kInvalidId) { | 627 while (child_id != syncer::kInvalidId) { |
628 syncer::ReadNode child_node(&trans); | 628 syncer::ReadNode child_node(&trans); |
629 if (child_node.InitByIdLookup(child_id) != BaseNode::INIT_OK) | 629 if (child_node.InitByIdLookup(child_id) != BaseNode::INIT_OK) |
630 return false; | 630 return false; |
631 | 631 |
632 const sync_pb::AutofillProfileSpecifics& autofill( | 632 const sync_pb::AutofillProfileSpecifics& autofill( |
633 child_node.GetEntitySpecifics().autofill_profile()); | 633 child_node.GetEntitySpecifics().autofill_profile()); |
634 AutofillProfile p; | 634 AutofillProfile p; |
635 p.set_guid(autofill.guid()); | 635 p.set_guid(autofill.guid()); |
636 AutofillProfileSyncableService::OverwriteProfileWithServerData( | 636 AutofillProfileSyncableService::OverwriteProfileWithServerData(autofill, |
637 autofill, &p, "en-US"); | 637 &p); |
638 profiles->push_back(p); | 638 profiles->push_back(p); |
639 child_id = child_node.GetSuccessorId(); | 639 child_id = child_node.GetSuccessorId(); |
640 } | 640 } |
641 return true; | 641 return true; |
642 } | 642 } |
643 | 643 |
644 void SetIdleChangeProcessorExpectations() { | 644 void SetIdleChangeProcessorExpectations() { |
645 EXPECT_CALL(autofill_table_, RemoveFormElement(_, _)).Times(0); | 645 EXPECT_CALL(autofill_table_, RemoveFormElement(_, _)).Times(0); |
646 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _, _)).Times(0); | 646 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _, _)).Times(0); |
647 | 647 |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 std::vector<AutofillEntry> sync_entries; | 1307 std::vector<AutofillEntry> sync_entries; |
1308 std::vector<AutofillProfile> sync_profiles; | 1308 std::vector<AutofillProfile> sync_profiles; |
1309 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1309 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
1310 EXPECT_EQ(3U, sync_entries.size()); | 1310 EXPECT_EQ(3U, sync_entries.size()); |
1311 EXPECT_EQ(0U, sync_profiles.size()); | 1311 EXPECT_EQ(0U, sync_profiles.size()); |
1312 for (size_t i = 0; i < sync_entries.size(); i++) { | 1312 for (size_t i = 0; i < sync_entries.size(); i++) { |
1313 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1313 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
1314 << ", " << sync_entries[i].key().value(); | 1314 << ", " << sync_entries[i].key().value(); |
1315 } | 1315 } |
1316 } | 1316 } |
OLD | NEW |