[Save and Fill] Create save and fill manager skeleton

This is where the core logic of the Save and Fill feature will reside.
AttemptToOfferSaveAndFill(~) will be added in the following CL.

Design doc: go/payments-autofill-save-and-fill-desktop-design

Bug: 378164925
Change-Id: I619449b0dd00c8c7eecc32bcf78ea17f480ce294
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6527649
Reviewed-by: Siyu An <siyua@chromium.org>
Commit-Queue: Verina Armanyous <averina@google.com>
Cr-Commit-Position: refs/heads/main@{#1458372}
diff --git a/chrome/browser/ui/autofill/payments/chrome_payments_autofill_client.cc b/chrome/browser/ui/autofill/payments/chrome_payments_autofill_client.cc
index 941ff22..f521b90 100644
--- a/chrome/browser/ui/autofill/payments/chrome_payments_autofill_client.cc
+++ b/chrome/browser/ui/autofill/payments/chrome_payments_autofill_client.cc
@@ -47,6 +47,7 @@
 #include "components/autofill/core/browser/payments/otp_unmask_result.h"
 #include "components/autofill/core/browser/payments/payments_autofill_client.h"
 #include "components/autofill/core/browser/payments/payments_network_interface.h"
+#include "components/autofill/core/browser/payments/save_and_fill_manager.h"
 #include "components/autofill/core/browser/payments/virtual_card_enrollment_manager.h"
 #include "components/autofill/core/browser/single_field_fillers/payments/merchant_promo_code_manager.h"
 #include "components/autofill/core/browser/suggestions/suggestion.h"
@@ -964,6 +965,18 @@
 #endif  // !BUILDFLAG(IS_ANDROID)
 }
 
