[Autofill] Make AutofillClientEfl implement ContentAutofillClient 86/300486/1
authorGajendra N <gajendra.n@samsung.com>
Wed, 25 Oct 2023 12:42:49 +0000 (18:12 +0530)
committerGajendra N <gajendra.n@samsung.com>
Thu, 26 Oct 2023 05:16:38 +0000 (10:46 +0530)
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 <gajendra.n@samsung.com>
tizen_src/ewk/efl_integration/browser/autofill/autofill_client_efl.cc
tizen_src/ewk/efl_integration/browser/autofill/autofill_client_efl.h
tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc

index e9fce88..d8f70ca 100644 (file)
 
 namespace autofill {
 
+// static
+AutofillClientEfl* AutofillClientEfl::FromWebContents(
+    content::WebContents* web_contents) {
+  return static_cast<AutofillClientEfl*>(
+      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<AutofillClientEfl>(*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<network::SharedURLLoaderFactory>
 AutofillClientEfl::GetURLLoaderFactory() {
-  NOTIMPLEMENTED();
-  return scoped_refptr<network::SharedURLLoaderFactory>();
+  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
index 1ba2183..f143729 100644 (file)
@@ -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<AutofillClientEfl>,
-      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<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
   void DidFillOrPreviewForm(mojom::RendererFormDataAction action,
@@ -167,15 +168,12 @@ class AutofillClientEfl
 
  private:
   explicit AutofillClientEfl(content::WebContents* web_contents);
-  friend class content::WebContentsUserData<AutofillClientEfl>;
   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
index 99da01b..39be5a7 100644 (file)
@@ -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";