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

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

Issue 374053007: Change PhoneNumber::SetInfo to only apply formatting where there is none (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better way Created 6 years, 5 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/phone_number_i18n.cc
diff --git a/components/autofill/core/browser/phone_number_i18n.cc b/components/autofill/core/browser/phone_number_i18n.cc
index 72b2e1f481849956d8091f5bc9adb460ff4ddc0c..10a71d6a7964a22a831e27001a86c657503156b2 100644
--- a/components/autofill/core/browser/phone_number_i18n.cc
+++ b/components/autofill/core/browser/phone_number_i18n.cc
@@ -100,8 +100,9 @@ bool ParsePhoneNumber(const base::string16& value,
// The |default_region| should already be sanitized.
DCHECK_EQ(2U, default_region.size());
- if (phone_util->Parse(number_text, default_region, i18n_number) !=
- PhoneNumberUtil::NO_PARSING_ERROR) {
+ if (phone_util->ParseAndKeepRawInput(
+ number_text, default_region, i18n_number) !=
+ PhoneNumberUtil::NO_PARSING_ERROR) {
return false;
}
@@ -131,21 +132,13 @@ bool ParsePhoneNumber(const base::string16& value,
}
*number = base::UTF8ToUTF16(subscriber_number);
*city_code = base::UTF8ToUTF16(area_code);
- *country_code = base::string16();
-
- phone_util->NormalizeDigitsOnly(&number_text);
- base::string16 normalized_number(base::UTF8ToUTF16(number_text));
// Check if parsed number has a country code that was not inferred from the
// region.
- if (i18n_number->has_country_code()) {
+ if (i18n_number->has_country_code() &&
+ i18n_number->country_code_source() != PhoneNumber::FROM_DEFAULT_COUNTRY) {
*country_code = base::UTF8ToUTF16(
base::StringPrintf("%d", i18n_number->country_code()));
- if (normalized_number.length() <= national_significant_number.length() &&
- !StartsWith(normalized_number, *country_code,
- true /* case_sensitive */)) {
- country_code->clear();
- }
}
// The region might be different from what we started with.
« no previous file with comments | « components/autofill/core/browser/phone_number.cc ('k') | components/autofill/core/browser/phone_number_i18n_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698