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

// Copyright 2017 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_data_importer.h"

#include <stddef.h>
#include <stdint.h>

#include <algorithm>
#include <limits>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <utility>

#include "base/check_deref.h"
#include "base/containers/flat_map.h"
#include "base/functional/bind.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "components/autofill/core/browser/address_data_manager.h"
#include "components/autofill/core/browser/address_profile_save_manager.h"
#include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/autofill_data_util.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_plus_address_delegate.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/country_type.h"
#include "components/autofill/core/browser/data_model/autofill_i18n_api.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/data_model/autofill_profile_comparator.h"
#include "components/autofill/core/browser/data_model/autofill_structured_address_name.h"
#include "components/autofill/core/browser/data_model/autofill_structured_address_utils.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/data_model/iban.h"
#include "components/autofill/core/browser/data_model/phone_number.h"
#include "components/autofill/core/browser/field_type_utils.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_parsing/form_field_parser.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/browser/form_types.h"
#include "components/autofill/core/browser/geo/autofill_country.h"
#include "components/autofill/core/browser/geo/phone_number_i18n.h"
#include "components/autofill/core/browser/logging/log_manager.h"
#include "components/autofill/core/browser/metrics/profile_import_metrics.h"
#include "components/autofill/core/browser/payments/credit_card_save_manager.h"
#include "components/autofill/core/browser/payments/iban_save_manager.h"
#include "components/autofill/core/browser/payments/local_card_migration_manager.h"
#include "components/autofill/core/browser/payments/mandatory_reauth_manager.h"
#include "components/autofill/core/browser/payments/payments_autofill_client.h"
#include "components/autofill/core/browser/payments/payments_network_interface.h"
#include "components/autofill/core/browser/payments/virtual_card_enrollment_manager.h"
#include "components/autofill/core/browser/payments_data_manager.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/profile_requirement_utils.h"
#include "components/autofill/core/browser/validation.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_payments_features.h"
#include "components/autofill/core/common/autofill_util.h"

