diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-09-03 13:32:17 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-10-01 14:31:55 +0200 |
commit | 21ba0c5d4bf8fba15dddd97cd693bad2358b77fd (patch) | |
tree | 91be119f694044dfc1ff9fdc054459e925de9df0 /chromium/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge.cc | |
parent | 03c549e0392f92c02536d3f86d5e1d8dfa3435ac (diff) | |
download | qtwebengine-chromium-21ba0c5d4bf8fba15dddd97cd693bad2358b77fd.tar.gz |
BASELINE: Update Chromium to 92.0.4515.166
Change-Id: I42a050486714e9e54fc271f2a8939223a02ae364
Diffstat (limited to 'chromium/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge.cc')
-rw-r--r-- | chromium/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge.cc | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/chromium/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge.cc b/chromium/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge.cc index 04421a3e523..41e3de12846 100644 --- a/chromium/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge.cc +++ b/chromium/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge.cc @@ -12,6 +12,7 @@ #include "base/logging.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "components/autofill/core/browser/autofill_metrics.h" #include "components/autofill/core/browser/autofill_profile_sync_util.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" #include "components/autofill/core/browser/data_model/credit_card.h" @@ -135,6 +136,35 @@ std::unique_ptr<EntityData> CreateEntityDataFromCreditCardCloudTokenData( return entity_data; } +// Checks whether the virtual card metadata for cards is updated, if so, logs +// accordingly. +void LogVirtualCardMetadataChanges( + const std::vector<std::unique_ptr<CreditCard>>& old_data, + const std::vector<CreditCard>& new_data) { + for (CreditCard new_card : new_data) { + if (new_card.virtual_card_enrollment_state() == + CreditCard::VirtualCardEnrollmentState::ENROLLED) { + // Find the old card with same server id. + auto old_data_iterator = std::find_if( + old_data.begin(), old_data.end(), + [&new_card](const std::unique_ptr<CreditCard>& old_card) { + return new_card.server_id() == old_card->server_id(); + }); + if (old_data_iterator != old_data.end()) { + // If the virtual card metadata has changed, log the updated sync. + if ((*old_data_iterator)->virtual_card_enrollment_state() != + new_card.virtual_card_enrollment_state() || + (*old_data_iterator)->card_art_url() != new_card.card_art_url()) { + AutofillMetrics::LogVirtualCardMetadataSynced(/*existing_card*/ true); + } + } else { + // No existing card with the same ID found; log the newly-synced card. + AutofillMetrics::LogVirtualCardMetadataSynced(/*existing_card*/ false); + } + } + } +} + } // namespace // static @@ -180,11 +210,11 @@ AutofillWalletSyncBridge::CreateMetadataChangeList() { GetAutofillTable(), syncer::AUTOFILL_WALLET_DATA); } -base::Optional<syncer::ModelError> AutofillWalletSyncBridge::MergeSyncData( +absl::optional<syncer::ModelError> AutofillWalletSyncBridge::MergeSyncData( std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, syncer::EntityChangeList entity_data) { // All metadata changes have been already written, return early for an error. - base::Optional<syncer::ModelError> error = + absl::optional<syncer::ModelError> error = static_cast<syncer::SyncMetadataStoreChangeList*>( metadata_change_list.get()) ->TakeError(); @@ -198,16 +228,16 @@ base::Optional<syncer::ModelError> AutofillWalletSyncBridge::MergeSyncData( // TODO(crbug.com/853688): Update the AutofillTable API to know about write // errors and report them here. - return base::nullopt; + return absl::nullopt; } -base::Optional<syncer::ModelError> AutofillWalletSyncBridge::ApplySyncChanges( +absl::optional<syncer::ModelError> AutofillWalletSyncBridge::ApplySyncChanges( std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, syncer::EntityChangeList entity_data) { // This bridge does not support incremental updates, so whenever this is // called, the change list should be empty. DCHECK(entity_data.empty()) << "Received an unsupported incremental update."; - return base::nullopt; + return absl::nullopt; } void AutofillWalletSyncBridge::GetData(StorageKeyList storage_keys, @@ -356,6 +386,10 @@ bool AutofillWalletSyncBridge::SetWalletCards( ComputeAutofillWalletDiff(existing_cards, wallet_cards); if (!diff.IsEmpty()) { + // Check if there is any update on cards' virtual card metadata. If so log + // it. + LogVirtualCardMetadataChanges(existing_cards, wallet_cards); + table->SetServerCardsData(wallet_cards); if (notify_metadata_bridge) { for (const CreditCardChange& change : diff.changes) { |