Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(660)

Side by Side Diff: components/autofill/core/browser/autofill_profile.cc

Issue 1989173005: [Autofill] Dedupe similar profiles on insertion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_profile.h" 5 #include "components/autofill/core/browser/autofill_profile.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 } 424 }
425 425
426 bool AutofillProfile::operator==(const AutofillProfile& profile) const { 426 bool AutofillProfile::operator==(const AutofillProfile& profile) const {
427 return guid() == profile.guid() && EqualsSansGuid(profile); 427 return guid() == profile.guid() && EqualsSansGuid(profile);
428 } 428 }
429 429
430 bool AutofillProfile::operator!=(const AutofillProfile& profile) const { 430 bool AutofillProfile::operator!=(const AutofillProfile& profile) const {
431 return !operator==(profile); 431 return !operator==(profile);
432 } 432 }
433 433
434 const base::string16 AutofillProfile::PrimaryValue() const { 434 const base::string16 AutofillProfile::PrimaryValue(
435 return GetRawInfo(NAME_FIRST) + GetRawInfo(NAME_LAST) + 435 const std::string& app_locale) const {
436 GetRawInfo(ADDRESS_HOME_LINE1) + GetRawInfo(ADDRESS_HOME_CITY); 436 std::vector<base::string16> primary_values{
437 GetInfo(AutofillType(NAME_FIRST), app_locale),
438 GetInfo(AutofillType(NAME_LAST), app_locale),
439 GetInfo(AutofillType(ADDRESS_HOME_LINE1), app_locale),
440 GetInfo(AutofillType(ADDRESS_HOME_CITY), app_locale)};
441 return base::JoinString(primary_values, base::UTF8ToUTF16(" "));
Roger McFarlane (Chromium) 2016/06/09 20:37:36 Note that JoinString isn't smart about empty strin
sebsg 2016/06/12 21:41:25 Good point. It should be better now. Anyway, as so
437 } 442 }
438 443
439 bool AutofillProfile::IsSubsetOf(const AutofillProfile& profile, 444 bool AutofillProfile::IsSubsetOf(const AutofillProfile& profile,
440 const std::string& app_locale) const { 445 const std::string& app_locale) const {
441 ServerFieldTypeSet types; 446 ServerFieldTypeSet types;
442 GetSupportedTypes(&types); 447 GetSupportedTypes(&types);
443 return IsSubsetOfForFieldSet(profile, app_locale, types); 448 return IsSubsetOfForFieldSet(profile, app_locale, types);
444 } 449 }
445 450
446 bool AutofillProfile::IsSubsetOfForFieldSet( 451 bool AutofillProfile::IsSubsetOfForFieldSet(
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " " 1089 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " "
1085 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " " 1090 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " "
1086 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " " 1091 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " "
1087 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " " 1092 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " "
1088 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " " 1093 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " "
1089 << profile.language_code() << " " 1094 << profile.language_code() << " "
1090 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 1095 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
1091 } 1096 }
1092 1097
1093 } // namespace autofill 1098 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698