namespace autofill {

namespace {

AddressImportRequirement;

// Return true if the |field_type| and |value| are valid within the context
// of importing a form.
bool IsValidFieldTypeAndValue(
    const base::flat_map<FieldType, std::u16string>& observed_types,
    FieldType field_type,
    const std::u16string& value,
    LogBuffer* import_log_buffer) {}

// `extracted_credit_card` refers to the credit card that was most recently
// submitted and |fetched_card_instrument_id| refers to the instrument id of the
// most recently downstreamed (fetched from the server) credit card.
// These need to match to offer virtual card enrollment for the
// `extracted_credit_card`.
bool ShouldOfferVirtualCardEnrollment(
    const std::optional<CreditCard>& extracted_credit_card,
    std::optional<int64_t> fetched_card_instrument_id) {}

bool HasSynthesizedTypes(
    const base::flat_map<FieldType, std::u16string>& observed_field_values,
    AddressCountryCode country_code) {}

}  // namespace

FormDataImporter::ExtractedFormData::ExtractedFormData() = default;

FormDataImporter::ExtractedFormData::ExtractedFormData(
    const ExtractedFormData& extracted_form_data) = default;

FormDataImporter::ExtractedFormData&
FormDataImporter::ExtractedFormData::operator=(
    const ExtractedFormData& extracted_form_data) = default;

FormDataImporter::ExtractedFormData::~ExtractedFormData() = default;

FormDataImporter::FormDataImporter(AutofillClient* client,
                                   history::HistoryService* history_service,
                                   const std::string& app_locale)
    :{}

FormDataImporter::~FormDataImporter() = default;

FormDataImporter::AddressProfileImportCandidate::
    AddressProfileImportCandidate() = default;
FormDataImporter::AddressProfileImportCandidate::AddressProfileImportCandidate(
    const FormDataImporter::AddressProfileImportCandidate& other) = default;
FormDataImporter::AddressProfileImportCandidate::
    ~AddressProfileImportCandidate() = default;

void FormDataImporter::ImportAndProcessFormData(
    const FormStructure& submitted_form,
    bool profile_autofill_enabled,
    bool payment_methods_autofill_enabled) {}

bool FormDataImporter::ComplementCountry(AutofillProfile& profile,
                                         LogBuffer* import_log_buffer) {}

bool FormDataImporter::SetPhoneNumber(
    AutofillProfile& profile,
    const PhoneNumber::PhoneCombineHelper& combined_phone) {}

void FormDataImporter::RemoveInaccessibleProfileValues(
    AutofillProfile& profile) {}

void FormDataImporter::CacheFetchedVirtualCard(
    const std::u16string& last_four) {}

void FormDataImporter::SetFetchedCardInstrumentId(int64_t instrument_id) {}

FormDataImporter::ExtractedFormData FormDataImporter::ExtractFormData(
    const FormStructure& submitted_form,
    bool profile_autofill_enabled,
    bool payment_methods_autofill_enabled) {}

size_t FormDataImporter::ExtractAddressProfiles(
    const FormStructure& form,
    std::vector<FormDataImporter::AddressProfileImportCandidate>*
        address_profile_import_candidates) {}

AutofillProfile FormDataImporter::ConstructProfileFromObservedValues(
    const base::flat_map<FieldType, std::u16string>& observed_values,
    LogBuffer* import_log_buffer,
    ProfileImportMetadata& import_metadata) {}

base::flat_map<FieldType, std::u16string>
FormDataImporter::GetAddressObservedFieldValues(
    base::span<const AutofillField* const> section_fields,
    ProfileImportMetadata& import_metadata,
    LogBuffer* import_log_buffer,
    bool& has_invalid_field_types,
    bool& has_multiple_distinct_email_addresses,
    bool& has_address_related_fields) const {}

bool FormDataImporter::ExtractAddressProfileFromSection(
    base::span<const AutofillField* const> section_fields,
    const GURL& source_url,
    std::vector<FormDataImporter::AddressProfileImportCandidate>*
        address_profile_import_candidates,
    LogBuffer* import_log_buffer) {}

bool FormDataImporter::ProcessAddressProfileImportCandidates(
    const std::vector<FormDataImporter::AddressProfileImportCandidate>&
        address_profile_import_candidates,
    bool allow_prompt) {}

bool FormDataImporter::ProcessExtractedCreditCard(
    const FormStructure& submitted_form,
    const std::optional<CreditCard>& extracted_credit_card,
    bool is_credit_card_upstream_enabled) {}

bool FormDataImporter::ProcessIbanImportCandidate(Iban& extracted_iban) {}

std::optional<CreditCard> FormDataImporter::ExtractCreditCard(
    const FormStructure& form) {}

std::optional<CreditCard> FormDataImporter::TryMatchingExistingServerCard(
    const CreditCard& candidate) {}

std::optional<Iban> FormDataImporter::ExtractIban(const FormStructure& form) {}

FormDataImporter::ExtractCreditCardFromFormResult
FormDataImporter::ExtractCreditCardFromForm(const FormStructure& form) {}

Iban FormDataImporter::ExtractIbanFromForm(const FormStructure& form) {}

// TODO(crbug.com/40270301): Move ShouldOfferCreditCardSave to
// credit_card_save_manger and combine all card and CVC save logic to
// ProceedWithSavingIfApplicable function.
bool FormDataImporter::ShouldOfferCreditCardSave(
    const std::optional<CreditCard>& extracted_credit_card,
    bool is_credit_card_upstream_enabled) {}

void FormDataImporter::OnAddressDataChanged() {}

void FormDataImporter::OnHistoryDeletions(
    history::HistoryService* history_service,
    const history::DeletionInfo& deletion_info) {}

void FormDataImporter::
    SetPaymentMethodTypeIfNonInteractiveAuthenticationFlowCompleted(
        std::optional<NonInteractivePaymentMethodType>
            payment_method_type_if_non_interactive_authentication_flow_completed) {}

AddressDataManager& FormDataImporter::address_data_manager() {}

PaymentsDataManager& FormDataImporter::payments_data_manager() {}

}  // namespace autofill