chromium/components/autofill/core/browser/form_processing/name_processing_util.cc

// Copyright 2021 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_processing/name_processing_util.h"

#include <algorithm>
#include <array>
#include <limits>
#include <string_view>
#include <utility>

#include "base/check.h"
#include "base/feature_list.h"
#include "base/ranges/algorithm.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_regexes.h"

namespace autofill {

namespace {

// Common prefixes are only removed if a minimum number of fields are present
// and a sufficiently long prefix is found. These values are chosen to be
// effective against web frameworks which prepend prefixes such as
// "ctl01$ctl00$MainContentRegion$" on all fields.
constexpr size_t kCommonNamePrefixRemovalFieldThreshold =;
// Minimum required length for prefixes to be removed.
constexpr size_t kMinCommonNamePrefixLength =;

// Returns true if `parseable_name` is a valid parseable_name. To be considered
// valid, the string cannot be empty or consist of digits only.
// This condition prevents the logic from simplifying strings like
// "address-line-1", "address-line-2" to "1", "2".
bool IsValidParseableName(std::u16string_view parseable_name) {}

// Tries to remove an affix of length `len` from all `strings`. The removal
// fails if one of the resulting strings is not `IsValidParseableName()`.
// Assumes that all strings are at least `len` long.
void MaybeRemoveAffix(base::span<std::u16string_view> strings,
                      size_t len,
                      bool prefix) {}

}  // namespace

size_t FindLongestCommonAffixLength(base::span<std::u16string_view> strings,
                                    bool prefix) {}

void ComputeParseableNames(base::span<std::u16string_view> field_names) {}

}  // namespace autofill