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

Unified Diff: ios/chrome/browser/ui/payments/payment_request_edit_view_controller.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/payment_request_edit_view_controller.mm
diff --git a/ios/chrome/browser/ui/payments/payment_request_edit_view_controller.mm b/ios/chrome/browser/ui/payments/payment_request_edit_view_controller.mm
index bd63f8cabd38ebb8934a76f649b429aa6bab6bb3..1a134d3cae3fce8f7a38d750452fa5c6f587dcd1 100644
--- a/ios/chrome/browser/ui/payments/payment_request_edit_view_controller.mm
+++ b/ios/chrome/browser/ui/payments/payment_request_edit_view_controller.mm
@@ -384,7 +384,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
}
// This method is called as the text is being typed in, pasted, or deleted. Asks
-// the delegate if the text should be changed. Should always return YES. During
+// the delegate if the text should be changed. Should always return NO. During
// typing/pasting text, |newText| contains one or more new characters. When user
// deletes text, |newText| is empty. |range| is the range of characters to be
// replaced.
@@ -401,24 +401,29 @@ typedef NS_ENUM(NSInteger, ItemType) {
AutofillEditItem* item = base::mac::ObjCCastStrict<AutofillEditItem>(
[model itemAtIndexPath:indexPath]);
- // Find the respective editor field and update its value.
+ // Find the respective editor field and update its value to the proposed text.
NSNumber* key = [NSNumber numberWithInt:sectionIdentifier];
EditorField* field = self.fieldsMap[key];
DCHECK(field);
- // Obtain the text being typed.
- NSString* updatedText =
- [textField.text stringByReplacingCharactersInRange:range
- withString:newText];
- field.value = updatedText;
+ field.value = [textField.text stringByReplacingCharactersInRange:range
+ withString:newText];
+
+ // Format the proposed text if necessary.
+ [_dataSource formatValueForEditorField:field];
+
+ // Since this method is returning NO, update the text field's value now.
+ textField.text = field.value;
// Get the icon that identifies the field value and reload the cell if the
// icon changes.
UIImage* oldIcon = item.identifyingIcon;
item.identifyingIcon = [_dataSource iconIdentifyingEditorField:field];
- if (item.identifyingIcon != oldIcon)
+ if (item.identifyingIcon != oldIcon) {
+ item.textFieldValue = field.value;
[self reconfigureCellsForItems:@[ item ]];
+ }
- return YES;
+ return NO;
}
#pragma mark - AutofillEditAccessoryDelegate

Powered by Google App Engine
This is Rietveld 408576698