chromium/components/autofill/core/browser/payments_data_manager.h

// Copyright 2024 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_DATA_MANAGER_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_DATA_MANAGER_H_

#include <map>
#include <memory>
#include <optional>
#include <vector>

#include "base/containers/span.h"
#include "base/functional/function_ref.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/observer_list_types.h"
#include "components/autofill/core/browser/autofill_shared_storage_handler.h"
#include "components/autofill/core/browser/country_type.h"
#include "components/autofill/core/browser/data_model/autofill_offer_data.h"
#include "components/autofill/core/browser/data_model/autofill_wallet_usage_data.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/data_model/credit_card_benefit.h"
#include "components/autofill/core/browser/data_model/credit_card_cloud_token_data.h"
#include "components/autofill/core/browser/data_model/iban.h"
#include "components/autofill/core/browser/metrics/autofill_metrics.h"
#include "components/autofill/core/browser/payments/account_info_getter.h"
#include "components/autofill/core/browser/payments/payments_customer_data.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service_observer.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/sync/service/sync_service_observer.h"
#include "components/webdata/common/web_data_service_consumer.h"
#include "ui/gfx/image/image.h"
#include "url/gurl.h"

namespace syncer {
class SyncService;
}  // namespace syncer

namespace autofill {

class AutofillImageFetcherBase;
class AutofillOptimizationGuide;
class BankAccount;
struct CreditCardArtImage;
class PaymentsDatabaseHelper;

// Contains all payments-related logic of the `PersonalDataManager`. See comment
// above the `PersonalDataManager` first.
//
// Technical details on how modifications are implemented:
// `PaymentsDataManager` (PayDM) code simply posts a task to the DB sequence and
// triggers a `Refresh()` afterwards. Since `Refresh()` itself simply posts
// several read requests on the DB sequence, and because the DB sequence is a
// sequence, the `Refresh()` is guaranteed to read the latest data. This is
// unnecessarily inefficient, since any change causes the PayDM to reload all of
// its data.
class PaymentsDataManager : public AutofillWebDataServiceObserverOnUISequence,
                            public WebDataServiceConsumer,
                            public AccountInfoGetter,
                            public syncer::SyncServiceObserver,
                            public signin::IdentityManager::Observer {};

}  // namespace autofill

#endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_PAYMENTS_DATA_MANAGER_H_