OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/webdata/autofill_profile_syncable_service.h" | 5 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 | 137 |
138 // Check for similar unmatched profiles - they are created independently on | 138 // Check for similar unmatched profiles - they are created independently on |
139 // two systems, so merge them. | 139 // two systems, so merge them. |
140 for (GUIDToProfileMap::iterator it = bundle.candidates_to_merge.begin(); | 140 for (GUIDToProfileMap::iterator it = bundle.candidates_to_merge.begin(); |
141 it != bundle.candidates_to_merge.end(); ++it) { | 141 it != bundle.candidates_to_merge.end(); ++it) { |
142 GUIDToProfileMap::iterator profile_to_merge = | 142 GUIDToProfileMap::iterator profile_to_merge = |
143 remaining_profiles.find(it->first); | 143 remaining_profiles.find(it->first); |
144 if (profile_to_merge != remaining_profiles.end()) { | 144 if (profile_to_merge != remaining_profiles.end()) { |
145 bundle.profiles_to_delete.push_back(profile_to_merge->second->guid()); | 145 bundle.profiles_to_delete.push_back(profile_to_merge->second->guid()); |
146 if (MergeProfile(*(profile_to_merge->second), it->second)) | 146 if (MergeProfile(*(profile_to_merge->second), it->second, app_locale_)) |
147 bundle.profiles_to_sync_back.push_back(it->second); | 147 bundle.profiles_to_sync_back.push_back(it->second); |
148 DVLOG(2) << "[AUTOFILL SYNC]" | 148 DVLOG(2) << "[AUTOFILL SYNC]" |
149 << "Found similar profile in sync db but with a different guid: " | 149 << "Found similar profile in sync db but with a different guid: " |
150 << UTF16ToUTF8(it->second->GetRawInfo(NAME_FIRST)) | 150 << UTF16ToUTF8(it->second->GetRawInfo(NAME_FIRST)) |
151 << UTF16ToUTF8(it->second->GetRawInfo(NAME_LAST)) | 151 << UTF16ToUTF8(it->second->GetRawInfo(NAME_LAST)) |
152 << "New guid " << it->second->guid() | 152 << "New guid " << it->second->guid() |
153 << ". Profile to be deleted " | 153 << ". Profile to be deleted " |
154 << profile_to_merge->second->guid(); | 154 << profile_to_merge->second->guid(); |
155 remaining_profiles.erase(profile_to_merge); | 155 remaining_profiles.erase(profile_to_merge); |
156 } | 156 } |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 changed = true; | 556 changed = true; |
557 } | 557 } |
558 } | 558 } |
559 if (changed) | 559 if (changed) |
560 autofill_profile->SetRawMultiInfo(field_type, values); | 560 autofill_profile->SetRawMultiInfo(field_type, values); |
561 return changed; | 561 return changed; |
562 } | 562 } |
563 | 563 |
564 bool AutofillProfileSyncableService::MergeProfile( | 564 bool AutofillProfileSyncableService::MergeProfile( |
565 const AutofillProfile& merge_from, | 565 const AutofillProfile& merge_from, |
566 AutofillProfile* merge_into) { | 566 AutofillProfile* merge_into, |
567 merge_into->OverwriteWithOrAddTo(merge_from); | 567 const std::string& app_locale) { |
| 568 merge_into->OverwriteWithOrAddTo(merge_from, app_locale); |
568 return (merge_into->Compare(merge_from) != 0); | 569 return (merge_into->Compare(merge_from) != 0); |
569 } | 570 } |
570 | 571 |
571 AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const { | 572 AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const { |
572 return AutofillTable::FromWebDatabase(web_data_service_->GetDatabase()); | 573 return AutofillTable::FromWebDatabase(web_data_service_->GetDatabase()); |
573 } | 574 } |
574 | 575 |
575 AutofillProfileSyncableService::DataBundle::DataBundle() {} | 576 AutofillProfileSyncableService::DataBundle::DataBundle() {} |
576 | 577 |
577 AutofillProfileSyncableService::DataBundle::~DataBundle() {} | 578 AutofillProfileSyncableService::DataBundle::~DataBundle() {} |
OLD | NEW |