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

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

Issue 355823007: Adjust autofill phone number format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update android test. 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 10a71d6a7964a22a831e27001a86c657503156b2..246c5eb46ff85bd73f1987b8f611c4dca8598176 100644
--- a/components/autofill/core/browser/phone_number_i18n.cc
+++ b/components/autofill/core/browser/phone_number_i18n.cc
@@ -65,12 +65,24 @@ void FormatValidatedNumber(const PhoneNumber& number,
std::string processed_number;
phone_util->Format(number, format, &processed_number);
+ std::string region_code;
+ phone_util->GetRegionCodeForNumber(number, &region_code);
+
+ // Drop the leading '+' for US numbers as some US sites can't handle the "+",
+ // and in the US dialing "+1..." is the same as dialing "1...".
+ std::string prefix;
+ if (processed_number[0] == '+') {
+ processed_number = processed_number.substr(1);
+ if (region_code != "US")
+ prefix = "+";
+ }
+
if (formatted_number)
- *formatted_number = base::UTF8ToUTF16(processed_number);
+ *formatted_number = base::UTF8ToUTF16(prefix + processed_number);
if (normalized_number) {
phone_util->NormalizeDigitsOnly(&processed_number);
- *normalized_number = base::UTF8ToUTF16(processed_number);
+ *normalized_number = base::UTF8ToUTF16(prefix + processed_number);
}
}

Powered by Google App Engine
This is Rietveld 408576698