#include "components/autofill/core/browser/autofill_external_delegate.h"
#include <stddef.h>
#include <functional>
#include <optional>
#include <utility>
#include "base/check.h"
#include "base/check_deref.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/fixed_flat_set.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/i18n/case_conversion.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.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/autocomplete_history_manager.h"
#include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/autofill_compose_delegate.h"
#include "components/autofill/core/browser/autofill_driver.h"
#include "components/autofill/core/browser/autofill_granular_filling_utils.h"
#include "components/autofill/core/browser/autofill_plus_address_delegate.h"
#include "components/autofill/core/browser/autofill_trigger_details.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/browser_autofill_manager.h"
#include "components/autofill/core/browser/field_filling_address_util.h"
#include "components/autofill/core/browser/field_type_utils.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/filling_product.h"
#include "components/autofill/core/browser/metrics/autofill_in_devtools_metrics.h"
#include "components/autofill/core/browser/metrics/autofill_metrics.h"
#include "components/autofill/core/browser/metrics/granular_filling_metrics.h"
#include "components/autofill/core/browser/metrics/log_event.h"
#include "components/autofill/core/browser/metrics/suggestions_list_metrics.h"
#include "components/autofill/core/browser/payments/credit_card_access_manager.h"
#include "components/autofill/core/browser/payments/iban_access_manager.h"
#include "components/autofill/core/browser/payments/payments_autofill_client.h"
#include "components/autofill/core/browser/payments_data_manager.h"
#include "components/autofill/core/browser/ui/popup_open_enums.h"
#include "components/autofill/core/browser/ui/suggestion.h"
#include "components/autofill/core/browser/ui/suggestion_type.h"
#include "components/autofill/core/common/aliases.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/autofill/core/common/autofill_util.h"
#include "components/autofill/core/common/mojom/autofill_types.mojom-shared.h"
#include "components/autofill/core/common/signatures.h"
#include "components/signin/public/base/signin_metrics.h"
#include "components/strings/grit/components_strings.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "ui/accessibility/platform/ax_platform.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/rect.h"
namespace autofill {
namespace {
const AutofillProfile* GetTestAddressByGUID(
base::span<const AutofillProfile> test_addresses,
const std::string& guid) { … }
AutofillTriggerSource TriggerSourceFromSuggestionTriggerSource(
AutofillSuggestionTriggerSource suggestion_trigger_source) { … }
const Suggestion* FindTestSuggestion(AutofillClient& client,
base::span<const Suggestion> suggestions,
int index) { … }
void PossiblyRemoveAutofillWarnings(std::vector<Suggestion>& suggestions) { … }
}
int AutofillExternalDelegate::shortcut_test_suggestion_index_ = …;
AutofillExternalDelegate::AutofillExternalDelegate(
BrowserAutofillManager* manager)
: … { … }
AutofillExternalDelegate::~AutofillExternalDelegate() = default;
bool AutofillExternalDelegate::IsAutofillAndFirstLayerSuggestionId(
SuggestionType item_id) { … }
void AutofillExternalDelegate::OnQuery(
const FormData& form,
const FormFieldData& field,
const gfx::Rect& caret_bounds,
AutofillSuggestionTriggerSource trigger_source) { … }
const AutofillField* AutofillExternalDelegate::GetQueriedAutofillField() const { … }
void AutofillExternalDelegate::OnSuggestionsReturned(
FieldGlobalId field_id,
const std::vector<Suggestion>& input_suggestions,
std::optional<autofill_metrics::SuggestionRankingContext>
suggestion_ranking_context) { … }
void AutofillExternalDelegate::AttemptToDisplayAutofillSuggestions(
std::vector<Suggestion> suggestions,
std::optional<autofill_metrics::SuggestionRankingContext>
suggestion_ranking_context,
AutofillSuggestionTriggerSource trigger_source,
bool is_update) { … }
SuggestionType
AutofillExternalDelegate::GetLastAcceptedSuggestionToFillForSection(
const Section& section) const { … }
bool AutofillExternalDelegate::HasActiveScreenReader() const { … }
void AutofillExternalDelegate::OnAutofillAvailabilityEvent(
mojom::AutofillSuggestionAvailability suggestion_availability) { … }
void AutofillExternalDelegate::SetCurrentDataListValues(
std::vector<SelectOption> datalist) { … }
absl::variant<AutofillDriver*, password_manager::PasswordManagerDriver*>
AutofillExternalDelegate::GetDriver() { … }
void AutofillExternalDelegate::OnSuggestionsShown() { … }
void AutofillExternalDelegate::OnSuggestionsHidden() { … }
void AutofillExternalDelegate::DidSelectSuggestion(
const Suggestion& suggestion) { … }
void AutofillExternalDelegate::DidAcceptSuggestion(
const Suggestion& suggestion,
const SuggestionPosition& position) { … }
void AutofillExternalDelegate::DidPerformButtonActionForSuggestion(
const Suggestion& suggestion,
const SuggestionButtonAction& button_action) { … }
bool AutofillExternalDelegate::RemoveSuggestion(const Suggestion& suggestion) { … }
void AutofillExternalDelegate::DidEndTextFieldEditing() { … }
void AutofillExternalDelegate::ClearPreviewedForm() { … }
FillingProduct AutofillExternalDelegate::GetMainFillingProduct() const { … }
base::WeakPtr<AutofillExternalDelegate> AutofillExternalDelegate::GetWeakPtr() { … }
void AutofillExternalDelegate::ShowEditAddressProfileDialog(
const std::string& guid) { … }
void AutofillExternalDelegate::ShowDeleteAddressProfileDialog(
const std::string& guid) { … }
void AutofillExternalDelegate::OnAddressEditorClosed(
AutofillClient::AddressPromptUserDecision decision,
base::optional_ref<const AutofillProfile> edited_profile) { … }
void AutofillExternalDelegate::OnDeleteDialogClosed(const std::string& guid,
bool user_accepted_delete) { … }
void AutofillExternalDelegate::OnAddressDataChanged() { … }
void AutofillExternalDelegate::OnCreditCardScanned(
const AutofillTriggerSource trigger_source,
const CreditCard& card) { … }
void AutofillExternalDelegate::PreviewFieldByFieldFillingSuggestion(
const Suggestion& suggestion) { … }
void AutofillExternalDelegate::FillFieldByFieldFillingSuggestion(
const Suggestion& suggestion,
const SuggestionPosition& position) { … }
void AutofillExternalDelegate::PreviewAddressFieldByFieldFillingSuggestion(
const AutofillProfile& profile,
const Suggestion& suggestion) { … }
void AutofillExternalDelegate::FillAddressFieldByFieldFillingSuggestion(
const AutofillProfile& profile,
const Suggestion& suggestion,
const SuggestionPosition& position) { … }
void AutofillExternalDelegate::PreviewCreditCardFieldByFieldFillingSuggestion(
const Suggestion& suggestion) { … }
void AutofillExternalDelegate::FillCreditCardFieldByFieldFillingSuggestion(
const CreditCard& credit_card,
const Suggestion& suggestion) { … }
void AutofillExternalDelegate::OnCreditCardFetched(
CreditCardFetchResult result,
const CreditCard* credit_card) { … }
void AutofillExternalDelegate::OnVirtualCreditCardFetched(
CreditCardFetchResult result,
const CreditCard* credit_card) { … }
void AutofillExternalDelegate::FillAutofillFormData(
SuggestionType type,
Suggestion::BackendId backend_id,
std::optional<SuggestionPosition> position,
bool is_preview,
const AutofillTriggerDetails& trigger_details) { … }
void AutofillExternalDelegate::InsertDataListValues(
std::vector<Suggestion>& suggestions) const { … }
bool AutofillExternalDelegate::IsPaymentsManualFallbackOnNonPaymentsField()
const { … }
AutofillSuggestionTriggerSource
AutofillExternalDelegate::GetReopenTriggerSource() const { … }
void AutofillExternalDelegate::LogRankingContextAfterSuggestionAccepted(
const Suggestion& accepted_suggestion) { … }
void AutofillExternalDelegate::DidAcceptAddressSuggestion(
const Suggestion& suggestion,
const SuggestionPosition& position) { … }
void AutofillExternalDelegate::DidAcceptPaymentsSuggestion(
const Suggestion& suggestion,
const SuggestionPosition& position) { … }
}