Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Unified Diff: components/payments/core/payment_request_data_util.cc

Issue 2842463002: [Payments] Normalize billing address for response on Desktop. (Closed)
Patch Set: Keep the old version for iOS Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/payments/core/payment_request_data_util.cc
diff --git a/components/payments/core/payment_request_data_util.cc b/components/payments/core/payment_request_data_util.cc
index 9a5f5f4f9636f30dc2b60ac6423a53d4a92ff5c3..67dd07f8eef6220221b1de6657e5123572347d68 100644
--- a/components/payments/core/payment_request_data_util.cc
+++ b/components/payments/core/payment_request_data_util.cc
@@ -71,7 +71,7 @@ PaymentAddress GetPaymentAddressFromAutofillProfile(
BasicCardResponse GetBasicCardResponseFromAutofillCreditCard(
const autofill::CreditCard& card,
const base::string16& cvc,
- const std::vector<autofill::AutofillProfile*>& billing_profiles,
+ const autofill::AutofillProfile& billing_profile,
const std::string& app_locale) {
BasicCardResponse response;
response.cardholder_name = card.GetRawInfo(autofill::CREDIT_CARD_NAME_FULL);
@@ -81,18 +81,30 @@ BasicCardResponse GetBasicCardResponseFromAutofillCreditCard(
card.GetRawInfo(autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR);
response.card_security_code = cvc;
- // TODO(crbug.com/602666): Ensure we reach here only if the card has a billing
- // address. Then add DCHECK(!card->billing_address_id().empty()).
+ response.billing_address =
+ GetPaymentAddressFromAutofillProfile(billing_profile, app_locale);
+
+ return response;
+}
+
+BasicCardResponse GetBasicCardResponseFromAutofillCreditCard(
+ const autofill::CreditCard& card,
+ const base::string16& cvc,
+ const std::vector<autofill::AutofillProfile*>& billing_profiles,
+ const std::string& app_locale) {
+ autofill::AutofillProfile billing_profile;
+
+ // TODO(crbug.com/714655): This should be done in the autofill instrument.
if (!card.billing_address_id().empty()) {
const autofill::AutofillProfile* billing_address =
autofill::PersonalDataManager::GetProfileFromProfilesByGUID(
card.billing_address_id(), billing_profiles);
DCHECK(billing_address);
- response.billing_address =
- GetPaymentAddressFromAutofillProfile(*billing_address, app_locale);
+ billing_profile = *billing_address;
}
- return response;
+ return GetBasicCardResponseFromAutofillCreditCard(card, cvc, billing_profile,
+ app_locale);
}
void ParseBasicCardSupportedNetworks(

Powered by Google App Engine
This is Rietveld 408576698