Commit 7e9814cc authored by Matthias Körber's avatar Matthias Körber Committed by Commit Bot

[Autofill] Remove side effects from operator= in AutofillProfile.

Currently, on profile assignment the finalization routine is called
that causes side effects that may be root cause for some crashes.

Change-Id: Ib6e6a2d11e1b9c8763df591cd262bb67686ed866
Bug: 1140131
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2550743
Commit-Queue: Matthias Körber <koerber@google.com>
Reviewed-by: default avatarChristoph Schwering <schwering@google.com>
Cr-Commit-Position: refs/heads/master@{#830177}
parent b1e95e11
...@@ -259,9 +259,6 @@ AutofillProfile::AutofillProfile(const AutofillProfile& profile) ...@@ -259,9 +259,6 @@ AutofillProfile::AutofillProfile(const AutofillProfile& profile)
company_(this), company_(this),
phone_number_(this) { phone_number_(this) {
operator=(profile); operator=(profile);
// In case the profile is converted from a legacy profile or a wallet profile
// with structured names, try to finalize it.
FinalizeAfterImport();
} }
AutofillProfile::~AutofillProfile() = default; AutofillProfile::~AutofillProfile() = default;
......
...@@ -374,7 +374,7 @@ class PaymentsClientTest : public testing::Test { ...@@ -374,7 +374,7 @@ class PaymentsClientTest : public testing::Test {
profile.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16(zip), "en-US"); profile.SetInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16(zip), "en-US");
profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16(phone_number), profile.SetInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16(phone_number),
"en-US"); "en-US");
profile.FinalizeAfterImport();
return profile; return profile;
} }
}; };
......
...@@ -885,6 +885,7 @@ TEST_F(PersonalDataManagerTest, AddProfile_CrazyCharacters) { ...@@ -885,6 +885,7 @@ TEST_F(PersonalDataManagerTest, AddProfile_CrazyCharacters) {
base::WideToUTF16(L"861088828000")); base::WideToUTF16(L"861088828000"));
profile1.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), profile1.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY),
base::WideToUTF16(L"India"), "en-US"); base::WideToUTF16(L"India"), "en-US");
profile1.FinalizeAfterImport();
profiles.push_back(profile1); profiles.push_back(profile1);
AutofillProfile profile2; AutofillProfile profile2;
...@@ -894,11 +895,13 @@ TEST_F(PersonalDataManagerTest, AddProfile_CrazyCharacters) { ...@@ -894,11 +895,13 @@ TEST_F(PersonalDataManagerTest, AddProfile_CrazyCharacters) {
L"\u8def1915\u53f7")); L"\u8def1915\u53f7"));
profile2.SetRawInfo(NAME_LAST, base::WideToUTF16(L"aguantó")); profile2.SetRawInfo(NAME_LAST, base::WideToUTF16(L"aguantó"));
profile2.SetRawInfo(ADDRESS_HOME_ZIP, base::WideToUTF16(L"HOME 94043")); profile2.SetRawInfo(ADDRESS_HOME_ZIP, base::WideToUTF16(L"HOME 94043"));
profile2.FinalizeAfterImport();
profiles.push_back(profile2); profiles.push_back(profile2);
AutofillProfile profile3; AutofillProfile profile3;
profile3.SetRawInfo(EMAIL_ADDRESS, base::WideToUTF16(L"sue@example.com")); profile3.SetRawInfo(EMAIL_ADDRESS, base::WideToUTF16(L"sue@example.com"));
profile3.SetRawInfo(COMPANY_NAME, base::WideToUTF16(L"Company X")); profile3.SetRawInfo(COMPANY_NAME, base::WideToUTF16(L"Company X"));
profile3.FinalizeAfterImport();
profiles.push_back(profile3); profiles.push_back(profile3);
AutofillProfile profile4; AutofillProfile profile4;
...@@ -917,6 +920,7 @@ TEST_F(PersonalDataManagerTest, AddProfile_CrazyCharacters) { ...@@ -917,6 +920,7 @@ TEST_F(PersonalDataManagerTest, AddProfile_CrazyCharacters) {
L"\u0905\u092a\u094b\u0932\u094b " L"\u0905\u092a\u094b\u0932\u094b "
L"\u091f\u093e\u092f\u0930\u094d\u0938 " L"\u091f\u093e\u092f\u0930\u094d\u0938 "
L"\u0906\u0926\u093f")); L"\u0906\u0926\u093f"));
profile4.FinalizeAfterImport();
profiles.push_back(profile4); profiles.push_back(profile4);
AutofillProfile profile5; AutofillProfile profile5;
...@@ -928,6 +932,7 @@ TEST_F(PersonalDataManagerTest, AddProfile_CrazyCharacters) { ...@@ -928,6 +932,7 @@ TEST_F(PersonalDataManagerTest, AddProfile_CrazyCharacters) {
base::WideToUTF16(L"111111111111110000GOOGLE")); base::WideToUTF16(L"111111111111110000GOOGLE"));
profile5.SetRawInfo(EMAIL_ADDRESS, base::WideToUTF16(L"page@000000.com")); profile5.SetRawInfo(EMAIL_ADDRESS, base::WideToUTF16(L"page@000000.com"));
profile5.SetRawInfo(COMPANY_NAME, base::WideToUTF16(L"Google")); profile5.SetRawInfo(COMPANY_NAME, base::WideToUTF16(L"Google"));
profile5.FinalizeAfterImport();
profiles.push_back(profile5); profiles.push_back(profile5);
AutofillProfile profile6; AutofillProfile profile6;
...@@ -944,6 +949,7 @@ TEST_F(PersonalDataManagerTest, AddProfile_CrazyCharacters) { ...@@ -944,6 +949,7 @@ TEST_F(PersonalDataManagerTest, AddProfile_CrazyCharacters) {
L"\u064a \u0639\u0645\u0631 " L"\u064a \u0639\u0645\u0631 "
L"\u0627\u0644\u0628\u0634\u064a\u0631")); L"\u0627\u0644\u0628\u0634\u064a\u0631"));
profile6.SetRawInfo(ADDRESS_HOME_ZIP, base::WideToUTF16(L"HOME 94043")); profile6.SetRawInfo(ADDRESS_HOME_ZIP, base::WideToUTF16(L"HOME 94043"));
profile6.FinalizeAfterImport();
profiles.push_back(profile6); profiles.push_back(profile6);
AutofillProfile profile7; AutofillProfile profile7;
...@@ -960,6 +966,7 @@ TEST_F(PersonalDataManagerTest, AddProfile_CrazyCharacters) { ...@@ -960,6 +966,7 @@ TEST_F(PersonalDataManagerTest, AddProfile_CrazyCharacters) {
base::WideToUTF16(L"15466784565")); base::WideToUTF16(L"15466784565"));
profile7.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), profile7.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY),
base::WideToUTF16(L"United States"), "en-US"); base::WideToUTF16(L"United States"), "en-US");
profile7.FinalizeAfterImport();
profiles.push_back(profile7); profiles.push_back(profile7);
personal_data_->SetProfiles(&profiles); personal_data_->SetProfiles(&profiles);
......
...@@ -183,6 +183,7 @@ AutofillProfile ConstructCompleteProfile() { ...@@ -183,6 +183,7 @@ AutofillProfile ConstructCompleteProfile() {
profile.SetRawInfo(ADDRESS_HOME_PREMISE_NAME, ASCIIToUTF16("Premise")); profile.SetRawInfo(ADDRESS_HOME_PREMISE_NAME, ASCIIToUTF16("Premise"));
profile.set_language_code("en"); profile.set_language_code("en");
profile.SetClientValidityFromBitfieldValue(kValidityStateBitfield); profile.SetClientValidityFromBitfieldValue(kValidityStateBitfield);
profile.FinalizeAfterImport();
return profile; return profile;
} }
...@@ -415,6 +416,7 @@ TEST_P(AutofillProfileSyncBridgeTest, AutofillProfileChanged_Added) { ...@@ -415,6 +416,7 @@ TEST_P(AutofillProfileSyncBridgeTest, AutofillProfileChanged_Added) {
AutofillProfile local(kGuidA, kHttpsOrigin); AutofillProfile local(kGuidA, kHttpsOrigin);
local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Jane")); local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Jane"));
local.FinalizeAfterImport();
AutofillProfileChange change(AutofillProfileChange::ADD, kGuidA, &local); AutofillProfileChange change(AutofillProfileChange::ADD, kGuidA, &local);
EXPECT_CALL( EXPECT_CALL(
...@@ -560,9 +562,11 @@ TEST_P(AutofillProfileSyncBridgeTest, GetAllDataForDebugging) { ...@@ -560,9 +562,11 @@ TEST_P(AutofillProfileSyncBridgeTest, GetAllDataForDebugging) {
AutofillProfile local1 = AutofillProfile(kGuidA, kHttpsOrigin); AutofillProfile local1 = AutofillProfile(kGuidA, kHttpsOrigin);
local1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); local1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
local1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); local1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"));
local1.FinalizeAfterImport();
AutofillProfile local2 = AutofillProfile(kGuidB, kHttpsOrigin); AutofillProfile local2 = AutofillProfile(kGuidB, kHttpsOrigin);
local2.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom")); local2.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom"));
local2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2nd st")); local2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2nd st"));
local2.FinalizeAfterImport();
AddAutofillProfilesToTable({local1, local2}); AddAutofillProfilesToTable({local1, local2});
EXPECT_THAT(GetAllLocalData(), UnorderedElementsAre(local1, local2)); EXPECT_THAT(GetAllLocalData(), UnorderedElementsAre(local1, local2));
...@@ -572,9 +576,11 @@ TEST_P(AutofillProfileSyncBridgeTest, GetData) { ...@@ -572,9 +576,11 @@ TEST_P(AutofillProfileSyncBridgeTest, GetData) {
AutofillProfile local1 = AutofillProfile(kGuidA, kHttpsOrigin); AutofillProfile local1 = AutofillProfile(kGuidA, kHttpsOrigin);
local1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); local1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
local1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); local1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"));
local1.FinalizeAfterImport();
AutofillProfile local2 = AutofillProfile(kGuidB, kHttpsOrigin); AutofillProfile local2 = AutofillProfile(kGuidB, kHttpsOrigin);
local2.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom")); local2.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom"));
local2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2nd st")); local2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2nd st"));
local2.FinalizeAfterImport();
AddAutofillProfilesToTable({local1, local2}); AddAutofillProfilesToTable({local1, local2});
std::vector<AutofillProfile> data; std::vector<AutofillProfile> data;
...@@ -595,10 +601,11 @@ TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData) { ...@@ -595,10 +601,11 @@ TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData) {
AutofillProfile local1 = AutofillProfile(kGuidA, kHttpOrigin); AutofillProfile local1 = AutofillProfile(kGuidA, kHttpOrigin);
local1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); local1.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
local1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); local1.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"));
local1.FinalizeAfterImport();
AutofillProfile local2 = AutofillProfile(kGuidB, std::string()); AutofillProfile local2 = AutofillProfile(kGuidB, std::string());
local2.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom")); local2.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom"));
local2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2nd st")); local2.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("2 2nd st"));
local2.FinalizeAfterImport();
AddAutofillProfilesToTable({local1, local2}); AddAutofillProfilesToTable({local1, local2});
...@@ -688,6 +695,7 @@ TEST_P(AutofillProfileSyncBridgeTest, ProfileMigration) { ...@@ -688,6 +695,7 @@ TEST_P(AutofillProfileSyncBridgeTest, ProfileMigration) {
// the server. // the server.
TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_SyncAllFieldsToServer) { TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_SyncAllFieldsToServer) {
AutofillProfile local = ConstructCompleteProfile(); AutofillProfile local = ConstructCompleteProfile();
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
// This complete profile is fully uploaded to sync. // This complete profile is fully uploaded to sync.
...@@ -762,6 +770,7 @@ TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_NonSimilarProfiles) { ...@@ -762,6 +770,7 @@ TEST_P(AutofillProfileSyncBridgeTest, MergeSyncData_NonSimilarProfiles) {
local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
local.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("K.")); local.SetRawInfo(NAME_MIDDLE, ASCIIToUTF16("K."));
local.SetRawInfo(NAME_LAST, ASCIIToUTF16("Doe")); local.SetRawInfo(NAME_LAST, ASCIIToUTF16("Doe"));
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
// The remote profile are not similar as the names are different (all other // The remote profile are not similar as the names are different (all other
...@@ -937,6 +946,7 @@ TEST_P(AutofillProfileSyncBridgeTest, ...@@ -937,6 +946,7 @@ TEST_P(AutofillProfileSyncBridgeTest,
MergeSyncData_SimilarProfiles_LocalOriginPreserved) { MergeSyncData_SimilarProfiles_LocalOriginPreserved) {
AutofillProfile local(kGuidA, kHttpsOrigin); AutofillProfile local(kGuidA, kHttpsOrigin);
local.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("650234567")); local.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("650234567"));
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
AutofillProfile remote_profile = AutofillProfile(kGuidB, kHttpOrigin); AutofillProfile remote_profile = AutofillProfile(kGuidB, kHttpOrigin);
...@@ -964,6 +974,7 @@ TEST_P(AutofillProfileSyncBridgeTest, ...@@ -964,6 +974,7 @@ TEST_P(AutofillProfileSyncBridgeTest,
TEST_P(AutofillProfileSyncBridgeTest, TEST_P(AutofillProfileSyncBridgeTest,
MergeSyncData_SimilarProfiles_LocalExistingOriginPreserved) { MergeSyncData_SimilarProfiles_LocalExistingOriginPreserved) {
AutofillProfile local(kGuidA, kHttpsOrigin); AutofillProfile local(kGuidA, kHttpsOrigin);
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
// Remote data does not have an origin value. // Remote data does not have an origin value.
...@@ -980,6 +991,7 @@ TEST_P(AutofillProfileSyncBridgeTest, ...@@ -980,6 +991,7 @@ TEST_P(AutofillProfileSyncBridgeTest,
// Expect the local autofill profile to still have an origin after sync. // Expect the local autofill profile to still have an origin after sync.
AutofillProfile merged(local); AutofillProfile merged(local);
merged.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); merged.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
merged.FinalizeAfterImport();
EXPECT_THAT(GetAllLocalData(), ElementsAre(merged)); EXPECT_THAT(GetAllLocalData(), ElementsAre(merged));
} }
...@@ -991,6 +1003,7 @@ TEST_P(AutofillProfileSyncBridgeTest, ...@@ -991,6 +1003,7 @@ TEST_P(AutofillProfileSyncBridgeTest,
MergeSyncData_SimilarProfiles_LocalMissingOriginPreserved) { MergeSyncData_SimilarProfiles_LocalMissingOriginPreserved) {
AutofillProfile local = AutofillProfile(kGuidA, std::string()); AutofillProfile local = AutofillProfile(kGuidA, std::string());
local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
// Create a Sync profile identical to |local|, except with no origin set. // Create a Sync profile identical to |local|, except with no origin set.
...@@ -1010,6 +1023,7 @@ TEST_P(AutofillProfileSyncBridgeTest, ...@@ -1010,6 +1023,7 @@ TEST_P(AutofillProfileSyncBridgeTest,
TEST_P(AutofillProfileSyncBridgeTest, ApplySyncChanges) { TEST_P(AutofillProfileSyncBridgeTest, ApplySyncChanges) {
AutofillProfile local = AutofillProfile(kGuidA, kHttpsOrigin); AutofillProfile local = AutofillProfile(kGuidA, kHttpsOrigin);
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
StartSyncing({}); StartSyncing({});
...@@ -1310,6 +1324,7 @@ TEST_P(AutofillProfileSyncBridgeTest, ...@@ -1310,6 +1324,7 @@ TEST_P(AutofillProfileSyncBridgeTest,
// Expect local autofill profile to still have the validity state after. // Expect local autofill profile to still have the validity state after.
AutofillProfile merged(local); AutofillProfile merged(local);
merged.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); merged.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
merged.FinalizeAfterImport();
// No update to sync, the local validity bitfield should stay untouched. // No update to sync, the local validity bitfield should stay untouched.
EXPECT_CALL(mock_processor(), Put(_, _, _)).Times(0); EXPECT_CALL(mock_processor(), Put(_, _, _)).Times(0);
...@@ -1324,6 +1339,7 @@ TEST_P(AutofillProfileSyncBridgeTest, ...@@ -1324,6 +1339,7 @@ TEST_P(AutofillProfileSyncBridgeTest,
// Local autofill profile has an empty full name. // Local autofill profile has an empty full name.
AutofillProfile local(kGuidA, kHttpsOrigin); AutofillProfile local(kGuidA, kHttpsOrigin);
local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
// Remote data does not have a full name value. // Remote data does not have a full name value.
......
...@@ -139,11 +139,13 @@ TEST_F(AutofillProfileSyncDifferenceTrackerTest, ...@@ -139,11 +139,13 @@ TEST_F(AutofillProfileSyncDifferenceTrackerTest,
IncorporateRemoteProfileShouldOverwriteProfileWithSameKey) { IncorporateRemoteProfileShouldOverwriteProfileWithSameKey) {
AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpOrigin); AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpOrigin);
local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
// The remote profile is completely different but it has the same key. // The remote profile is completely different but it has the same key.
AutofillProfile remote = AutofillProfile(kSmallerGuid, kHttpsOrigin); AutofillProfile remote = AutofillProfile(kSmallerGuid, kHttpsOrigin);
remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom")); remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom"));
remote.FinalizeAfterImport();
IncorporateRemoteProfile(remote); IncorporateRemoteProfile(remote);
...@@ -158,11 +160,13 @@ TEST_F(AutofillProfileSyncDifferenceTrackerTest, ...@@ -158,11 +160,13 @@ TEST_F(AutofillProfileSyncDifferenceTrackerTest,
IncorporateRemoteProfileShouldOverwriteUnverifiedProfileByVerified) { IncorporateRemoteProfileShouldOverwriteUnverifiedProfileByVerified) {
AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpsOrigin); AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpsOrigin);
local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
// The remote profile has the same key but it is not verified. // The remote profile has the same key but it is not verified.
AutofillProfile remote = AutofillProfile(kSmallerGuid, kSettingsOrigin); AutofillProfile remote = AutofillProfile(kSmallerGuid, kSettingsOrigin);
remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom")); remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom"));
remote.FinalizeAfterImport();
IncorporateRemoteProfile(remote); IncorporateRemoteProfile(remote);
...@@ -177,12 +181,13 @@ TEST_F(AutofillProfileSyncDifferenceTrackerTest, ...@@ -177,12 +181,13 @@ TEST_F(AutofillProfileSyncDifferenceTrackerTest,
IncorporateRemoteProfileShouldNotOverwriteVerifiedProfileByUnverified) { IncorporateRemoteProfileShouldNotOverwriteVerifiedProfileByUnverified) {
AutofillProfile local = AutofillProfile(kSmallerGuid, kSettingsOrigin); AutofillProfile local = AutofillProfile(kSmallerGuid, kSettingsOrigin);
local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
// The remote profile has the same key but it is not verified. // The remote profile has the same key but it is not verified.
AutofillProfile remote = AutofillProfile(kSmallerGuid, kHttpsOrigin); AutofillProfile remote = AutofillProfile(kSmallerGuid, kHttpsOrigin);
remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom")); remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Tom"));
remote.FinalizeAfterImport();
IncorporateRemoteProfile(remote); IncorporateRemoteProfile(remote);
// Nothing gets uploaded to sync and the local profile wins. // Nothing gets uploaded to sync and the local profile wins.
...@@ -196,6 +201,7 @@ TEST_F(AutofillProfileSyncDifferenceTrackerTest, ...@@ -196,6 +201,7 @@ TEST_F(AutofillProfileSyncDifferenceTrackerTest,
IncorporateRemoteProfileShouldNotOverwriteFullNameByEmptyString) { IncorporateRemoteProfileShouldNotOverwriteFullNameByEmptyString) {
AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpOrigin); AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpOrigin);
local.SetRawInfo(NAME_FULL, ASCIIToUTF16("John")); local.SetRawInfo(NAME_FULL, ASCIIToUTF16("John"));
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
// The remote profile has the same key. // The remote profile has the same key.
...@@ -204,7 +210,7 @@ TEST_F(AutofillProfileSyncDifferenceTrackerTest, ...@@ -204,7 +210,7 @@ TEST_F(AutofillProfileSyncDifferenceTrackerTest,
AutofillProfile merged(remote); AutofillProfile merged(remote);
merged.SetRawInfo(NAME_FULL, ASCIIToUTF16("John")); merged.SetRawInfo(NAME_FULL, ASCIIToUTF16("John"));
merged.FinalizeAfterImport();
IncorporateRemoteProfile(remote); IncorporateRemoteProfile(remote);
// Nothing gets uploaded to sync and the remote profile wins except for the // Nothing gets uploaded to sync and the remote profile wins except for the
...@@ -221,6 +227,7 @@ TEST_F( ...@@ -221,6 +227,7 @@ TEST_F(
AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpOrigin); AutofillProfile local = AutofillProfile(kSmallerGuid, kHttpOrigin);
local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"));
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
// The remote profile is identical to the local one, except that the guids and // The remote profile is identical to the local one, except that the guids and
...@@ -228,7 +235,7 @@ TEST_F( ...@@ -228,7 +235,7 @@ TEST_F(
AutofillProfile remote = AutofillProfile(kBiggerGuid, kHttpsOrigin); AutofillProfile remote = AutofillProfile(kBiggerGuid, kHttpsOrigin);
remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"));
remote.FinalizeAfterImport();
IncorporateRemoteProfile(remote); IncorporateRemoteProfile(remote);
// Nothing gets uploaded to sync and the remote profile wins. // Nothing gets uploaded to sync and the remote profile wins.
...@@ -245,12 +252,14 @@ TEST_F( ...@@ -245,12 +252,14 @@ TEST_F(
AutofillProfile local = AutofillProfile(kSmallerGuid, kSettingsOrigin); AutofillProfile local = AutofillProfile(kSmallerGuid, kSettingsOrigin);
local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"));
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
// The remote profile has the same key. // The remote profile has the same key.
AutofillProfile remote = AutofillProfile(kBiggerGuid, kHttpsOrigin); AutofillProfile remote = AutofillProfile(kBiggerGuid, kHttpsOrigin);
remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"));
remote.FinalizeAfterImport();
AutofillProfile merged(remote); AutofillProfile merged(remote);
merged.set_origin(kSettingsOrigin); merged.set_origin(kSettingsOrigin);
...@@ -272,6 +281,7 @@ TEST_F( ...@@ -272,6 +281,7 @@ TEST_F(
AutofillProfile local = AutofillProfile(kBiggerGuid, kHttpOrigin); AutofillProfile local = AutofillProfile(kBiggerGuid, kHttpOrigin);
local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"));
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
// The remote profile is identical to the local one, except that the guids and // The remote profile is identical to the local one, except that the guids and
...@@ -279,7 +289,7 @@ TEST_F( ...@@ -279,7 +289,7 @@ TEST_F(
AutofillProfile remote = AutofillProfile(kSmallerGuid, kHttpsOrigin); AutofillProfile remote = AutofillProfile(kSmallerGuid, kHttpsOrigin);
remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"));
remote.FinalizeAfterImport();
IncorporateRemoteProfile(remote); IncorporateRemoteProfile(remote);
// Nothing gets uploaded to sync and the remote profile wins. // Nothing gets uploaded to sync and the remote profile wins.
...@@ -296,16 +306,17 @@ TEST_F( ...@@ -296,16 +306,17 @@ TEST_F(
AutofillProfile local = AutofillProfile(kBiggerGuid, kHttpsOrigin); AutofillProfile local = AutofillProfile(kBiggerGuid, kHttpsOrigin);
local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); local.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); local.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"));
local.FinalizeAfterImport();
AddAutofillProfilesToTable({local}); AddAutofillProfilesToTable({local});
// The remote profile has the same key. // The remote profile has the same key.
AutofillProfile remote = AutofillProfile(kSmallerGuid, kSettingsOrigin); AutofillProfile remote = AutofillProfile(kSmallerGuid, kSettingsOrigin);
remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); remote.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John"));
remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st")); remote.SetRawInfo(ADDRESS_HOME_STREET_ADDRESS, ASCIIToUTF16("1 1st st"));
remote.FinalizeAfterImport();
AutofillProfile merged(local); AutofillProfile merged(local);
merged.set_origin(kSettingsOrigin); merged.set_origin(kSettingsOrigin);
IncorporateRemoteProfile(remote); IncorporateRemoteProfile(remote);
// Nothing gets uploaded to sync and the remote profile wins except for the // Nothing gets uploaded to sync and the remote profile wins except for the
......
...@@ -373,6 +373,9 @@ AutofillProfile ProfileFromSpecifics( ...@@ -373,6 +373,9 @@ AutofillProfile ProfileFromSpecifics(
profile.GenerateServerProfileIdentifier(); profile.GenerateServerProfileIdentifier();
// Call the finalization routine to parse the structure of the name and the
// address into their components.
profile.FinalizeAfterImport();
return profile; return profile;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment