From 2cb826bb6c237dc36e6e740a8553ad2e3dc8156b Mon Sep 17 00:00:00 2001 From: Gajendra N Date: Wed, 25 Oct 2023 18:12:49 +0530 Subject: [PATCH] [Autofill] Make AutofillClientEfl implement ContentAutofillClient Made changes as per upstream patch [1]. Set ContentAutofillClient as base class for AutofillClientEfl similar to Android and Chrome implementations. [1] https://chromium-review.googlesource.com/c/chromium/src/+/4272332 Change-Id: I70d8604cacb61c51e60d26fb70ff6bfc197356a3 Signed-off-by: Gajendra N --- .../browser/autofill/autofill_client_efl.cc | 33 +++++++++++++++++----- .../browser/autofill/autofill_client_efl.h | 14 ++++----- .../efl_integration/web_contents_delegate_efl.cc | 6 ---- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/tizen_src/ewk/efl_integration/browser/autofill/autofill_client_efl.cc b/tizen_src/ewk/efl_integration/browser/autofill/autofill_client_efl.cc index e9fce88..d8f70ca 100644 --- a/tizen_src/ewk/efl_integration/browser/autofill/autofill_client_efl.cc +++ b/tizen_src/ewk/efl_integration/browser/autofill/autofill_client_efl.cc @@ -32,9 +32,28 @@ namespace autofill { +// static +AutofillClientEfl* AutofillClientEfl::FromWebContents( + content::WebContents* web_contents) { + return static_cast( + ContentAutofillClient::FromWebContents(web_contents)); +} + +// static +void AutofillClientEfl::CreateForWebContents(content::WebContents* contents) { + DCHECK(contents); + if (!FromWebContents(contents)) { + contents->SetUserData(UserDataKey(), + base::WrapUnique(new AutofillClientEfl(contents))); + } +} + AutofillClientEfl::AutofillClientEfl(content::WebContents* web_contents) - : content::WebContentsObserver(web_contents), - content::WebContentsUserData(*web_contents), + : ContentAutofillClient(web_contents, + base::BindRepeating(&BrowserDriverInitHook, + this, + EWebView::GetPlatformLocale())), + content::WebContentsObserver(web_contents), web_contents_(web_contents) { DCHECK(web_contents); } @@ -311,14 +330,14 @@ void AutofillClientEfl::DidFillOrPreviewField( } bool AutofillClientEfl::IsOffTheRecord() { - NOTIMPLEMENTED(); - return false; + return web_contents_->GetBrowserContext()->IsOffTheRecord(); } scoped_refptr AutofillClientEfl::GetURLLoaderFactory() { - NOTIMPLEMENTED(); - return scoped_refptr(); + return web_contents_->GetBrowserContext() + ->GetDefaultStoragePartition() + ->GetURLLoaderFactoryForBrowserProcess(); } void AutofillClientEfl::ConfirmSaveIBANLocally( @@ -337,6 +356,7 @@ void AutofillClientEfl::DidFillOrPreviewForm( FormInteractionsFlowId AutofillClientEfl::GetCurrentFormInteractionsFlowId() { NOTIMPLEMENTED(); + return {}; } void AutofillClientEfl::UpdateAutofillIfRequired() { @@ -507,7 +527,6 @@ void AutofillClientEfl::HideTouchToFillCreditCard() { NOTIMPLEMENTED(); } -WEB_CONTENTS_USER_DATA_KEY_IMPL(AutofillClientEfl); } // namespace autofill #endif // TIZEN_AUTOFILL diff --git a/tizen_src/ewk/efl_integration/browser/autofill/autofill_client_efl.h b/tizen_src/ewk/efl_integration/browser/autofill/autofill_client_efl.h index 1ba2183..f143729 100644 --- a/tizen_src/ewk/efl_integration/browser/autofill/autofill_client_efl.h +++ b/tizen_src/ewk/efl_integration/browser/autofill/autofill_client_efl.h @@ -11,7 +11,7 @@ #include "base/i18n/rtl.h" #include "base/memory/weak_ptr.h" #include "browser/autofill_popup_view_efl.h" -#include "components/autofill/core/browser/autofill_client.h" +#include "components/autofill/content/browser/content_autofill_client.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/password_manager/core/browser/password_form_manager.h" #include "content/public/browser/web_contents_observer.h" @@ -26,16 +26,17 @@ class WebContents; namespace autofill { -class AutofillClientEfl - : public AutofillClient, - public content::WebContentsUserData, - public content::WebContentsObserver { +class AutofillClientEfl : public ContentAutofillClient, + public content::WebContentsObserver { public: ~AutofillClientEfl() override; AutofillClientEfl(const AutofillClientEfl&) = delete; AutofillClientEfl& operator=(const AutofillClientEfl&) = delete; + static AutofillClientEfl* FromWebContents(content::WebContents*); + static void CreateForWebContents(content::WebContents*); + bool IsOffTheRecord() override; scoped_refptr GetURLLoaderFactory() override; void DidFillOrPreviewForm(mojom::RendererFormDataAction action, @@ -167,15 +168,12 @@ class AutofillClientEfl private: explicit AutofillClientEfl(content::WebContents* web_contents); - friend class content::WebContentsUserData; AutofillPopupViewEfl* GetOrCreatePopupController(); gfx::RectF GetElementBoundsInScreen(const gfx::RectF& element_bounds); content::WebContents* const web_contents_; EWebView* webview_ = nullptr; AutofillPopupViewEfl* popup_controller_ = nullptr; - - WEB_CONTENTS_USER_DATA_KEY_DECL(); }; } // namespace autofill diff --git a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc index 99da01b..39be5a7 100644 --- a/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc +++ b/tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc @@ -135,7 +135,6 @@ WebContentsDelegateEfl::WebContentsDelegateEfl(EWebView* view) #if defined(TIZEN_AUTOFILL) if (!base::CommandLine::ForCurrentProcess()->HasSwitch( autofill::switches::kDisableAutofill)) { -#if !defined(EWK_BRINGUP) // FIXME: m114 bringup AutofillClientEfl::CreateForWebContents(&web_contents_); AutofillClientEfl* autofill_client = AutofillClientEfl::FromWebContents(&web_contents_); @@ -143,11 +142,6 @@ WebContentsDelegateEfl::WebContentsDelegateEfl(EWebView* view) autofill_client->SetEWebView(view); PasswordManagerClientEfl::CreateForWebContentsWithAutofillClient( &web_contents_, autofill_client); - ContentAutofillDriverFactory::CreateForWebContentsAndDelegate( - &web_contents_, autofill_client, - base::BindRepeating(&autofill::BrowserDriverInitHook, autofill_client, - EWebView::GetPlatformLocale())); -#endif } #if defined(TIZEN_AUTOFILL_FW) LOG(INFO) << "[Autofill] " << __FUNCTION__ << " Create AutofillRequest"; -- 2.7.4