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

Unified Diff: components/autofill/core/browser/validation.cc

Issue 2816083002: [WebPayments] Desktop implementation of Contact Editor (Closed)
Patch Set: rebase 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
« no previous file with comments | « components/autofill/core/browser/validation.h ('k') | components/payments_strings.grdp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/validation.cc
diff --git a/components/autofill/core/browser/validation.cc b/components/autofill/core/browser/validation.cc
index e6944314c98baa6df8978acefe2d56c9771d6325..fc15a8d940eae70c0923b6cf1ba4f8fc6dbcf407 100644
--- a/components/autofill/core/browser/validation.cc
+++ b/components/autofill/core/browser/validation.cc
@@ -15,11 +15,11 @@
#include "components/autofill/core/browser/autofill_data_util.h"
#include "components/autofill/core/browser/autofill_regex_constants.h"
#include "components/autofill/core/browser/credit_card.h"
-#include "components/autofill/core/browser/phone_number_i18n.h"
#include "components/autofill/core/browser/state_names.h"
#include "components/autofill/core/common/autofill_clock.h"
#include "components/autofill/core/common/autofill_regexes.h"
#include "components/strings/grit/components_strings.h"
+#include "third_party/libphonenumber/phonenumber_api.h"
#include "ui/base/l10n/l10n_util.h"
namespace autofill {
@@ -177,8 +177,16 @@ bool IsValidState(const base::string16& text) {
bool IsValidPhoneNumber(const base::string16& text,
const std::string& country_code) {
- i18n::PhoneObject phone_number(text, country_code);
- return phone_number.IsValidNumber();
+ ::i18n::phonenumbers::PhoneNumber parsed_number;
+ ::i18n::phonenumbers::PhoneNumberUtil* phone_number_util =
+ ::i18n::phonenumbers::PhoneNumberUtil::GetInstance();
+ if (phone_number_util->Parse(base::UTF16ToUTF8(text), country_code,
+ &parsed_number) !=
+ ::i18n::phonenumbers::PhoneNumberUtil::NO_PARSING_ERROR) {
+ return false;
+ }
+
+ return phone_number_util->IsValidNumber(parsed_number);
}
bool IsValidZip(const base::string16& text) {
« no previous file with comments | « components/autofill/core/browser/validation.h ('k') | components/payments_strings.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698