chromium/components/autofill/core/browser/form_parsing/phone_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/phone_field_parser.h"

#include <memory>
#include <string>
#include <string_view>
#include <utility>

#include "base/check.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/form_parsing/autofill_scanner.h"
#include "components/autofill/core/browser/form_parsing/regex_patterns.h"
#include "components/autofill/core/browser/metrics/autofill_metrics.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_regex_constants.h"
#include "components/autofill/core/common/autofill_regexes.h"

namespace autofill {
namespace {

// Minimum limit on the number of the options of the select field for
// determining the field to be of |PHONE_HOME_COUNTRY_CODE| type.
constexpr int kMinSelectOptionsForCountryCode =;

// Maximum limit on the number of the options of the select field for
// determining the field to be of |PHONE_HOME_COUNTRY_CODE| type.
// Currently, there are approximately 250 countries that have been assigned a
// phone country code, therefore, 275 is taken as the upper bound.
constexpr int kMaxSelectOptionsForCountryCode =;

// Minimum percentage of options in select field that should look like a
// country code in order to classify the field as a |PHONE_HOME_COUNTRY_CODE|.
constexpr int kMinCandidatePercentageForCountryCode =;

// If a <select> element has <= |kHeuristicThresholdForCountryCode| options,
// all or all-but-one need to look like country code options. Otherwise,
// |kMinCandidatePercentageForCountryCode| is used to check for a fraction
// of country code like options.
constexpr int kHeuristicThresholdForCountryCode =;

}  // namespace

PhoneFieldParser::~PhoneFieldParser() = default;

// Phone field grammars - first matched grammar will be parsed. Suffix and
// extension are parsed separately unless they are necessary parts of the match.
// The following notation is used to describe the patterns:
// <cc> - country code field.
// <ac> - area code field.
// TODO(crbug.com/40233246): Add a separate prefix type.
// <phone> - phone or prefix.
// <suffix> - suffix.
// :N means field is limited to N characters, otherwise it is unlimited.
// (pattern <field>)? means pattern is optional and matched separately.
// static
const std::vector<PhoneFieldParser::PhoneGrammar>&
PhoneFieldParser::GetPhoneGrammars() {}

// static
bool PhoneFieldParser::LikelyAugmentedPhoneCountryCode(
    AutofillScanner* scanner,
    raw_ptr<AutofillField>* matched_field) {}

// static
bool PhoneFieldParser::ParseGrammar(ParsingContext& context,
                                    const PhoneGrammar& grammar,
                                    ParsedPhoneFields& parsed_fields,
                                    AutofillScanner* scanner) {}

// static
std::unique_ptr<FormFieldParser> PhoneFieldParser::Parse(
    ParsingContext& context,
    AutofillScanner* scanner) {}

void PhoneFieldParser::AddClassifications(
    FieldCandidatesMap& field_candidates) const {}

PhoneFieldParser::PhoneFieldParser(ParsedPhoneFields fields)
    :{}

// Returns the string representation of |phonetype_id| as it is used to key to
// identify coressponding patterns.
std::string PhoneFieldParser::GetJSONFieldType(RegexType phonetype_id) {}

// static
bool PhoneFieldParser::ParsePhoneField(ParsingContext& context,
                                       AutofillScanner* scanner,
                                       raw_ptr<AutofillField>* field,
                                       const bool is_country_code_field,
                                       const std::string& json_field_type) {}

}  // namespace autofill