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

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

Issue 2816083002: [WebPayments] Desktop implementation of Contact Editor (Closed)
Patch Set: compile error + 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
Index: components/autofill/core/browser/validation.cc
diff --git a/components/autofill/core/browser/validation.cc b/components/autofill/core/browser/validation.cc
index e7237f7b3b73d3fab1ad1a963a3cb245a0e0df3f..cbcbfb2d9934679fb62ea9946cf4138a0b6a51d8 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 {
@@ -140,8 +140,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) {

Powered by Google App Engine
This is Rietveld 408576698