chromium/components/autofill/core/browser/autofill_data_util.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/autofill/core/browser/autofill_data_util.h"

#include <array>
#include <iterator>
#include <string_view>
#include <vector>

#include "base/containers/contains.h"
#include "base/i18n/char_iterator.h"
#include "base/no_destructor.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/branding_buildflags.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/browser/geo/autofill_country.h"
#include "components/autofill/core/browser/webdata/autofill_table_utils.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/autofill/core/common/credit_card_network_identifiers.h"
#include "components/grit/components_scaled_resources.h"
#include "components/strings/grit/components_strings.h"
#include "third_party/icu/source/common/unicode/uscript.h"
#include "third_party/re2/src/re2/re2.h"

namespace autofill::data_util {

kAddress;
kEmail;
kName;
kPhone;

namespace {

// Mappings from Chrome card networks to Payment Request API basic card payment
// spec networks and icons. Note that "generic" is not in the spec.
// https://w3c.github.io/webpayments-methods-card/#method-id
constexpr PaymentRequestData kPaymentRequestData[]{};

constexpr PaymentRequestData kPaymentRequestDataForNewNetworkImages[]{};

constexpr PaymentRequestData kGenericPaymentRequestData =;

constexpr PaymentRequestData kGenericPaymentRequestDataForNewNetworkImages =;

constexpr auto kNamePrefixes =;

constexpr auto kNameSuffixes =;

constexpr auto kFamilyNamePrefixes =;

// The common and non-ambiguous CJK surnames (last names) that have more than
// one character.
constexpr auto kCommonCjkMultiCharSurnames =;

// All Korean surnames that have more than one character, even the
// rare/ambiguous ones.
constexpr auto kKoreanMultiCharSurnames =;

// Returns true if `set` contains `element`, modulo a final period.
bool ContainsString(base::span<const std::string_view> set,
                    std::u16string_view element) {}

// Removes common name prefixes from `name_tokens`.
void StripPrefixes(std::vector<std::u16string_view>* name_tokens) {}

// Removes common name suffixes from `name_tokens`.
void StripSuffixes(std::vector<std::u16string_view>* name_tokens) {}

// Find whether `name` starts with any of the strings from the array
// `prefixes`. The returned value is the length of the prefix found, or 0 if
// none is found.
size_t StartsWithAny(std::u16string_view name,
                     base::span<const std::u16string_view> prefixes) {}

// Returns true if |c| is a CJK (Chinese, Japanese, Korean) character, for any
// of the CJK alphabets.
bool IsCJKCharacter(UChar32 c) {}

// Returns true if |c| is a Korean Hangul character.
bool IsHangulCharacter(UChar32 c) {}

// Returns true if |name| looks like a Korean name, made up entirely of Hangul
// characters or spaces. |name| should already be confirmed to be a CJK name, as
// per |IsCJKName()|.
bool IsHangulName(std::u16string_view name) {}

// Tries to split a Chinese, Japanese, or Korean name into its given name &
// surname parts, and puts the result in |parts|. If splitting did not work for
// whatever reason, returns false.
bool SplitCJKName(const std::vector<std::u16string_view>& name_tokens,
                  NameParts* parts) {}

void AddGroupToBitmask(uint32_t* group_bitmask, FieldType type) {}

}  // namespace

bool ContainsName(uint32_t groups) {}

bool ContainsAddress(uint32_t groups) {}

bool ContainsEmail(uint32_t groups) {}

bool ContainsPhone(uint32_t groups) {}

uint32_t DetermineGroups(const FormStructure& form) {}

uint32_t DetermineGroups(const FieldTypeSet& types) {}

bool IsSupportedFormType(uint32_t groups) {}

std::string GetSuffixForProfileFormType(uint32_t bitmask) {}

std::string TruncateUTF8(const std::string& data) {}

bool IsCreditCardExpirationType(FieldType type) {}

bool IsCJKName(std::u16string_view name) {}

NameParts SplitName(std::u16string_view name) {}

std::u16string JoinNameParts(std::u16string_view given,
                             std::u16string_view middle,
                             std::u16string_view family) {}

const PaymentRequestData& GetPaymentRequestData(
    const std::string& issuer_network) {}

const char* GetIssuerNetworkForBasicCardIssuerNetwork(
    const std::string& basic_card_issuer_network) {}

bool IsValidBasicCardIssuerNetwork(
    const std::string& basic_card_issuer_network) {}

bool IsValidCountryCode(const std::string& country_code) {}

bool IsValidCountryCode(const std::u16string& country_code) {}

std::string GetCountryCodeWithFallback(const autofill::AutofillProfile& profile,
                                       const std::string& app_locale) {}

}  // namespace autofill::data_util