chromium/components/autofill/core/browser/form_parsing/form_field_parser.cc

// Copyright 2013 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/form_parsing/form_field_parser.h"

#include <algorithm>
#include <cstddef>
#include <iterator>
#include <numeric>
#include <string_view>

#include "base/auto_reset.h"
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_parsing/address_field_parser.h"
#include "components/autofill/core/browser/form_parsing/address_field_parser_ng.h"
#include "components/autofill/core/browser/form_parsing/autofill_parsing_utils.h"
#include "components/autofill/core/browser/form_parsing/autofill_scanner.h"
#include "components/autofill/core/browser/form_parsing/credit_card_field_parser.h"
#include "components/autofill/core/browser/form_parsing/email_field_parser.h"
#include "components/autofill/core/browser/form_parsing/form_field_parser.h"
#include "components/autofill/core/browser/form_parsing/iban_field_parser.h"
#include "components/autofill/core/browser/form_parsing/merchant_promo_code_field_parser.h"
#include "components/autofill/core/browser/form_parsing/name_field_parser.h"
#include "components/autofill/core/browser/form_parsing/numeric_quantity_field_parser.h"
#include "components/autofill/core/browser/form_parsing/phone_field_parser.h"
#include "components/autofill/core/browser/form_parsing/price_field_parser.h"
#include "components/autofill/core/browser/form_parsing/search_field_parser.h"
#include "components/autofill/core/browser/form_parsing/standalone_cvc_field_parser.h"
#include "components/autofill/core/browser/form_parsing/travel_field_parser.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/browser/logging/log_manager.h"
#include "components/autofill/core/common/autocomplete_parsing_util.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_internals/log_message.h"
#include "components/autofill/core/common/autofill_internals/logging_scope.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/autofill/core/common/autofill_regexes.h"
#include "components/autofill/core/common/autofill_util.h"
#include "components/autofill/core/common/dense_set.h"

namespace autofill {

namespace {

constexpr char16_t kEmptyLabelRegex[] =;

constexpr bool IsEmpty(const char16_t* s) {}

AutofillRegexCache& GetAutofillRegexCache() {}

}  // namespace

RegexMatchesCache::RegexMatchesCache(int capacity) :{}
RegexMatchesCache::~RegexMatchesCache() = default;

RegexMatchesCache::Key RegexMatchesCache::BuildKey(
    std::u16string_view input,
    std::u16string_view pattern) {}

std::optional<bool> RegexMatchesCache::Get(RegexMatchesCache::Key key) {}

void RegexMatchesCache::Put(RegexMatchesCache::Key key, bool value) {}

ParsingContext::ParsingContext(GeoIpCountryCode client_country,
                               LanguageCode page_language,
                               PatternSource pattern_source,
                               LogManager* log_manager)
    :{}

ParsingContext::~ParsingContext() = default;

// static
bool FormFieldParser::MatchesRegexWithCache(
    ParsingContext& context,
    std::u16string_view input,
    std::u16string_view pattern,
    std::vector<std::u16string>* groups) {}

// static
void FormFieldParser::ParseFormFields(
    ParsingContext& context,
    const std::vector<std::unique_ptr<AutofillField>>& fields,
    bool is_form_tag,
    FieldCandidatesMap& field_candidates) {}

// static
void FormFieldParser::ClearCandidatesIfHeuristicsDidNotFindEnoughFields(
    ParsingContext& context,
    const std::vector<std::unique_ptr<AutofillField>>& fields,
    FieldCandidatesMap& field_candidates,
    bool is_form_tag) {}

void FormFieldParser::ParseSingleFieldForms(
    ParsingContext& context,
    const std::vector<std::unique_ptr<AutofillField>>& fields,
    FieldCandidatesMap& field_candidates) {}

void FormFieldParser::ParseStandaloneCVCFields(
    ParsingContext& context,
    const std::vector<std::unique_ptr<AutofillField>>& fields,
    FieldCandidatesMap& field_candidates) {}

void FormFieldParser::ParseStandaloneEmailFields(
    ParsingContext& context,
    const std::vector<std::unique_ptr<AutofillField>>& fields,
    FieldCandidatesMap& field_candidates) {}

// static
bool FormFieldParser::FieldMatchesMatchPatternRef(
    ParsingContext& context,
    base::span<const MatchPatternRef> patterns,
    const AutofillField& field,
    const char* regex_name,
    std::initializer_list<MatchParams (*)(const MatchParams&)> projections) {}

// static
bool FormFieldParser::ParseField(
    ParsingContext& context,
    AutofillScanner* scanner,
    base::span<const MatchPatternRef> patterns,
    raw_ptr<AutofillField>* match,
    const char* regex_name,
    MatchParams (*projection)(const MatchParams&)) {}

// static
bool FormFieldParser::ParseInAnyOrder(
    AutofillScanner* scanner,
    std::vector<
        std::pair<raw_ptr<AutofillField>*, base::RepeatingCallback<bool()>>>
        fields_and_parsers) {}

// static
bool FormFieldParser::ParseEmptyLabel(ParsingContext& context,
                                      AutofillScanner* scanner,
                                      raw_ptr<AutofillField>* match) {}

// static
void FormFieldParser::AddClassification(const AutofillField* field,
                                        FieldType type,
                                        float score,
                                        FieldCandidatesMap& field_candidates) {}

// static
std::vector<raw_ptr<AutofillField, VectorExperimental>>
FormFieldParser::RemoveCheckableFields(
    const std::vector<std::unique_ptr<AutofillField>>& fields) {}

bool FormFieldParser::Match(ParsingContext& context,
                            const AutofillField* field,
                            std::u16string_view pattern,
                            DenseSet<MatchAttribute> match_attributes,
                            const char* regex_name) {}

// static
void FormFieldParser::ParseFormFieldsPass(
    ParseFunction parse,
    ParsingContext& context,
    const std::vector<raw_ptr<AutofillField, VectorExperimental>>& fields,
    FieldCandidatesMap& field_candidates) {}

// static
bool FormFieldParser::MatchesFormControlType(
    FormControlType type,
    DenseSet<FormControlType> match_type) {}

// static
bool FormFieldParser::IsSingleFieldParseableType(FieldType field_type) {}

}  // namespace autofill