[M130][Autofill] Enable autofill and fix crashes during ubrowser launch 77/318877/4
authorGajendra N <gajendra.n@samsung.com>
Thu, 30 Jan 2025 06:49:19 +0000 (12:19 +0530)
committerInsoon Kim <is46.kim@samsung.com>
Wed, 5 Feb 2025 05:02:51 +0000 (05:02 +0000)
a) Crash related to BrowserAutofillManager ctor, reason being
   GetPaymentAutofillClient() returning null

   Implemented PaymentAutofillClientEfl in tizen_src.

b) Crash related to a autofill pref not registered
   FATAL:pref_service.cc(692)] Check failed: pref_registry_->defaults()->GetValue(path, &default_value).
   Trying to access an unregistered pref: autofill.payment_card_benefits

   Registered kAutofillPaymentCardBenefits pref.

Change-Id: I3303699e96b2999dd0dee1b0e650750f475be461
Signed-off-by: Gajendra N <gajendra.n@samsung.com>
tizen_src/build/config/tizen_features.gni
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/browser_context_efl.cc

index e07b0a255330562e3984100288261b8701798c83..17bbdde8cb78fbc09fbab95b0b36ec80c9584d66 100644 (file)
@@ -84,12 +84,9 @@ declare_args() {
   tizen_tv_riscv64 = false
 }
 
-# Enable autofill after fixing related crash.
-if (!ewk_bringup) {  #  FIXME: m130 bringup
-  tizen_autofill = true
-  if (tizen_product_tv) {
-    tizen_autofill_fw = true
-  }
+tizen_autofill = true
+if (tizen_product_tv) {
+  tizen_autofill_fw = true
 }
 
 if (use_ttrace) {
index 03d8864ef5965a38f54654158ec7d9592b302cb7..ed7aa277c3c0a186d0b35ff32f5e2274331da55e 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "browser/autofill/autofill_client_efl.h"
 
+#include "base/check_deref.h"
 #include "base/logging.h"
 #include "base/strings/utf_string_conversions.h"
 #include "browser/autofill/autocomplete_history_manager_factory.h"
 
 namespace autofill {
 
+namespace payments {
+
+PaymentsAutofillClientEfl::PaymentsAutofillClientEfl(
+    ContentAutofillClient* client)
+    : client_(CHECK_DEREF(client)) {}
+
+CreditCardCvcAuthenticator& PaymentsAutofillClientEfl::GetCvcAuthenticator() {
+  if (!cvc_authenticator_) {
+    cvc_authenticator_ =
+        std::make_unique<CreditCardCvcAuthenticator>(&client_.get());
+  }
+  return *cvc_authenticator_;
+}
+
+void PaymentsAutofillClientEfl::LoadRiskData(
+    base::OnceCallback<void(const std::string&)> callback) {
+  NOTIMPLEMENTED();
+}
+
+}  // namespace payments
+
 // static
 AutofillClientEfl* AutofillClientEfl::FromWebContents(
     content::WebContents* web_contents) {
@@ -282,8 +304,7 @@ std::unique_ptr<AutofillManager> AutofillClientEfl::CreateManager(
 
 payments::PaymentsAutofillClient*
 AutofillClientEfl::GetPaymentsAutofillClient() {
-  NOTIMPLEMENTED();
-  return nullptr;
+  return &payments_autofill_client_;
 }
 
 void AutofillClientEfl::ShowSavePasswordPopup(
index ec1ce22ec684d8d841b3ea8a48a330d609eea781..e72865e09a01ea2e9c1d48e4aa0454df2a5ee375 100644 (file)
@@ -12,6 +12,7 @@
 #include "base/memory/weak_ptr.h"
 #include "browser/autofill_popup_view_efl.h"
 #include "components/autofill/content/browser/content_autofill_client.h"
+#include "components/autofill/core/browser/payments/credit_card_cvc_authenticator.h"
 #include "components/autofill/core/browser/payments/local_card_migration_manager.h"
 #include "components/autofill/core/browser/payments/payments_autofill_client.h"
 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
@@ -28,6 +29,26 @@ class WebContents;
 
 namespace autofill {
 
+namespace payments {
+
+class PaymentsAutofillClientEfl : public PaymentsAutofillClient {
+ public:
+  explicit PaymentsAutofillClientEfl(ContentAutofillClient* client);
+  PaymentsAutofillClientEfl(const PaymentsAutofillClientEfl&) = delete;
+  PaymentsAutofillClientEfl& operator=(const PaymentsAutofillClientEfl&) =
+      delete;
+
+  CreditCardCvcAuthenticator& GetCvcAuthenticator() override;
+  void LoadRiskData(
+      base::OnceCallback<void(const std::string&)> callback) override;
+
+ private:
+  const raw_ref<ContentAutofillClient> client_;
+  std::unique_ptr<CreditCardCvcAuthenticator> cvc_authenticator_;
+};
+
+}  // namespace payments
+
 class AutofillClientEfl : public ContentAutofillClient,
                           public content::WebContentsObserver {
  public:
@@ -168,6 +189,8 @@ class AutofillClientEfl : public ContentAutofillClient,
   AutofillPopupViewEfl* GetOrCreatePopupController();
   gfx::RectF GetElementBoundsInScreen(const gfx::RectF& element_bounds);
 
+  payments::PaymentsAutofillClientEfl payments_autofill_client_{this};
+
   content::WebContents* const web_contents_;
   EWebView* webview_ = nullptr;
   AutofillPopupViewEfl* popup_controller_ = nullptr;
index b0aeda3e5e314c7aa22a4a1908e1a5ecbb3b9546..b663ddf001e3ab7da0ad796c23c1a68cf44c99ff 100644 (file)
@@ -206,6 +206,7 @@ BrowserContextEfl::BrowserContextEfl(EWebContext* web_context, bool incognito)
   // autofill preferences
   pref_registry->RegisterBooleanPref(kAutofillProfileEnabled, true);
   pref_registry->RegisterBooleanPref(kAutofillCreditCardEnabled, true);
+  pref_registry->RegisterBooleanPref(kAutofillPaymentCardBenefits, true);
   pref_registry->RegisterIntegerPref(kAutocompleteLastVersionRetentionPolicy,
                                      0);
   pref_registry->RegisterIntegerPref(kAutofillLastVersionDeduped, 0);