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

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

Issue 2965073002: [Payment Request] Moves PaymentRequest into the payments namespace (Closed)
Patch Set: rebase Created 3 years, 5 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
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/ui/payments/credit_card_edit_mediator.h" 5 #import "ios/chrome/browser/ui/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"
(...skipping 21 matching lines...) Expand all
32 using ::autofill::data_util::GetIssuerNetworkForBasicCardIssuerNetwork; 32 using ::autofill::data_util::GetIssuerNetworkForBasicCardIssuerNetwork;
33 using ::autofill::data_util::GetPaymentRequestData; 33 using ::autofill::data_util::GetPaymentRequestData;
34 using ::payment_request_util::GetBillingAddressLabelFromAutofillProfile; 34 using ::payment_request_util::GetBillingAddressLabelFromAutofillProfile;
35 } // namespace 35 } // namespace
36 36
37 @interface CreditCardEditViewControllerMediator () 37 @interface CreditCardEditViewControllerMediator ()
38 38
39 // The PaymentRequest object owning an instance of web::PaymentRequest as 39 // The PaymentRequest object owning an instance of web::PaymentRequest as
40 // provided by the page invoking the Payment Request API. This is a weak 40 // provided by the page invoking the Payment Request API. This is a weak
41 // pointer and should outlive this class. 41 // pointer and should outlive this class.
42 @property(nonatomic, assign) PaymentRequest* paymentRequest; 42 @property(nonatomic, assign) payments::PaymentRequest* paymentRequest;
43 43
44 // The credit card to be edited, if any. This pointer is not owned by this class 44 // The credit card to be edited, if any. This pointer is not owned by this class
45 // and should outlive it. 45 // and should outlive it.
46 @property(nonatomic, assign) autofill::CreditCard* creditCard; 46 @property(nonatomic, assign) autofill::CreditCard* creditCard;
47 47
48 // The map of autofill types to the cached editor fields. Helps reuse the editor 48 // The map of autofill types to the cached editor fields. Helps reuse the editor
49 // fields and therefore maintain their existing values when the billing address 49 // fields and therefore maintain their existing values when the billing address
50 // changes and the fields get updated. 50 // changes and the fields get updated.
51 @property(nonatomic, strong) 51 @property(nonatomic, strong)
52 NSMutableDictionary<NSNumber*, EditorField*>* fieldsMap; 52 NSMutableDictionary<NSNumber*, EditorField*>* fieldsMap;
53 53
54 // The reference to the expiration date field that combines the values for 54 // The reference to the expiration date field that combines the values for
55 // autofill::CREDIT_CARD_EXP_MONTH and autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR 55 // autofill::CREDIT_CARD_EXP_MONTH and autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR
56 // field types. This is nil when editing a server card. 56 // field types. This is nil when editing a server card.
57 @property(nonatomic, strong) EditorField* creditCardExpDateField; 57 @property(nonatomic, strong) EditorField* creditCardExpDateField;
58 58
59 @end 59 @end
60 60
61 @implementation CreditCardEditViewControllerMediator 61 @implementation CreditCardEditViewControllerMediator
62 62
63 @synthesize state = _state; 63 @synthesize state = _state;
64 @synthesize consumer = _consumer; 64 @synthesize consumer = _consumer;
65 @synthesize billingProfile = _billingProfile; 65 @synthesize billingProfile = _billingProfile;
66 @synthesize paymentRequest = _paymentRequest; 66 @synthesize paymentRequest = _paymentRequest;
67 @synthesize creditCard = _creditCard; 67 @synthesize creditCard = _creditCard;
68 @synthesize fieldsMap = _fieldsMap; 68 @synthesize fieldsMap = _fieldsMap;
69 @synthesize creditCardExpDateField = _creditCardExpDateField; 69 @synthesize creditCardExpDateField = _creditCardExpDateField;
70 70
71 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest 71 - (instancetype)initWithPaymentRequest:(payments::PaymentRequest*)paymentRequest
72 creditCard:(autofill::CreditCard*)creditCard { 72 creditCard:(autofill::CreditCard*)creditCard {
73 self = [super init]; 73 self = [super init];
74 if (self) { 74 if (self) {
75 _paymentRequest = paymentRequest; 75 _paymentRequest = paymentRequest;
76 _creditCard = creditCard; 76 _creditCard = creditCard;
77 _state = _creditCard ? EditViewControllerStateEdit 77 _state = _creditCard ? EditViewControllerStateEdit
78 : EditViewControllerStateCreate; 78 : EditViewControllerStateCreate;
79 _billingProfile = 79 _billingProfile =
80 _creditCard && !_creditCard->billing_address_id().empty() 80 _creditCard && !_creditCard->billing_address_id().empty()
81 ? autofill::PersonalDataManager::GetProfileFromProfilesByGUID( 81 ? autofill::PersonalDataManager::GetProfileFromProfilesByGUID(
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 value:@"YES" 328 value:@"YES"
329 required:YES]; 329 required:YES];
330 [self.fieldsMap setObject:saveToChromeField forKey:fieldKey]; 330 [self.fieldsMap setObject:saveToChromeField forKey:fieldKey];
331 } 331 }
332 [fields addObject:saveToChromeField]; 332 [fields addObject:saveToChromeField];
333 333
334 return fields; 334 return fields;
335 } 335 }
336 336
337 @end 337 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698