1 // Copyright 2014 Samsung Electronics. 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 AUTOFILL_MANAGER_DELEGATE_EFL_H
5 #define AUTOFILL_MANAGER_DELEGATE_EFL_H
7 #if defined(TIZEN_AUTOFILL)
9 #include "base/compiler_specific.h"
10 #include "base/functional/callback.h"
11 #include "base/i18n/rtl.h"
12 #include "base/memory/weak_ptr.h"
13 #include "browser/autofill_popup_view_efl.h"
14 #include "components/autofill/core/browser/autofill_client.h"
15 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
16 #include "components/password_manager/core/browser/password_form_manager.h"
17 #include "content/public/browser/web_contents_observer.h"
18 #include "content/public/browser/web_contents_user_data.h"
19 #include "eweb_view.h"
22 struct FrameNavigateParams;
23 struct LoadCommittedDetails;
29 class AutofillClientEfl
30 : public AutofillClient,
31 public content::WebContentsUserData<AutofillClientEfl>,
32 public content::WebContentsObserver {
34 ~AutofillClientEfl() override;
36 AutofillClientEfl(const AutofillClientEfl&) = delete;
37 AutofillClientEfl& operator=(const AutofillClientEfl&) = delete;
39 bool IsOffTheRecord() override;
40 scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
41 void DidFillOrPreviewForm(mojom::RendererFormDataAction action,
42 AutofillTriggerSource trigger_source,
43 bool is_refill) override;
44 void ConfirmSaveIBANLocally(const IBAN& iban,
45 bool should_show_prompt,
46 LocalSaveIBANPromptCallback callback) override;
47 FormInteractionsFlowId GetCurrentFormInteractionsFlowId() override;
49 // AutofillClient implementation.
50 PersonalDataManager* GetPersonalDataManager() override;
51 PrefService* GetPrefs() override;
52 virtual const PrefService* GetPrefs() const override;
53 syncer::SyncService* GetSyncService() override;
54 void ShowAutofillSettings(PopupType popup_type) override;
55 void ConfirmSaveCreditCardLocally(
56 const CreditCard& card,
57 SaveCreditCardOptions options,
58 LocalSaveCardPromptCallback callback) override;
59 void ConfirmSaveCreditCardToCloud(
60 const CreditCard& card,
61 const LegalMessageLines& legal_message_lines,
62 SaveCreditCardOptions options,
63 UploadSaveCardPromptCallback callback) override;
64 void ConfirmCreditCardFillAssist(const CreditCard& card,
65 base::OnceClosure callback) override;
66 void ShowAutofillPopup(
67 const PopupOpenArgs& open_args,
68 base::WeakPtr<autofill::AutofillPopupDelegate> delegate) override;
69 void ShowUnmaskPrompt(
70 const CreditCard& card,
71 const CardUnmaskPromptOptions& card_unmask_prompt_options,
72 base::WeakPtr<CardUnmaskDelegate> delegate) override;
73 void UpdateAutofillPopupDataListValues(
74 const std::vector<std::u16string>& values,
75 const std::vector<std::u16string>& labels) override;
76 void OnUnmaskVerificationResult(PaymentsRpcResult result) override;
77 bool HasCreditCardScanFeature() override;
78 void ScanCreditCard(CreditCardScanCallback callback) override;
79 bool IsContextSecure() const override;
81 signin::IdentityManager* GetIdentityManager() override;
82 ukm::UkmRecorder* GetUkmRecorder() override;
83 ukm::SourceId GetUkmSourceId() override;
84 AddressNormalizer* GetAddressNormalizer() override;
85 security_state::SecurityLevel GetSecurityLevelForUmaHistograms() override;
87 void ExecuteCommand(int id) override;
88 void HideAutofillPopup(PopupHidingReason reason) override;
89 bool IsAutocompleteEnabled() const override;
90 void PropagateAutofillPredictions(
91 autofill::AutofillDriver* autofill_driver,
92 const std::vector<FormStructure*>& forms) override;
93 void DidFillOrPreviewField(const std::u16string& autofilled_value,
94 const std::u16string& profile_full_name) override;
95 void ConfirmMigrateLocalCardToCloud(
96 const LegalMessageLines& legal_message_lines,
97 const std::string& user_email,
98 const std::vector<MigratableCreditCard>& migratable_credit_cards,
99 LocalCardMigrationCallback start_migrating_cards_callback) override;
100 void ShowWebauthnOfferDialog(
101 WebauthnDialogCallback offer_dialog_callback) override;
102 void ShowWebauthnVerifyPendingDialog(
103 WebauthnDialogCallback verify_pending_dialog_callback) override;
104 void UpdateWebauthnOfferDialogWithError() override;
105 bool CloseWebauthnDialog() override;
106 void ConfirmSaveUpiIdLocally(
107 const std::string& upi_id,
108 base::OnceCallback<void(bool user_decision)> callback) override;
109 void OfferVirtualCardOptions(
110 const std::vector<CreditCard*>& candidates,
111 base::OnceCallback<void(const std::string&)> callback) override;
112 void CreditCardUploadCompleted(bool card_saved) override;
113 void PinPopupView() override;
114 PopupOpenArgs GetReopenPopupArgs() const override;
115 std::vector<Suggestion> GetPopupSuggestions() const override;
116 void UpdatePopup(const std::vector<Suggestion>& suggestions,
117 PopupType popup_type) override;
118 const GURL& GetLastCommittedPrimaryMainFrameURL() const override;
119 const translate::LanguageState* GetLanguageState() override;
120 translate::TranslateDriver* GetTranslateDriver() override;
121 std::vector<std::string> GetAllowedMerchantsForVirtualCards() override;
122 std::vector<std::string> GetAllowedBinRangesForVirtualCards() override;
123 void ConfirmSaveAddressProfile(
124 const AutofillProfile& profile,
125 const AutofillProfile* original_profile,
126 AutofillClient::SaveAddressProfilePromptOptions options,
127 AddressProfileSavePromptCallback callback) override;
128 payments::PaymentsClient* GetPaymentsClient() override;
129 url::Origin GetLastCommittedPrimaryMainFrameOrigin() const override;
130 bool IsTouchToFillCreditCardSupported() override { return false; }
131 bool ShowTouchToFillCreditCard(
132 base::WeakPtr<TouchToFillDelegate> delegate,
133 base::span<const autofill::CreditCard> cards_to_suggest) override {
136 bool IsPasswordManagerEnabled() override { return false; }
138 void HideTouchToFillCreditCard() override;
140 void OpenPromoCodeOfferDetailsURL(const GURL& url) override;
142 // content::WebContentsObserver implementation.
143 void PrimaryMainFrameWasResized(bool width_changed) override;
144 void WebContentsDestroyed() override;
146 base::OnceCallback<void(const std::string&)> callback) override;
148 void ShowSavePasswordPopup(
149 std::unique_ptr<password_manager::PasswordFormManagerForUI> form_to_save);
150 void SetEWebView(EWebView* view) { webview_ = view; }
151 void UpdateAutofillIfRequired();
152 #if defined(TIZEN_AUTOFILL_FW)
153 void ResetLastInteractedElements();
155 void DidChangeFocusedNodeBounds(const gfx::RectF& node_bounds);
156 bool IsAutocompleteSavingEnabled();
157 FormDataImporter* GetFormDataImporter();
158 StrikeDatabase* GetStrikeDatabase();
159 void ShowLocalCardMigrationDialog(
160 base::OnceClosure show_migration_dialog_closure);
161 void ShowLocalCardMigrationResults(
162 const bool has_server_error,
163 const std::u16string& tip_message,
164 const std::vector<MigratableCreditCard>& migratable_credit_cards,
165 MigrationDeleteCardCallback delete_local_card_callback);
166 AutocompleteHistoryManager* GetAutocompleteHistoryManager();
169 explicit AutofillClientEfl(content::WebContents* web_contents);
170 friend class content::WebContentsUserData<AutofillClientEfl>;
171 AutofillPopupViewEfl* GetOrCreatePopupController();
172 gfx::RectF GetElementBoundsInScreen(const gfx::RectF& element_bounds);
174 content::WebContents* const web_contents_;
175 EWebView* webview_ = nullptr;
176 AutofillPopupViewEfl* popup_controller_ = nullptr;
178 WEB_CONTENTS_USER_DATA_KEY_DECL();
181 } // namespace autofill
183 #endif // TIZEN_AUTOFILL
185 #endif // AUTOFILL_CLIENT_EFL_H