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

Side by Side Diff: ios/chrome/browser/payments/credit_card_edit_mediator.mm

Issue 2826593005: [Payment Request] Sever card summary section in the credit card edit form (Closed)
Patch Set: Addressed comments 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 unified diff | Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/payments/credit_card_edit_view_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/payments/credit_card_edit_mediator.h" 5 #import "ios/chrome/browser/payments/credit_card_edit_mediator.h"
6 6
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #include "components/autofill/core/browser/autofill_data_util.h" 8 #include "components/autofill/core/browser/autofill_data_util.h"
9 #include "components/autofill/core/browser/autofill_profile.h" 9 #include "components/autofill/core/browser/autofill_profile.h"
10 #include "components/autofill/core/browser/credit_card.h" 10 #include "components/autofill/core/browser/credit_card.h"
11 #include "components/autofill/core/browser/personal_data_manager.h" 11 #include "components/autofill/core/browser/personal_data_manager.h"
12 #import "components/autofill/ios/browser/credit_card_util.h" 12 #import "components/autofill/ios/browser/credit_card_util.h"
13 #include "components/strings/grit/components_strings.h" 13 #include "components/strings/grit/components_strings.h"
14 #include "ios/chrome/browser/application_context.h" 14 #include "ios/chrome/browser/application_context.h"
15 #import "ios/chrome/browser/payments/cells/payment_method_item.h"
15 #include "ios/chrome/browser/payments/payment_request.h" 16 #include "ios/chrome/browser/payments/payment_request.h"
16 #import "ios/chrome/browser/payments/payment_request_editor_field.h" 17 #import "ios/chrome/browser/payments/payment_request_editor_field.h"
17 #import "ios/chrome/browser/payments/payment_request_util.h" 18 #import "ios/chrome/browser/payments/payment_request_util.h"
18 #import "ios/chrome/browser/ui/autofill/autofill_ui_type.h" 19 #import "ios/chrome/browser/ui/autofill/autofill_ui_type.h"
19 #import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h" 20 #import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h"
20 #import "ios/chrome/browser/ui/uikit_ui_util.h" 21 #import "ios/chrome/browser/ui/uikit_ui_util.h"
21 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
22 23
23 #if !defined(__has_feature) || !__has_feature(objc_arc) 24 #if !defined(__has_feature) || !__has_feature(objc_arc)
24 #error "This file requires ARC support." 25 #error "This file requires ARC support."
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 creditCard:(autofill::CreditCard*)creditCard { 58 creditCard:(autofill::CreditCard*)creditCard {
58 self = [super init]; 59 self = [super init];
59 if (self) { 60 if (self) {
60 _paymentRequest = paymentRequest; 61 _paymentRequest = paymentRequest;
61 _creditCard = creditCard; 62 _creditCard = creditCard;
62 _editorFields = [self createEditorFields]; 63 _editorFields = [self createEditorFields];
63 } 64 }
64 return self; 65 return self;
65 } 66 }
66 67
68 - (CollectionViewItem*)serverCardSummaryItem {
69 if (!_creditCard || autofill::IsCreditCardLocal(*_creditCard))
70 return nil;
71
72 PaymentMethodItem* cardSummaryItem = [[PaymentMethodItem alloc] init];
73 cardSummaryItem.methodID =
74 base::SysUTF16ToNSString(_creditCard->TypeAndLastFourDigits());
75 cardSummaryItem.methodDetail = base::SysUTF16ToNSString(
76 _creditCard->GetRawInfo(autofill::CREDIT_CARD_NAME_FULL));
77 const int cardTypeIconID =
78 autofill::data_util::GetPaymentRequestData(_creditCard->type())
79 .icon_resource_id;
80 cardSummaryItem.methodTypeIcon = NativeImage(cardTypeIconID);
81 return cardSummaryItem;
82 }
83
67 - (NSString*)billingAddressLabelForProfileWithGUID:(NSString*)profileGUID { 84 - (NSString*)billingAddressLabelForProfileWithGUID:(NSString*)profileGUID {
68 DCHECK(profileGUID); 85 DCHECK(profileGUID);
69 autofill::AutofillProfile* profile = 86 autofill::AutofillProfile* profile =
70 autofill::PersonalDataManager::GetProfileFromProfilesByGUID( 87 autofill::PersonalDataManager::GetProfileFromProfilesByGUID(
71 base::SysNSStringToUTF8(profileGUID), 88 base::SysNSStringToUTF8(profileGUID),
72 _paymentRequest->billing_profiles()); 89 _paymentRequest->billing_profiles());
73 DCHECK(profile); 90 DCHECK(profile);
74 return GetBillingAddressLabelFromAutofillProfile(*profile); 91 return GetBillingAddressLabelFromAutofillProfile(*profile);
75 } 92 }
76 93
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 [[EditorField alloc] 158 [[EditorField alloc]
142 initWithAutofillUIType:AutofillUITypeFromAutofillType( 159 initWithAutofillUIType:AutofillUITypeFromAutofillType(
143 autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR) 160 autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR)
144 label:l10n_util::GetNSString(IDS_PAYMENTS_EXP_YEAR) 161 label:l10n_util::GetNSString(IDS_PAYMENTS_EXP_YEAR)
145 value:creditCardExpYear 162 value:creditCardExpYear
146 required:YES] 163 required:YES]
147 ]; 164 ];
148 } 165 }
149 166
150 @end 167 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/payments/credit_card_edit_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698