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

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

Issue 2911973002: [Payments] Don't show error for intl phone from other country. (Closed)
Patch Set: Created 3 years, 7 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 9973b91bea76b51c2d30bc85fa60dae05ccefa22..7f689419603a7f6ac6d17d0017c271ce194d0820 100644
--- a/components/payments/core/payment_request_data_util.cc
+++ b/components/payments/core/payment_request_data_util.cc
@@ -13,6 +13,7 @@
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/personal_data_manager.h"
+#include "components/autofill/core/browser/validation.h"
#include "components/payments/core/basic_card_response.h"
#include "components/payments/core/payment_address.h"
#include "components/payments/core/payment_method_data.h"
@@ -165,15 +166,11 @@ base::string16 GetFormattedPhoneNumberForDisplay(
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()) {
+ if (autofill::IsValidPhoneNumber(
+ base::UTF8ToUTF16(tentative_intl_phone),
+ GetCountryCodeWithFallback(&profile, locale))) {
return base::UTF8ToUTF16(FormatPhoneForDisplay(
tentative_intl_phone, GetCountryCodeWithFallback(&profile, locale)));
}

Powered by Google App Engine
This is Rietveld 408576698