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

Unified Diff: components/autofill/core/browser/phone_number.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.cc
diff --git a/components/autofill/core/browser/phone_number.cc b/components/autofill/core/browser/phone_number.cc
index 66971ae05f5892286d11496557ca233f549cc025..6783677e3e77644882418e3098d1b94727ed3b56 100644
--- a/components/autofill/core/browser/phone_number.cc
+++ b/components/autofill/core/browser/phone_number.cc
@@ -134,9 +134,16 @@ bool PhoneNumber::SetInfo(const AutofillType& type,
if (number_.empty())
return true;
- // Store a formatted (i.e., pretty printed) version of the number.
+ // Store a formatted (i.e., pretty printed) version of the number if either
+ // the number doesn't contain formatting marks.
UpdateCacheIfNeeded(app_locale);
- number_ = cached_parsed_phone_.GetFormattedNumber();
+ if (base::ContainsOnlyChars(number_, base::ASCIIToUTF16("+0123456789"))) {
+ number_ = cached_parsed_phone_.GetFormattedNumber();
+ } else if (i18n::NormalizePhoneNumber(
+ number_, GetRegion(*profile_, app_locale)).empty()) {
+ // The number doesn't make sense for this region; clear it.
+ number_.clear();
+ }
return !number_.empty();
}

Powered by Google App Engine
This is Rietveld 408576698