Commit 92f311a3 authored by Sujie Zhu's avatar Sujie Zhu Committed by Commit Bot

[Autofill local card migration settings page] Add IsMigratable attribute to each CreditCardEntry.

A card is migratable only when this card's card number and expiration date is valid and does not have a duplicated server card.

The validation and duplication check is only supported in the c++ side, so we add a new attribute called IsMigratable when we create each CreditCardEntry in autofill_util in order to check the migration requirement later.

The following CLs will be:

1. Use the added IsMigratable, syncStatus and experimental flag to check the migration requirement.

2. Display the migration button to the user when requirements meet.

3. Trigger migration when user click on the button with a new API call.

Please refer to the design doc for more details: https://docs.google.com/document/d/1J7YyBeKZZaBhjAHnMEezvuBa5x1pk_XCh_yZvV_HMmc/edit#heading=h.1wm3blr98d8i

Bug: 852904
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Ib02706bea5e7485eb8ac7dfd227003e3380e24af
Reviewed-on: https://chromium-review.googlesource.com/1173142
Commit-Queue: Sujie Zhu <sujiezhu@google.com>
Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583142}
parent dc66a2c9
......@@ -132,7 +132,8 @@ autofill_private::CountryEntry CountryToCountryEntry(
}
autofill_private::CreditCardEntry CreditCardToCreditCardEntry(
const autofill::CreditCard& credit_card) {
const autofill::CreditCard& credit_card,
const autofill::PersonalDataManager& personal_data) {
autofill_private::CreditCardEntry card;
// Add all credit card fields to the entry.
......@@ -158,6 +159,11 @@ autofill_private::CreditCardEntry CreditCardToCreditCardEntry(
credit_card.record_type() == autofill::CreditCard::LOCAL_CARD));
metadata->is_cached.reset(new bool(
credit_card.record_type() == autofill::CreditCard::FULL_SERVER_CARD));
// IsValid() checks if both card number and expiration date are valid.
// IsServerCard() checks whether there is a duplicated server card in
// |personal_data|.
metadata->is_migratable.reset(new bool(
credit_card.IsValid() && !personal_data.IsServerCard(&credit_card)));
card.metadata = std::move(metadata);
return card;
......@@ -210,7 +216,7 @@ CreditCardEntryList GenerateCreditCardList(
CreditCardEntryList list;
for (const autofill::CreditCard* card : cards)
list.push_back(CreditCardToCreditCardEntry(*card));
list.push_back(CreditCardToCreditCardEntry(*card, personal_data));
return list;
}
......
......@@ -38,6 +38,10 @@ namespace autofillPrivate {
// For credit cards, whether this is a full copy of the card
boolean? isCached;
// For credit cards, whether this is migratable (both the card number and
// expiration date valid and does not have the duplicated server card).
boolean? isMigratable;
};
// An address entry which can be saved in the autofill section of the
......@@ -209,7 +213,7 @@ namespace autofillPrivate {
static void saveCreditCard(CreditCardEntry card);
// Removes the entry (address or credit card) with the given ID.
// |guid|: ID of the entry to remove.
// |guid|: ID of the entry to remove.
static void removeEntry(DOMString guid);
// Validates a newly-added phone number and invokes the callback with a list
......
......@@ -36,7 +36,8 @@ chrome.autofillPrivate.AddressField = {
* summaryLabel: string,
* summarySublabel: (string|undefined),
* isLocal: (boolean|undefined),
* isCached: (boolean|undefined)
* isCached: (boolean|undefined),
* isMigratable: (boolean|undefined)
* }}
*/
chrome.autofillPrivate.AutofillMetadata;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment