#include "chrome/browser/devtools/protocol/autofill_handler.h"
#include <optional>
#include "base/check_deref.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/devtools/protocol/autofill.h"
#include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
#include "chrome/browser/ui/autofill/chrome_autofill_client.h"
#include "components/autofill/content/browser/content_autofill_client.h"
#include "components/autofill/content/browser/content_autofill_driver.h"
#include "components/autofill/content/browser/content_autofill_driver_factory.h"
#include "components/autofill/content/browser/scoped_autofill_managers_observation.h"
#include "components/autofill/core/browser/autofill_address_util.h"
#include "components/autofill/core/browser/autofill_manager.h"
#include "components/autofill/core/browser/browser_autofill_manager.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/core/browser/manual_testing_import.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/form_field_data.h"
#include "components/autofill/core/common/mojom/autofill_types.mojom-shared.h"
#include "components/autofill/core/common/unique_ids.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/render_frame_host.h"
#include "third_party/blink/public/common/features.h"
AutofillField;
AutofillTriggerSource;
CreditCard;
FieldGlobalId;
FormData;
FormFieldData;
HtmlFieldTypeToBestCorrespondingFieldType;
HtmlFieldType;
Maybe;
Response;
namespace {
std::optional<std::pair<FormData, FormFieldData>> FindFieldWithFormData(
autofill::ContentAutofillDriver* driver,
autofill::FieldGlobalId id) { … }
std::optional<std::string> GetRenderFrameDevtoolsToken(
const std::string& target_id,
const std::string& frame_token) { … }
}
AutofillHandler::AutofillHandler(protocol::UberDispatcher* dispatcher,
const std::string& target_id)
: … { … }
AutofillHandler::~AutofillHandler() { … }
protocol::Response AutofillHandler::Trigger(
int field_id,
Maybe<String> frame_id,
std::unique_ptr<protocol::Autofill::CreditCard> card) { … }
void AutofillHandler::SetAddresses(
std::unique_ptr<protocol::Array<protocol::Autofill::Address>> addresses,
std::unique_ptr<SetAddressesCallback> callback) { … }
void AutofillHandler::OnFillOrPreviewDataModelForm(
autofill::AutofillManager& manager,
autofill::FormGlobalId form,
autofill::mojom::ActionPersistence action_persistence,
base::span<const FormFieldData* const> filled_fields,
absl::variant<const autofill::AutofillProfile*, const autofill::CreditCard*>
profile_or_credit_card) { … }
void AutofillHandler::OnAutofillManagerStateChanged(
autofill::AutofillManager& manager,
autofill::AutofillManager::LifecycleState old_state,
autofill::AutofillManager::LifecycleState new_state) { … }
void AutofillHandler::OnContentAutofillDriverFactoryDestroyed(
autofill::ContentAutofillDriverFactory& factory) { … }
void AutofillHandler::OnContentAutofillDriverCreated(
autofill::ContentAutofillDriverFactory&,
autofill::ContentAutofillDriver& new_driver) { … }
autofill::ContentAutofillDriver* AutofillHandler::GetAutofillDriver() { … }
autofill::AutofillClient* AutofillHandler::GetAutofillClient() { … }
Response AutofillHandler::Enable() { … }
Response AutofillHandler::Disable() { … }