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

// Copyright 2024 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_filler.h"

#include <array>
#include <optional>

#include "base/check_deref.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/hash/hash.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_data_util.h"
#include "components/autofill/core/browser/browser_autofill_manager.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/field_filling_address_util.h"
#include "components/autofill/core/browser/field_filling_payments_util.h"
#include "components/autofill/core/browser/field_type_utils.h"
#include "components/autofill/core/browser/filling_product.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/browser/logging/log_manager.h"
#include "components/autofill/core/browser/metrics/log_event.h"
#include "components/autofill/core/common/autofill_clock.h"
#include "components/autofill/core/common/autofill_features.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_regexes.h"
#include "components/autofill/core/common/autofill_util.h"
#include "components/autofill/core/common/logging/log_buffer.h"
#include "components/autofill/core/common/logging/log_macros.h"

namespace autofill {

namespace {

// Time to wait after a dynamic form change before triggering a refill.
// This is used for sites that change multiple things consecutively.
constexpr base::TimeDelta kWaitTimeForDynamicForms =;

std::string_view GetSkipFieldFillLogMessage(
    FieldFillingSkipReason skip_reason) {}

std::string FetchCountryCodeFromProfile(const AutofillProfile* profile) {}

// Returns how many fields with type |field_type| may be filled in a form at
// maximum.
size_t TypeValueFormFillingLimit(FieldType field_type) {}

std::string_view ActionPersistenceToString(
    mojom::ActionPersistence action_persistence) {}

// Returns `true` if `autofill_field`'s pre-filled value is classified as
// meaningful (guarded by `features::kAutofillOverwritePlaceholdersOnly`) and
// Autofill's behavior for filling pre-filled fields is overwriting them by
// default.
bool IsMeaningfullyPreFilled(const autofill::AutofillField& autofill_field) {}

// Returns `true` if `autofill_field`'s pre-filled value is classified as a
// placeholder (guarded by `features::kAutofillOverwritePlaceholdersOnly`) and
// Autofill's behavior for filling pre-filled fields is skipping them by
// default.
bool IsNotAPlaceholder(const autofill::AutofillField& autofill_field) {}

bool AllowPaymentSwapping(const AutofillField& trigger_field,
                          const AutofillField& field,
                          bool is_refill) {}

// Returns whether a filling action for `filling_product` should be included in
// the form autofill history.
bool ShouldRecordFillingHistory(FillingProduct filling_product) {}

}  // namespace

FieldFillingSkipReason FormFiller::GetFieldFillingSkipReason(
    const FormFieldData& field,
    const AutofillField& autofill_field,
    const AutofillField& trigger_field,
    base::flat_map<FieldType, size_t>& type_count,
    const std::optional<DenseSet<FieldTypeGroup>> type_groups_originally_filled,
    FieldTypeSet field_types_to_fill,
    FillingProduct filling_product,
    bool skip_unrecognized_autocomplete_fields,
    bool is_refill,
    bool is_expired_credit_card) {}

FormFiller::FillingContext::FillingContext(
    const AutofillField& field,
    absl::variant<const AutofillProfile*, const CreditCard*>
        profile_or_credit_card,
    base::optional_ref<const std::u16string> cvc)
    :{}

FormFiller::FillingContext::~FillingContext() = default;

FormFiller::FormFiller(BrowserAutofillManager& manager,
                       LogManager* log_manager,
                       const std::string& app_locale)
    :{}

FormFiller::~FormFiller() = default;

void FormFiller::Reset() {}

std::optional<base::TimeTicks> FormFiller::GetOriginalFillingTime(
    FormGlobalId form_id) {}

base::flat_map<FieldGlobalId, FieldFillingSkipReason>
FormFiller::GetFieldFillingSkipReasons(
    base::span<const FormFieldData> fields,
    const FormStructure& form_structure,
    const AutofillField& trigger_field,
    const FieldTypeSet& field_types_to_fill,
    std::optional<DenseSet<FieldTypeGroup>> type_groups_originally_filled,
    FillingProduct filling_product,
    bool skip_unrecognized_autocomplete_fields,
    bool is_refill,
    bool is_expired_credit_card) const {}

FillingProduct FormFiller::UndoAutofill(
    mojom::ActionPersistence action_persistence,
    FormData form,
    FormStructure& form_structure,
    const FormFieldData& trigger_field) {}

void FormFiller::FillOrPreviewField(mojom::ActionPersistence action_persistence,
                                    mojom::FieldActionType action_type,
                                    const FormData& form,
                                    const FormFieldData& field,
                                    FormStructure* form_structure,
                                    AutofillField* autofill_field,
                                    const std::u16string& value,
                                    FillingProduct filling_product,
                                    std::optional<FieldType> field_type_used) {}

void FormFiller::FillOrPreviewFormExperimental(
    mojom::ActionPersistence action_persistence,
    FillingProduct filling_product,
    const FieldTypeSet& field_types_to_fill,
    const DenseSet<FieldFillingSkipReason>& ignorable_skip_reasons,
    const FormData& form,
    const FormFieldData& trigger_field,
    FormStructure& form_structure,
    const AutofillField& autofill_trigger_field,
    const base::flat_map<FieldGlobalId, std::u16string>& values_to_fill) {}

void FormFiller::FillOrPreviewForm(
    mojom::ActionPersistence action_persistence,
    const FormData& form,
    const FormFieldData& trigger_field,
    absl::variant<const AutofillProfile*, const CreditCard*>
        profile_or_credit_card,
    base::optional_ref<const std::u16string> cvc,
    FormStructure* form_structure,
    AutofillField* autofill_trigger_field,
    const AutofillTriggerDetails& trigger_details,
    bool is_refill) {}

bool FormFiller::ShouldTriggerRefill(
    const FormStructure& form_structure,
    RefillTriggerReason refill_trigger_reason) {}

void FormFiller::ScheduleRefill(const FormData& form,
                                const FormStructure& form_structure,
                                const AutofillTriggerDetails& trigger_details) {}

void FormFiller::TriggerRefill(const FormData& form,
                               const AutofillTriggerDetails& trigger_details) {}

void FormFiller::MaybeTriggerRefillForExpirationDate(
    const FormData& form,
    const FormFieldData& field,
    const FormStructure& form_structure,
    const std::u16string& old_value,
    const AutofillTriggerDetails& trigger_details) {}

void FormFiller::SetFillingContext(FormGlobalId form_id,
                                   std::unique_ptr<FillingContext> context) {}

FormFiller::FillingContext* FormFiller::GetFillingContext(
    FormGlobalId form_id) {}

FormFiller::FieldFillingData FormFiller::GetFieldFillingData(
    const AutofillField& autofill_field,
    const absl::variant<const AutofillProfile*, const CreditCard*>
        profile_or_credit_card,
    const std::map<FieldGlobalId, std::u16string>& forced_fill_values,
    const FormFieldData& field_data,
    const std::u16string& cvc,
    mojom::ActionPersistence action_persistence,
    std::string* failure_to_fill) {}

bool FormFiller::FillField(
    AutofillField& autofill_field,
    absl::variant<const AutofillProfile*, const CreditCard*>
        profile_or_credit_card,
    const std::map<FieldGlobalId, std::u16string>& forced_fill_values,
    FormFieldData& field_data,
    const std::u16string& cvc,
    mojom::ActionPersistence action_persistence,
    std::string* failure_to_fill) {}

}  // namespace autofill