| 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 b2b3fccdd0ad6c359291e69d41a6304e4bbe37c2..9973b91bea76b51c2d30bc85fa60dae05ccefa22 100644
|
| --- a/components/payments/core/payment_request_data_util.cc
|
| +++ b/components/payments/core/payment_request_data_util.cc
|
| @@ -155,10 +155,31 @@ void ParseBasicCardSupportedNetworks(
|
| base::string16 GetFormattedPhoneNumberForDisplay(
|
| const autofill::AutofillProfile& profile,
|
| const std::string& locale) {
|
| + // Since the "+" is removed for some country's phone numbers, try to add a "+"
|
| + // and see if it is a valid phone number for a country.
|
| + // Having two "+" in front of a number has no effect on the formatted number.
|
| + // The reason for this is international phone numbers for another country. For
|
| + // example, without adding a "+", the US number 1-415-123-1234 for an AU
|
| + // address would be wrongly formatted as +61 1-415-123-1234 which is invalid.
|
| + std::string phone = base::UTF16ToUTF8(profile.GetInfo(
|
| + autofill::AutofillType(autofill::PHONE_HOME_WHOLE_NUMBER), locale));
|
| + std::string tentative_intl_phone = "+" + phone;
|
| +
|
| + autofill::i18n::PhoneObject phone_obj(
|
| + base::UTF8ToUTF16(phone), GetCountryCodeWithFallback(&profile, locale));
|
| + autofill::i18n::PhoneObject tentative_intl_phone_obj(
|
| + base::UTF8ToUTF16(tentative_intl_phone),
|
| + GetCountryCodeWithFallback(&profile, locale));
|
| +
|
| + // Always favor the tentative international phone number if it's determined as
|
| + // being a valid number.
|
| + if (!tentative_intl_phone_obj.region().empty()) {
|
| + return base::UTF8ToUTF16(FormatPhoneForDisplay(
|
| + tentative_intl_phone, GetCountryCodeWithFallback(&profile, locale)));
|
| + }
|
| +
|
| return base::UTF8ToUTF16(FormatPhoneForDisplay(
|
| - base::UTF16ToUTF8(profile.GetInfo(
|
| - autofill::AutofillType(autofill::PHONE_HOME_WHOLE_NUMBER), locale)),
|
| - GetCountryCodeWithFallback(&profile, locale)));
|
| + phone, GetCountryCodeWithFallback(&profile, locale)));
|
| }
|
|
|
| std::string FormatPhoneForDisplay(const std::string& phone_number,
|
|
|