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

Unified Diff: ios/chrome/browser/ui/settings/autofill_credit_card_edit_collection_view_controller.mm

Issue 2949283002: [iOS] Set credit card icon using the saved network. (Closed)
Patch Set: Rebased. 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/settings/autofill_credit_card_edit_collection_view_controller.mm
diff --git a/ios/chrome/browser/ui/settings/autofill_credit_card_edit_collection_view_controller.mm b/ios/chrome/browser/ui/settings/autofill_credit_card_edit_collection_view_controller.mm
index ecfbcfbd9459ab85d9df085635fde6ffca8aad31..4eeab2b8db19279e352bf461bd892f3bbeccd210 100644
--- a/ios/chrome/browser/ui/settings/autofill_credit_card_edit_collection_view_controller.mm
+++ b/ios/chrome/browser/ui/settings/autofill_credit_card_edit_collection_view_controller.mm
@@ -155,21 +155,21 @@ typedef NS_ENUM(NSInteger, ItemType) {
toSectionWithIdentifier:SectionIdentifierFields];
// Card number (PAN).
- AutofillEditItem* cardNumberitem =
+ AutofillEditItem* cardNumberItem =
[[AutofillEditItem alloc] initWithType:ItemTypeCardNumber];
- cardNumberitem.textFieldName =
+ cardNumberItem.textFieldName =
l10n_util::GetNSString(IDS_IOS_AUTOFILL_CARD_NUMBER);
// Never show full card number for Wallet cards, even if copied locally.
- cardNumberitem.textFieldValue =
+ cardNumberItem.textFieldValue =
autofill::IsCreditCardLocal(_creditCard)
? base::SysUTF16ToNSString(_creditCard.number())
- : base::SysUTF16ToNSString(_creditCard.LastFourDigits());
- cardNumberitem.textFieldEnabled = isEditing;
- cardNumberitem.autofillUIType = AutofillUITypeCreditCardNumber;
- cardNumberitem.keyboardType = UIKeyboardTypeNumberPad;
- cardNumberitem.identifyingIcon =
- [self cardTypeIconFromCardNumber:cardNumberitem.textFieldValue];
- [model addItem:cardNumberitem
+ : base::SysUTF16ToNSString(_creditCard.NetworkAndLastFourDigits());
+ cardNumberItem.textFieldEnabled = isEditing;
+ cardNumberItem.autofillUIType = AutofillUITypeCreditCardNumber;
+ cardNumberItem.keyboardType = UIKeyboardTypeNumberPad;
+ cardNumberItem.identifyingIcon =
+ [self cardTypeIconFromNetwork:_creditCard.network().c_str()];
+ [model addItem:cardNumberItem
toSectionWithIdentifier:SectionIdentifierFields];
// Expiration month.
@@ -232,7 +232,9 @@ typedef NS_ENUM(NSInteger, ItemType) {
NSString* updatedText =
[textField.text stringByReplacingCharactersInRange:range
withString:newText];
- item.identifyingIcon = [self cardTypeIconFromCardNumber:updatedText];
+ const char* network = autofill::CreditCard::GetCardNetwork(
+ base::SysNSStringToUTF16(updatedText));
+ item.identifyingIcon = [self cardTypeIconFromNetwork:network];
// Update the cell.
[self reconfigureCellsForItems:@[ item ]];
}
@@ -300,9 +302,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
#pragma mark - Helper Methods
-- (UIImage*)cardTypeIconFromCardNumber:(NSString*)cardNumber {
- const char* network = autofill::CreditCard::GetCardNetwork(
- base::SysNSStringToUTF16(cardNumber));
+- (UIImage*)cardTypeIconFromNetwork:(const char*)network {
if (network != autofill::kGenericCard) {
int resourceID =
autofill::data_util::GetPaymentRequestData(network).icon_resource_id;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698