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

Unified Diff: ios/chrome/browser/ui/payments/credit_card_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/credit_card_edit_mediator.mm
diff --git a/ios/chrome/browser/ui/payments/credit_card_edit_mediator.mm b/ios/chrome/browser/ui/payments/credit_card_edit_mediator.mm
index 3630dd3845094d86662753d9179a4e3544543857..2f8256186df61a2afe55cd6b4b36f5a5e0d61f9f 100644
--- a/ios/chrome/browser/ui/payments/credit_card_edit_mediator.mm
+++ b/ios/chrome/browser/ui/payments/credit_card_edit_mediator.mm
@@ -10,6 +10,7 @@
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#import "components/autofill/ios/browser/credit_card_util.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"
@@ -153,6 +154,14 @@ using ::payment_request_util::GetBillingAddressLabelFromAutofillProfile;
return !_creditCard || autofill::IsCreditCardLocal(*_creditCard);
}
+- (void)formatValueForEditorField:(EditorField*)field {
+ if (field.autofillUIType == AutofillUITypeCreditCardNumber) {
+ field.value = base::SysUTF16ToNSString(
+ payments::data_util::FormatCardNumberForDisplay(
+ base::SysNSStringToUTF16(field.value)));
+ }
+}
+
- (UIImage*)iconIdentifyingEditorField:(EditorField*)field {
// Early return if the field is not the credit card number field.
if (field.autofillUIType != AutofillUITypeCreditCardNumber)
@@ -253,7 +262,10 @@ using ::payment_request_util::GetBillingAddressLabelFromAutofillProfile;
// Credit Card number field.
NSString* creditCardNumber =
- _creditCard ? base::SysUTF16ToNSString(_creditCard->number()) : nil;
+ _creditCard ? base::SysUTF16ToNSString(
+ payments::data_util::FormatCardNumberForDisplay(
+ _creditCard->number()))
+ : nil;
fieldKey = [NSNumber numberWithInt:AutofillUITypeCreditCardNumber];
EditorField* creditCardNumberField = self.fieldsMap[fieldKey];
if (!creditCardNumberField) {

Powered by Google App Engine
This is Rietveld 408576698