Index: chrome/browser/autofill/phone_number_i18n.cc |
=================================================================== |
--- chrome/browser/autofill/phone_number_i18n.cc (revision 85992) |
+++ chrome/browser/autofill/phone_number_i18n.cc (working copy) |
@@ -9,6 +9,7 @@ |
#include "base/stringprintf.h" |
#include "base/string_number_conversions.h" |
#include "base/utf_string_conversions.h" |
+#include "chrome/browser/autofill/autofill_country.h" |
#include "third_party/libphonenumber/cpp/src/phonenumberutil.h" |
namespace { |
@@ -16,8 +17,8 @@ |
std::string SanitizeLocaleCode(const std::string& locale_code) { |
if (locale_code.length() == 2) |
return locale_code; |
- // Use USA for incomplete locales. |
- return std::string("US"); |
+ return AutofillCountry::CountryCodeForLocale( |
+ AutofillCountry::ApplicationLocale()); |
} |
i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat UtilsTypeToPhoneLibType( |
@@ -162,6 +163,12 @@ |
if (validation != i18n::phonenumbers::PhoneNumberUtil::IS_POSSIBLE) |
return false; |
+ // This verifies that number has a valid area code (that in some cases could |
+ // be empty) for parsed country code. Also verifies that this is a valid |
+ // number (in US 1234567 is not valid, because numbers do not start with 1). |
+ if (!phone_util->IsValidNumber(i18n_number)) |
+ return false; |
+ |
std::string formatted_number; |
phone_util->Format(i18n_number, UtilsTypeToPhoneLibType(phone_format), |