#include "components/autofill/core/browser/autofill_manager.h"
#include "base/check_deref.h"
#include "base/command_line.h"
#include "base/containers/adapters.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/thread_pool.h"
#include "components/autofill/core/browser/country_type.h"
#include "components/autofill/core/browser/crowdsourcing/autofill_crowdsourcing_encoding.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/browser/logging/log_manager.h"
#include "components/autofill/core/browser/metrics/quality_metrics.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_data_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_switches.h"
#include "components/optimization_guide/machine_learning_tflite_buildflags.h"
#include "components/translate/core/common/language_detection_details.h"
#include "components/translate/core/common/translate_constants.h"
#include "third_party/abseil-cpp/absl/cleanup/cleanup.h"
#include "ui/gfx/geometry/rect_f.h"
#if BUILDFLAG(BUILD_WITH_TFLITE_LIB)
#include "components/autofill/core/browser/ml_model/autofill_ml_prediction_model_handler.h"
#endif
namespace autofill {
namespace {
template <typename Functor, typename... Args>
base::OnceCallback<AutofillManager&(AutofillManager&, const FormData&)>
ParsingCallback(Functor&& functor, Args&&... args) { … }
template <typename Functor, typename... Args>
[[nodiscard]] base::OnceCallback<void(AutofillManager&)>
NotifyObserversCallback(Functor&& functor, Args&&... args) { … }
base::OnceCallback<void(AutofillManager&)> NotifyNoObserversCallback() { … }
std::vector<FormGlobalId> GetFormGlobalIds(base::span<const FormData> forms) { … }
AutofillField* FindAutofillFillField(const FormStructure& form,
const FormFieldData& field) { … }
bool CachedFormNeedsUpdate(const FormData& live_form,
const FormStructure& cached_form) { … }
}
void AutofillManager::LogTypePredictionsAvailable(
LogManager* log_manager,
const std::vector<raw_ptr<FormStructure, VectorExperimental>>& forms) { … }
AutofillManager::AutofillManager(AutofillDriver* driver)
: … { … }
AutofillManager::~AutofillManager() { … }
void AutofillManager::OnAutofillDriverLifecycleStateChanged(
LifecycleState old_state,
LifecycleState new_state,
base::PassKey<AutofillDriverFactory>) { … }
void AutofillManager::Reset() { … }
void AutofillManager::OnLanguageDetermined(
const translate::LanguageDetectionDetails& details) { … }
void AutofillManager::OnTranslateDriverDestroyed(
translate::TranslateDriver* translate_driver) { … }
LanguageCode AutofillManager::GetCurrentPageLanguage() { … }
void AutofillManager::OnDidFillAutofillFormData(
const FormData& form,
const base::TimeTicks timestamp) { … }
void AutofillManager::OnFormSubmitted(const FormData& form,
const bool known_success,
const mojom::SubmissionSource source) { … }
void AutofillManager::OnFormsSeen(
const std::vector<FormData>& updated_forms,
const std::vector<FormGlobalId>& removed_forms) { … }
void AutofillManager::OnFormsParsed(const std::vector<FormData>& forms) { … }
void AutofillManager::OnCaretMovedInFormField(const FormData& form,
const FieldGlobalId& field_id,
const gfx::Rect& caret_bounds) { … }
void AutofillManager::OnTextFieldDidChange(const FormData& form,
const FieldGlobalId& field_id,
const base::TimeTicks timestamp) { … }
void AutofillManager::OnTextFieldDidScroll(const FormData& form,
const FieldGlobalId& field_id) { … }
void AutofillManager::OnSelectControlDidChange(const FormData& form,
const FieldGlobalId& field_id) { … }
void AutofillManager::OnAskForValuesToFill(
const FormData& form,
const FieldGlobalId& field_id,
const gfx::Rect& caret_bounds,
AutofillSuggestionTriggerSource trigger_source) { … }
void AutofillManager::OnFocusOnFormField(const FormData& form,
const FieldGlobalId& field_id) { … }
void AutofillManager::OnFocusOnNonFormField() { … }
void AutofillManager::OnDidEndTextFieldEditing() { … }
void AutofillManager::OnHidePopup() { … }
void AutofillManager::OnSuggestionsHidden() { … }
void AutofillManager::OnSelectOrSelectListFieldOptionsDidChange(
const FormData& form) { … }
void AutofillManager::OnJavaScriptChangedAutofilledValue(
const FormData& form,
const FieldGlobalId& field_id,
const std::u16string& old_value,
bool formatting_only) { … }
bool AutofillManager::GetCachedFormAndField(
const FormData& form,
const FormFieldData& field,
FormStructure** form_structure,
AutofillField** autofill_field) const { … }
std::unique_ptr<AutofillMetrics::FormInteractionsUkmLogger>
AutofillManager::CreateFormInteractionsUkmLogger() { … }
size_t AutofillManager::FindCachedFormsBySignature(
FormSignature form_signature,
std::vector<raw_ptr<FormStructure, VectorExperimental>>* form_structures)
const { … }
FormStructure* AutofillManager::FindCachedFormById(FormGlobalId form_id) const { … }
bool AutofillManager::CanShowAutofillUi() const { … }
void AutofillManager::TriggerFormExtractionInAllFrames(
base::OnceCallback<void(bool success)> form_extraction_finished_callback) { … }
void AutofillManager::ParseFormsAsync(
const std::vector<FormData>& forms,
base::OnceCallback<void(AutofillManager&, const std::vector<FormData>&)>
callback) { … }
void AutofillManager::ParseFormAsync(
const FormData& form_data,
base::OnceCallback<void(AutofillManager&, const FormData&)> callback) { … }
void AutofillManager::OnLoadedServerPredictions(
std::optional<AutofillCrowdsourcingManager::QueryResponse> response) { … }
}