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

Unified Diff: ios/chrome/browser/ui/payments/contact_info_edit_mediator.mm

Issue 2949813003: [Payment Request] Formats phone number and credit card number in editors. (Closed)
Patch Set: Fixed broken tests Created 3 years, 6 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: ios/chrome/browser/ui/payments/contact_info_edit_mediator.mm
diff --git a/ios/chrome/browser/ui/payments/contact_info_edit_mediator.mm b/ios/chrome/browser/ui/payments/contact_info_edit_mediator.mm
index 64446035c4b0384e94f7d280bda8a474d78b7d92..98e20b8d9f0714de23ded9be8bd94cc50457c559 100644
--- a/ios/chrome/browser/ui/payments/contact_info_edit_mediator.mm
+++ b/ios/chrome/browser/ui/payments/contact_info_edit_mediator.mm
@@ -6,9 +6,11 @@
#include "base/logging.h"
#include "base/strings/sys_string_conversions.h"
+#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/field_types.h"
+#include "components/payments/core/payment_request_data_util.h"
#include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/payments/payment_request.h"
@@ -74,6 +76,17 @@
return NO;
}
+- (void)formatValueForEditorField:(EditorField*)field {
+ if (field.autofillUIType == AutofillUITypeProfileHomePhoneWholeNumber) {
+ const std::string countryCode =
+ autofill::AutofillCountry::CountryCodeForLocale(
+ GetApplicationContext()->GetApplicationLocale());
+ field.value =
+ base::SysUTF8ToNSString(payments::data_util::FormatPhoneForDisplay(
+ base::SysNSStringToUTF8(field.value), countryCode));
+ }
+}
+
- (UIImage*)iconIdentifyingEditorField:(EditorField*)field {
return nil;
}
@@ -99,8 +112,12 @@
if (_paymentRequest->request_payer_phone()) {
NSString* phone =
- [self fieldValueFromProfile:self.profile
- fieldType:autofill::PHONE_HOME_WHOLE_NUMBER];
+ self.profile
+ ? base::SysUTF16ToNSString(
+ payments::data_util::GetFormattedPhoneNumberForDisplay(
+ *self.profile,
+ GetApplicationContext()->GetApplicationLocale()))
+ : nil;
EditorField* phoneField = [[EditorField alloc]
initWithAutofillUIType:AutofillUITypeProfileHomePhoneWholeNumber
fieldType:EditorFieldTypeTextField

Powered by Google App Engine
This is Rietveld 408576698