+SaveAndFillManager* ChromePaymentsAutofillClient::GetSaveAndFillManager() {
+#if BUILDFLAG(IS_ANDROID)
+  return nullptr;
+#else
+  if (!save_and_fill_manager_) {
+    save_and_fill_manager_ =
+        std::make_unique<payments::SaveAndFillManager>(this);
+  }
+  return save_and_fill_manager_.get();
+#endif  // BUILDFLAG(IS_ANDROID)
+}
+
 void ChromePaymentsAutofillClient::ShowSelectBnplIssuerDialog(
     std::vector<BnplIssuerContext> bnpl_issuer_context,
     std::string app_locale,
diff --git a/chrome/browser/ui/autofill/payments/chrome_payments_autofill_client.h b/chrome/browser/ui/autofill/payments/chrome_payments_autofill_client.h
index fcc7ec3..97289113 100644
--- a/chrome/browser/ui/autofill/payments/chrome_payments_autofill_client.h
+++ b/chrome/browser/ui/autofill/payments/chrome_payments_autofill_client.h
@@ -64,6 +64,7 @@
 enum class OtpUnmaskResult;
 class PaymentsDataManager;
 class SaveAndFillDialogControllerImpl;
+class SaveAndFillManager;
 class TouchToFillDelegate;
 struct VirtualCardEnrollmentFields;
 class VirtualCardEnrollmentManager;
@@ -209,6 +210,7 @@
       override;
   PaymentsDataManager& GetPaymentsDataManager() final;
   void ShowCreditCardSaveAndFillDialog() override;
+  payments::SaveAndFillManager* GetSaveAndFillManager() override;
   void ShowSelectBnplIssuerDialog(
       std::vector<BnplIssuerContext> bnpl_issuer_context,
       std::string app_locale,
@@ -331,6 +333,8 @@
   std::unique_ptr<SaveAndFillDialogControllerImpl>
       save_and_fill_dialog_controller_;
 
+  std::unique_ptr<SaveAndFillManager> save_and_fill_manager_;
+
   std::unique_ptr<SelectBnplIssuerDialogControllerImpl>
       select_bnpl_issuer_dialog_controller_;
 
diff --git a/components/autofill/core/browser/BUILD.gn b/components/autofill/core/browser/BUILD.gn
index 827dae8..6b33be9 100644
--- a/components/autofill/core/browser/BUILD.gn
+++ b/components/autofill/core/browser/BUILD.gn
@@ -543,6 +543,8 @@
     "payments/payments_window_manager_util.cc",
     "payments/payments_window_manager_util.h",
     "payments/risk_data_loader.h",
+    "payments/save_and_fill_manager.cc",
+    "payments/save_and_fill_manager.h",
     "payments/virtual_card_enroll_metrics_logger.cc",
     "payments/virtual_card_enroll_metrics_logger.h",
     "payments/virtual_card_enrollment_flow.h",
diff --git a/components/autofill/core/browser/payments/payments_autofill_client.cc b/components/autofill/core/browser/payments/payments_autofill_client.cc
index 80134d4d..bf9f0c42 100644
--- a/components/autofill/core/browser/payments/payments_autofill_client.cc
+++ b/components/autofill/core/browser/payments/payments_autofill_client.cc
@@ -252,6 +252,10 @@
 
 void PaymentsAutofillClient::ShowCreditCardSaveAndFillDialog() {}
 
+payments::SaveAndFillManager* PaymentsAutofillClient::GetSaveAndFillManager() {
+  return nullptr;
+}
+
 void PaymentsAutofillClient::ShowSelectBnplIssuerDialog(
     std::vector<BnplIssuerContext> bnpl_issuer_context,
     std::string app_locale,
diff --git a/components/autofill/core/browser/payments/payments_autofill_client.h b/components/autofill/core/browser/payments/payments_autofill_client.h
index caf8d47..87915901 100644
--- a/components/autofill/core/browser/payments/payments_autofill_client.h
+++ b/components/autofill/core/browser/payments/payments_autofill_client.h
@@ -61,6 +61,7 @@
 class MandatoryReauthManager;
 class PaymentsNetworkInterface;
 class PaymentsWindowManager;
+class SaveAndFillManager;
 
 // A payments-specific client interface that handles dependency injection, and
 // its implementations serve as the integration for platform-specific code. One
@@ -574,6 +575,10 @@
   // Shows the `Save and Fill` modal dialog.
   virtual void ShowCreditCardSaveAndFillDialog();
 
+  // Gets the payments Save and Fill manager owned by the client. This will be
+  // used to handle the Save and Fill dialog.
+  virtual payments::SaveAndFillManager* GetSaveAndFillManager();
+
   // Shows the issuer selection dialog for BNPL when the BNPL suggestion is
   // selected to let users choose a BNPL issuer.
   virtual void ShowSelectBnplIssuerDialog(
diff --git a/components/autofill/core/browser/payments/save_and_fill_manager.cc b/components/autofill/core/browser/payments/save_and_fill_manager.cc
new file mode 100644
index 0000000..e747bc1
--- /dev/null
+++ b/components/autofill/core/browser/payments/save_and_fill_manager.cc
@@ -0,0 +1,17 @@
+// Copyright 2025 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/autofill/core/browser/payments/save_and_fill_manager.h"
+
+#include "base/check_deref.h"
+
+namespace autofill::payments {
+
+SaveAndFillManager::SaveAndFillManager(
+    PaymentsAutofillClient* payments_autofill_client)
+    : payments_autofill_client_(CHECK_DEREF(payments_autofill_client)) {}
+
+SaveAndFillManager::~SaveAndFillManager() = default;
+
+}  // namespace autofill::payments
diff --git a/components/autofill/core/browser/payments/save_and_fill_manager.h b/components/autofill/core/browser/payments/save_and_fill_manager.h
new file mode 100644
index 0000000..580a2ab
--- /dev/null
+++ b/components/autofill/core/browser/payments/save_and_fill_manager.h
@@ -0,0 +1,30 @@
+// Copyright 2025 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_SAVE_AND_FILL_MANAGER_H_
+#define COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_SAVE_AND_FILL_MANAGER_H_
+
+#include "base/memory/raw_ref.h"
+
+namespace autofill::payments {
+
+class PaymentsAutofillClient;
+
+// Owned by PaymentsAutofillClient. There is one instance of this class per Web
+// Contents. This class manages the flow for the Save and Fill dialog.
+class SaveAndFillManager {
+ public:
+  explicit SaveAndFillManager(PaymentsAutofillClient* payments_autofill_client);
+  SaveAndFillManager(const SaveAndFillManager& other) = delete;
+  SaveAndFillManager& operator=(const SaveAndFillManager& other) = delete;
+  ~SaveAndFillManager();
+
+ private:
+  // The associated payments autofill client.
+  const raw_ref<PaymentsAutofillClient> payments_autofill_client_;
+};
+
+}  // namespace autofill::payments
+
+#endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_SAVE_AND_FILL_MANAGER_H_