#include "components/autofill/core/browser/webdata/payments/autofill_wallet_sync_bridge.h"
#include <utility>
#include "base/base64.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/ranges/algorithm.h"
#include "components/autofill/core/browser/data_model/bank_account.h"
#include "components/autofill/core/browser/data_model/credit_card.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/payments_customer_data.h"
#include "components/autofill/core/browser/webdata/autofill_sync_metadata_table.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_backend.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/autofill/core/browser/webdata/payments/payments_autofill_table.h"
#include "components/autofill/core/browser/webdata/payments/payments_sync_bridge_util.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/hash_util.h"
#include "components/sync/model/client_tag_based_data_type_processor.h"
#include "components/sync/model/mutable_data_batch.h"
#include "components/sync/model/sync_metadata_store_change_list.h"
#include "components/sync/protocol/entity_data.h"
AutofillWalletSpecifics;
EntityData;
namespace autofill {
namespace {
static int kAutofillWalletSyncBridgeUserDataKey = …;
std::string GetClientTagFromCreditCard(const CreditCard& card) { … }
std::string GetClientTagFromPaymentsCustomerData(
const PaymentsCustomerData& customer_data) { … }
std::string GetClientTagFromCreditCardCloudTokenData(
const CreditCardCloudTokenData& cloud_token_data) { … }
std::string GetClientTagFromIban(const Iban& iban) { … }
std::string GetClientTagFromBankAccount(const BankAccount& bank_account) { … }
std::string GetStorageKeyForWalletDataClientTag(const std::string& client_tag) { … }
std::unique_ptr<EntityData> CreateEntityDataFromCard(const CreditCard& card,
bool enforce_utf8) { … }
std::unique_ptr<EntityData> CreateEntityDataFromPaymentsCustomerData(
const PaymentsCustomerData& customer_data) { … }
std::unique_ptr<EntityData> CreateEntityDataFromCreditCardCloudTokenData(
const CreditCardCloudTokenData& cloud_token_data,
bool enforce_utf8) { … }
std::unique_ptr<EntityData> CreateEntityDataFromIban(const Iban& iban,
bool enforce_utf8) { … }
std::unique_ptr<EntityData> CreateEntityDataFromBankAccount(
const BankAccount& bank_account) { … }
void SetEntityDataFromBenefit(const CreditCardBenefit& benefit,
bool enforce_utf8,
EntityData& entity_data) { … }
}
void AutofillWalletSyncBridge::CreateForWebDataServiceAndBackend(
const std::string& app_locale,
AutofillWebDataBackend* web_data_backend,
AutofillWebDataService* web_data_service) { … }
syncer::DataTypeSyncBridge* AutofillWalletSyncBridge::FromWebDataService(
AutofillWebDataService* web_data_service) { … }
AutofillWalletSyncBridge::AutofillWalletSyncBridge(
std::unique_ptr<syncer::DataTypeLocalChangeProcessor> change_processor,
AutofillWebDataBackend* web_data_backend)
: … { … }
AutofillWalletSyncBridge::~AutofillWalletSyncBridge() { … }
std::unique_ptr<syncer::MetadataChangeList>
AutofillWalletSyncBridge::CreateMetadataChangeList() { … }
std::optional<syncer::ModelError> AutofillWalletSyncBridge::MergeFullSyncData(
std::unique_ptr<syncer::MetadataChangeList> metadata_change_list,
syncer::EntityChangeList entity_data) { … }
std::optional<syncer::ModelError>
AutofillWalletSyncBridge::ApplyIncrementalSyncChanges(
std::unique_ptr<syncer::MetadataChangeList> metadata_change_list,
syncer::EntityChangeList entity_data) { … }
std::unique_ptr<syncer::DataBatch> AutofillWalletSyncBridge::GetDataForCommit(
StorageKeyList storage_keys) { … }
std::unique_ptr<syncer::DataBatch>
AutofillWalletSyncBridge::GetAllDataForDebugging() { … }
std::string AutofillWalletSyncBridge::GetClientTag(
const syncer::EntityData& entity_data) { … }
std::string AutofillWalletSyncBridge::GetStorageKey(
const syncer::EntityData& entity_data) { … }
bool AutofillWalletSyncBridge::SupportsIncrementalUpdates() const { … }
void AutofillWalletSyncBridge::ApplyDisableSyncChanges(
std::unique_ptr<syncer::MetadataChangeList> delete_metadata_change_list) { … }
std::unique_ptr<syncer::DataBatch>
AutofillWalletSyncBridge::GetAllDataForTesting() { … }
std::unique_ptr<syncer::DataBatch> AutofillWalletSyncBridge::GetAllDataImpl(
bool enforce_utf8) { … }
void AutofillWalletSyncBridge::SetSyncData(
const syncer::EntityChangeList& entity_data,
bool notify_webdata_backend) { … }
bool AutofillWalletSyncBridge::SetWalletCards(
std::vector<CreditCard> wallet_cards,
bool notify_webdata_backend) { … }
bool AutofillWalletSyncBridge::SetCardBenefits(
std::vector<CreditCardBenefit> card_benefits) { … }
bool AutofillWalletSyncBridge::SetWalletIbans(std::vector<Iban> wallet_ibans,
bool notify_webdata_backend) { … }
bool AutofillWalletSyncBridge::SetPaymentsCustomerData(
std::vector<PaymentsCustomerData> customer_data) { … }
bool AutofillWalletSyncBridge::SetCreditCardCloudTokenData(
const std::vector<CreditCardCloudTokenData>& cloud_token_data) { … }
bool AutofillWalletSyncBridge::SetBankAccountsData(
const std::vector<BankAccount>& bank_accounts) { … }
PaymentsAutofillTable* AutofillWalletSyncBridge::GetAutofillTable() { … }
AutofillSyncMetadataTable* AutofillWalletSyncBridge::GetSyncMetadataStore() { … }
void AutofillWalletSyncBridge::LoadMetadata() { … }
void AutofillWalletSyncBridge::LogVirtualCardMetadataChanges(
const std::vector<std::unique_ptr<CreditCard>>& old_data,
const std::vector<CreditCard>& new_data) { … }
void AutofillWalletSyncBridge::ReconcileServerCvcForWalletCards() { … }
}