#include "components/autofill/content/browser/content_autofill_driver.h"
#include <concepts>
#include <functional>
#include <type_traits>
#include <utility>
#include "base/barrier_callback.h"
#include "base/functional/callback.h"
#include "components/autofill/content/browser/bad_message.h"
#include "components/autofill/content/browser/content_autofill_driver_factory.h"
#include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/autofill_driver_router.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_util.h"
#include "components/autofill/core/common/form_data_predictions.h"
#include "components/autofill/core/common/signatures.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/permissions_policy/permissions_policy_features.h"
#include "third_party/blink/public/common/tokens/tokens.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom-shared.h"
#include "url/origin.h"
namespace autofill {
namespace {
AnyOf;
template <typename T>
requires(std::is_scalar_v<std::remove_cvref_t<T>> ||
AnyOf<T,
bool,
AutofillDriverRouter::RoutedCallback<>,
base::TimeTicks,
std::u16string>)
T&& Lift(ContentAutofillDriver& source, T&& x) { … }
FormData Lift(ContentAutofillDriver& source, FormData form) { … }
FormGlobalId Lift(ContentAutofillDriver& source, FormRendererId id) { … }
FieldGlobalId Lift(ContentAutofillDriver& source, FieldRendererId id) { … }
template <typename T>
auto Lift(ContentAutofillDriver& source, const std::optional<T>& x) { … }
template <typename T>
auto Lift(ContentAutofillDriver& source, const std::vector<T>& xs) { … }
gfx::Rect Lift(ContentAutofillDriver& source, gfx::Rect r) { … }
template <typename... Args>
base::OnceCallback<void(Args...)> Lift(ContentAutofillDriver& source,
base::OnceCallback<void(Args...)> cb) { … }
template <typename T>
requires(std::is_scalar_v<std::remove_cvref_t<T>> ||
AnyOf<T,
bool,
FieldGlobalId,
base::TimeTicks,
gfx::Rect,
std::u16string,
std::vector<FormGlobalId>>)
T&& WithNewVersion(T&& x) { … }
auto& WithNewVersion(const FormData& browser_form) { … }
auto& WithNewVersion(const std::optional<FormData>& browser_form) { … }
auto& WithNewVersion(const std::vector<FormData>& browser_forms) { … }
template <typename... Args>
base::OnceCallback<void(Args...)> WithNewVersion(
base::OnceCallback<void(Args...)> cb) { … }
template <typename R,
typename... RouterArgs,
typename... AgentArgs,
typename... ActualArgs>
R RouteToAgent(AutofillDriverRouter& router,
R (AutofillDriverRouter::*router_fun)(
AutofillDriverRouter::RoutedCallback<AgentArgs...>,
RouterArgs...),
void (mojom::AutofillAgent::*agent_fun)(AgentArgs...),
ActualArgs&&... args) { … }
template <typename... RouterArgs,
typename... ManagerArgs,
typename... ActualArgs>
void RouteToManager(ContentAutofillDriver& source,
AutofillDriverRouter& router,
void (AutofillDriverRouter::*router_fun)(
AutofillDriverRouter::RoutedCallback<ManagerArgs...>,
autofill::AutofillDriver& source,
RouterArgs...),
void (AutofillManager::*manager_fun)(ManagerArgs...),
ActualArgs&&... args) { … }
}
ContentAutofillDriver::ContentAutofillDriver(
content::RenderFrameHost* render_frame_host,
ContentAutofillDriverFactory* owner)
: … { … }
ContentAutofillDriver::~ContentAutofillDriver() { … }
void ContentAutofillDriver::Reset(ContentAutofillDriverFactoryPassKey) { … }
void ContentAutofillDriver::TriggerFormExtractionInDriverFrame(
AutofillDriverRouterAndFormForestPassKey pass_key) { … }
void ContentAutofillDriver::TriggerFormExtractionInAllFrames(
base::OnceCallback<void(bool success)> form_extraction_finished_callback) { … }
void ContentAutofillDriver::GetFourDigitCombinationsFromDom(
base::OnceCallback<void(const std::vector<std::string>&)>
potential_matches) { … }
ContentAutofillDriver* ContentAutofillDriver::GetForRenderFrameHost(
content::RenderFrameHost* render_frame_host) { … }
void ContentAutofillDriver::BindPendingReceiver(
mojo::PendingAssociatedReceiver<mojom::AutofillDriver> pending_receiver) { … }
LocalFrameToken ContentAutofillDriver::GetFrameToken() const { … }
ContentAutofillDriver* ContentAutofillDriver::GetParent() { … }
ContentAutofillClient& ContentAutofillDriver::GetAutofillClient() { … }
AutofillManager& ContentAutofillDriver::GetAutofillManager() { … }
std::optional<LocalFrameToken> ContentAutofillDriver::Resolve(
FrameToken query) { … }
bool ContentAutofillDriver::IsActive() const { … }
bool ContentAutofillDriver::IsInAnyMainFrame() const { … }
bool ContentAutofillDriver::HasSharedAutofillPermission() const { … }
bool ContentAutofillDriver::CanShowAutofillUi() const { … }
std::optional<net::IsolationInfo> ContentAutofillDriver::GetIsolationInfo() { … }
base::flat_set<FieldGlobalId> ContentAutofillDriver::ApplyFormAction(
mojom::FormActionType action_type,
mojom::ActionPersistence action_persistence,
base::span<const FormFieldData> data,
const url::Origin& triggered_origin,
const base::flat_map<FieldGlobalId, FieldType>& field_type_map) { … }
void ContentAutofillDriver::ApplyFieldAction(
mojom::FieldActionType action_type,
mojom::ActionPersistence action_persistence,
const FieldGlobalId& field_id,
const std::u16string& value) { … }
void ContentAutofillDriver::ExtractForm(FormGlobalId form_id,
BrowserFormHandler final_handler) { … }
void ContentAutofillDriver::SendTypePredictionsToRenderer(
const std::vector<raw_ptr<FormStructure, VectorExperimental>>& forms) { … }
void ContentAutofillDriver::RendererShouldAcceptDataListSuggestion(
const FieldGlobalId& field_id,
const std::u16string& value) { … }
void ContentAutofillDriver::RendererShouldClearPreviewedForm() { … }
void ContentAutofillDriver::RendererShouldTriggerSuggestions(
const FieldGlobalId& field_id,
AutofillSuggestionTriggerSource trigger_source) { … }
void ContentAutofillDriver::RendererShouldSetSuggestionAvailability(
const FieldGlobalId& field_id,
mojom::AutofillSuggestionAvailability suggestion_availability) { … }
void ContentAutofillDriver::FormsSeen(
const std::vector<FormData>& updated_forms,
const std::vector<FormRendererId>& removed_forms) { … }
void ContentAutofillDriver::FormSubmitted(
const FormData& form,
bool known_success,
mojom::SubmissionSource submission_source) { … }
void ContentAutofillDriver::CaretMovedInFormField(
const FormData& form,
FieldRendererId field_id,
const gfx::Rect& caret_bounds) { … }
void ContentAutofillDriver::TextFieldDidChange(const FormData& form,
FieldRendererId field_id,
base::TimeTicks timestamp) { … }
void ContentAutofillDriver::TextFieldDidScroll(const FormData& form,
FieldRendererId field_id) { … }
void ContentAutofillDriver::SelectControlDidChange(const FormData& form,
FieldRendererId field_id) { … }
void ContentAutofillDriver::AskForValuesToFill(
const FormData& form,
FieldRendererId field_id,
const gfx::Rect& caret_bounds,
AutofillSuggestionTriggerSource trigger_source) { … }
void ContentAutofillDriver::HidePopup() { … }
void ContentAutofillDriver::FocusOnNonFormField() { … }
void ContentAutofillDriver::FocusOnFormField(const FormData& form,
FieldRendererId field_id) { … }
void ContentAutofillDriver::DidFillAutofillFormData(const FormData& form,
base::TimeTicks timestamp) { … }
void ContentAutofillDriver::DidEndTextFieldEditing() { … }
void ContentAutofillDriver::SelectOrSelectListFieldOptionsDidChange(
const FormData& form) { … }
void ContentAutofillDriver::JavaScriptChangedAutofilledValue(
const FormData& form,
FieldRendererId field_id,
const std::u16string& old_value,
bool formatting_only) { … }
const mojo::AssociatedRemote<mojom::AutofillAgent>&
ContentAutofillDriver::GetAutofillAgent() { … }
void ContentAutofillDriver::LiftForTest(FormData& form) { … }
AutofillDriverRouter& ContentAutofillDriver::router() { … }
}