autofill_client_impl.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef WEBLAYER_BROWSER_AUTOFILL_CLIENT_IMPL_H_
  5. #define WEBLAYER_BROWSER_AUTOFILL_CLIENT_IMPL_H_
  6. #include "base/compiler_specific.h"
  7. #include "build/build_config.h"
  8. #include "components/autofill/core/browser/autofill_client.h"
  9. #include "content/public/browser/web_contents_observer.h"
  10. #include "content/public/browser/web_contents_user_data.h"
  11. namespace weblayer {
  12. // A minimal implementation of autofill::AutofillClient to satisfy the minor
  13. // touchpoints between the autofill implementation and its client that get
  14. // exercised within the WebLayer autofill flow.
  15. class AutofillClientImpl
  16. : public autofill::AutofillClient,
  17. public content::WebContentsUserData<AutofillClientImpl>,
  18. public content::WebContentsObserver {
  19. public:
  20. AutofillClientImpl(const AutofillClientImpl&) = delete;
  21. AutofillClientImpl& operator=(const AutofillClientImpl&) = delete;
  22. ~AutofillClientImpl() override;
  23. // AutofillClient:
  24. autofill::PersonalDataManager* GetPersonalDataManager() override;
  25. autofill::AutocompleteHistoryManager* GetAutocompleteHistoryManager()
  26. override;
  27. PrefService* GetPrefs() override;
  28. const PrefService* GetPrefs() const override;
  29. syncer::SyncService* GetSyncService() override;
  30. signin::IdentityManager* GetIdentityManager() override;
  31. autofill::FormDataImporter* GetFormDataImporter() override;
  32. autofill::payments::PaymentsClient* GetPaymentsClient() override;
  33. autofill::StrikeDatabase* GetStrikeDatabase() override;
  34. ukm::UkmRecorder* GetUkmRecorder() override;
  35. ukm::SourceId GetUkmSourceId() override;
  36. autofill::AddressNormalizer* GetAddressNormalizer() override;
  37. const GURL& GetLastCommittedURL() const override;
  38. security_state::SecurityLevel GetSecurityLevelForUmaHistograms() override;
  39. const translate::LanguageState* GetLanguageState() override;
  40. translate::TranslateDriver* GetTranslateDriver() override;
  41. void ShowAutofillSettings(bool show_credit_card_settings) override;
  42. void ShowUnmaskPrompt(
  43. const autofill::CreditCard& card,
  44. UnmaskCardReason reason,
  45. base::WeakPtr<autofill::CardUnmaskDelegate> delegate) override;
  46. void OnUnmaskVerificationResult(PaymentsRpcResult result) override;
  47. #if !BUILDFLAG(IS_ANDROID)
  48. std::vector<std::string> GetAllowedMerchantsForVirtualCards() override;
  49. std::vector<std::string> GetAllowedBinRangesForVirtualCards() override;
  50. void ShowLocalCardMigrationDialog(
  51. base::OnceClosure show_migration_dialog_closure) override;
  52. void ConfirmMigrateLocalCardToCloud(
  53. const autofill::LegalMessageLines& legal_message_lines,
  54. const std::string& user_email,
  55. const std::vector<autofill::MigratableCreditCard>&
  56. migratable_credit_cards,
  57. LocalCardMigrationCallback start_migrating_cards_callback) override;
  58. void ShowLocalCardMigrationResults(
  59. const bool has_server_error,
  60. const std::u16string& tip_message,
  61. const std::vector<autofill::MigratableCreditCard>&
  62. migratable_credit_cards,
  63. MigrationDeleteCardCallback delete_local_card_callback) override;
  64. void ShowWebauthnOfferDialog(
  65. WebauthnDialogCallback offer_dialog_callback) override;
  66. void ShowWebauthnVerifyPendingDialog(
  67. WebauthnDialogCallback verify_pending_dialog_callback) override;
  68. void UpdateWebauthnOfferDialogWithError() override;
  69. bool CloseWebauthnDialog() override;
  70. void ConfirmSaveUpiIdLocally(
  71. const std::string& upi_id,
  72. base::OnceCallback<void(bool user_decision)> callback) override;
  73. void OfferVirtualCardOptions(
  74. const std::vector<autofill::CreditCard*>& candidates,
  75. base::OnceCallback<void(const std::string&)> callback) override;
  76. #else // !BUILDFLAG(IS_ANDROID)
  77. void ConfirmAccountNameFixFlow(
  78. base::OnceCallback<void(const std::u16string&)> callback) override;
  79. void ConfirmExpirationDateFixFlow(
  80. const autofill::CreditCard& card,
  81. base::OnceCallback<void(const std::u16string&, const std::u16string&)>
  82. callback) override;
  83. #endif // !BUILDFLAG(IS_ANDROID)
  84. void ConfirmSaveCreditCardLocally(
  85. const autofill::CreditCard& card,
  86. SaveCreditCardOptions options,
  87. LocalSaveCardPromptCallback callback) override;
  88. void ConfirmSaveCreditCardToCloud(
  89. const autofill::CreditCard& card,
  90. const autofill::LegalMessageLines& legal_message_lines,
  91. SaveCreditCardOptions options,
  92. UploadSaveCardPromptCallback callback) override;
  93. void CreditCardUploadCompleted(bool card_saved) override;
  94. void ConfirmCreditCardFillAssist(const autofill::CreditCard& card,
  95. base::OnceClosure callback) override;
  96. void ConfirmSaveAddressProfile(
  97. const autofill::AutofillProfile& profile,
  98. const autofill::AutofillProfile* original_profile,
  99. SaveAddressProfilePromptOptions options,
  100. AddressProfileSavePromptCallback callback) override;
  101. bool HasCreditCardScanFeature() override;
  102. void ScanCreditCard(CreditCardScanCallback callback) override;
  103. bool IsTouchToFillCreditCardSupported() override;
  104. bool ShowTouchToFillCreditCard(
  105. base::WeakPtr<autofill::TouchToFillDelegate> delegate) override;
  106. void HideTouchToFillCreditCard() override;
  107. void ShowAutofillPopup(
  108. const autofill::AutofillClient::PopupOpenArgs& open_args,
  109. base::WeakPtr<autofill::AutofillPopupDelegate> delegate) override;
  110. void UpdateAutofillPopupDataListValues(
  111. const std::vector<std::u16string>& values,
  112. const std::vector<std::u16string>& labels) override;
  113. base::span<const autofill::Suggestion> GetPopupSuggestions() const override;
  114. void PinPopupView() override;
  115. autofill::AutofillClient::PopupOpenArgs GetReopenPopupArgs() const override;
  116. void UpdatePopup(const std::vector<autofill::Suggestion>& suggestions,
  117. autofill::PopupType popup_type) override;
  118. void HideAutofillPopup(autofill::PopupHidingReason reason) override;
  119. bool IsAutocompleteEnabled() override;
  120. bool IsPasswordManagerEnabled() override;
  121. void PropagateAutofillPredictions(
  122. autofill::AutofillDriver* driver,
  123. const std::vector<autofill::FormStructure*>& forms) override;
  124. void DidFillOrPreviewField(const std::u16string& autofilled_value,
  125. const std::u16string& profile_full_name) override;
  126. bool IsContextSecure() const override;
  127. bool ShouldShowSigninPromo() override;
  128. bool AreServerCardsSupported() const override;
  129. void ExecuteCommand(int id) override;
  130. void OpenPromoCodeOfferDetailsURL(const GURL& url) override;
  131. // RiskDataLoader:
  132. void LoadRiskData(
  133. base::OnceCallback<void(const std::string&)> callback) override;
  134. private:
  135. explicit AutofillClientImpl(content::WebContents* web_contents);
  136. friend class content::WebContentsUserData<AutofillClientImpl>;
  137. WEB_CONTENTS_USER_DATA_KEY_DECL();
  138. };
  139. } // namespace weblayer
  140. #endif // WEBLAYER_BROWSER_AUTOFILL_CLIENT_IMPL_H_