#include "components/autofill/core/browser/data_model/autofill_profile_comparator.h"
#include <algorithm>
#include <optional>
#include <string_view>
#include <vector>
#include "base/i18n/char_iterator.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversion_utils.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_data_util.h"
#include "components/autofill/core/browser/data_model/autofill_structured_address_utils.h"
#include "components/autofill/core/browser/data_model/borrowed_transliterator.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/geo/autofill_country.h"
#include "components/autofill/core/browser/metrics/autofill_metrics.h"
#include "components/autofill/core/common/autofill_clock.h"
#include "components/autofill/core/common/autofill_l10n_util.h"
#include "third_party/libphonenumber/phonenumber_api.h"
PhoneNumberUtil;
namespace autofill {
namespace {
constexpr char16_t kSpace[] = …;
std::ostream& operator<<(std::ostream& os,
const ::i18n::phonenumbers::PhoneNumber& n) { … }
bool IsPunctuationOrWhitespace(const int8_t character) { … }
class NormalizingIterator { … };
NormalizingIterator::NormalizingIterator(
std::u16string_view text,
AutofillProfileComparator::WhitespaceSpec whitespace_spec)
: … { … }
NormalizingIterator::~NormalizingIterator() = default;
void NormalizingIterator::Advance() { … }
bool NormalizingIterator::End() { … }
bool NormalizingIterator::EndsInSkippableCharacters() { … }
int32_t NormalizingIterator::GetNextChar() { … }
}
FieldTypeSet GetUserVisibleTypes() { … }
AutofillProfileComparator::AutofillProfileComparator(
std::string_view app_locale)
: … { … }
AutofillProfileComparator::~AutofillProfileComparator() = default;
std::vector<ProfileValueDifference>
AutofillProfileComparator::GetProfileDifference(
const AutofillProfile& first_profile,
const AutofillProfile& second_profile,
FieldTypeSet types,
const std::string& app_locale) { … }
base::flat_map<FieldType, std::pair<std::u16string, std::u16string>>
AutofillProfileComparator::GetProfileDifferenceMap(
const AutofillProfile& first_profile,
const AutofillProfile& second_profile,
FieldTypeSet types,
const std::string& app_locale) { … }
std::vector<ProfileValueDifference>
AutofillProfileComparator::GetSettingsVisibleProfileDifference(
const AutofillProfile& first_profile,
const AutofillProfile& second_profile,
const std::string& app_locale) { … }
base::flat_map<FieldType, std::pair<std::u16string, std::u16string>>
AutofillProfileComparator::GetSettingsVisibleProfileDifferenceMap(
const AutofillProfile& first_profile,
const AutofillProfile& second_profile,
const std::string& app_locale) { … }
bool AutofillProfileComparator::Compare(std::u16string_view text1,
std::u16string_view text2,
WhitespaceSpec whitespace_spec) const { … }
bool AutofillProfileComparator::HasOnlySkippableCharacters(
std::u16string_view text) const { … }
std::u16string AutofillProfileComparator::NormalizeForComparison(
std::u16string_view text,
AutofillProfileComparator::WhitespaceSpec whitespace_spec) { … }
bool AutofillProfileComparator::AreMergeable(const AutofillProfile& p1,
const AutofillProfile& p2) const { … }
bool AutofillProfileComparator::MergeNames(const AutofillProfile& p1,
const AutofillProfile& p2,
NameInfo& name_info) const { … }
bool AutofillProfileComparator::MergeCJKNames(const AutofillProfile& p1,
const AutofillProfile& p2,
NameInfo& info) const { … }
bool AutofillProfileComparator::IsNameVariantOf(
const std::u16string& full_name_1,
const std::u16string& full_name_2) const { … }
bool AutofillProfileComparator::MergeEmailAddresses(
const AutofillProfile& p1,
const AutofillProfile& p2,
EmailInfo& email_info) const { … }
bool AutofillProfileComparator::MergeCompanyNames(
const AutofillProfile& p1,
const AutofillProfile& p2,
CompanyInfo& company_info) const { … }
bool AutofillProfileComparator::MergePhoneNumbers(
const AutofillProfile& p1,
const AutofillProfile& p2,
PhoneNumber& phone_number) const { … }
bool AutofillProfileComparator::MergeAddresses(const AutofillProfile& p1,
const AutofillProfile& p2,
Address& address) const { … }
std::optional<FieldTypeSet>
AutofillProfileComparator::NonMergeableSettingVisibleTypes(
const AutofillProfile& a,
const AutofillProfile& b) const { … }
bool AutofillProfileComparator::ProfilesHaveDifferentSettingsVisibleValues(
const AutofillProfile& p1,
const AutofillProfile& p2,
const std::string& app_locale) { … }
bool AutofillProfileComparator::IsMergeCandidate(
const AutofillProfile& existing_profile,
const AutofillProfile& new_profile,
const std::string& app_locale) { … }
std::set<std::u16string_view> AutofillProfileComparator::UniqueTokens(
std::u16string_view s) { … }
AutofillProfileComparator::CompareTokensResult
AutofillProfileComparator::CompareTokens(std::u16string_view s1,
std::u16string_view s2) { … }
std::u16string AutofillProfileComparator::GetNonEmptyOf(
const AutofillProfile& p1,
const AutofillProfile& p2,
AutofillType t) const { … }
std::set<std::u16string> AutofillProfileComparator::GetNamePartVariants(
const std::u16string& name_part) { … }
bool AutofillProfileComparator::HaveMergeableNames(
const AutofillProfile& p1,
const AutofillProfile& p2) const { … }
bool AutofillProfileComparator::HaveMergeableEmailAddresses(
const AutofillProfile& p1,
const AutofillProfile& p2) const { … }
bool AutofillProfileComparator::HaveMergeableCompanyNames(
const AutofillProfile& p1,
const AutofillProfile& p2) const { … }
bool AutofillProfileComparator::HaveMergeablePhoneNumbers(
const AutofillProfile& p1,
const AutofillProfile& p2) const { … }
bool AutofillProfileComparator::HaveMergeableAddresses(
const AutofillProfile& p1,
const AutofillProfile& p2) const { … }
}