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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/autofill/PhoneNumberUtil.java

Issue 2791973003: [Payments] Normalize contact info phone# in PaymentResponse on Android. (Closed)
Patch Set: Updated ContactDetails tests expectations to reflect the new phone formatting 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentResponseHelper.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/autofill/PhoneNumberUtil.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/PhoneNumberUtil.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/PhoneNumberUtil.java
index 2315304acbccca0cfad5f8fead07f7746bc5856f..d69cb1fb20ed772af84f14b89e09a9738f735abe 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/PhoneNumberUtil.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/PhoneNumberUtil.java
@@ -27,7 +27,7 @@ public class PhoneNumberUtil {
public void afterTextChanged(Editable s) {
if (mSelfChange) return;
- String formattedNumber = format(s.toString());
+ String formattedNumber = formatForDisplay(s.toString());
mSelfChange = true;
s.replace(0, s.length(), formattedNumber, 0, formattedNumber.length());
mSelfChange = false;
@@ -47,10 +47,24 @@ public class PhoneNumberUtil {
* office will be formatted as "+41 44 668 1800" in INTERNATIONAL format.
*
* @param phoneNumber The given phone number.
- * @return formatted phone number.
+ * @return Formatted phone number.
*/
- public static String format(String phoneNumber) {
- return nativeFormat(phoneNumber);
+ public static String formatForDisplay(String phoneNumber) {
+ return nativeFormatForDisplay(phoneNumber);
+ }
+
+ /**
+ * Formats the given phone number in E.164 format as specified in the Payment Request spec
+ * (https://w3c.github.io/browser-payment-api/#paymentrequest-updated-algorithm)
+ * [i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat::E164], returning the original number
+ * if no formatting can be made. For example, the number of the Google Zürich office will be
+ * formatted as "+41446681800" in E.164 format.
+ *
+ * @param phoneNumber The given phone number.
+ * @return Formatted phone number.
+ */
+ public static String formatForResponse(String phoneNumber) {
+ return nativeFormatForResponse(phoneNumber);
}
/**
@@ -65,6 +79,7 @@ public class PhoneNumberUtil {
return nativeIsValidNumber(phoneNumber);
}
- private static native String nativeFormat(String phoneNumber);
+ private static native String nativeFormatForDisplay(String phoneNumber);
+ private static native String nativeFormatForResponse(String phoneNumber);
private static native boolean nativeIsValidNumber(String phoneNumber);
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/payments/PaymentResponseHelper.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698