| OLD | NEW |
| 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 #include <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #import "ios/chrome/browser/ui/payments/billing_address_selection_mediator.h" | 7 #import "ios/chrome/browser/ui/payments/billing_address_selection_mediator.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 using ::payment_request_util::GetBillingAddressLabelFromAutofillProfile; | 27 using ::payment_request_util::GetBillingAddressLabelFromAutofillProfile; |
| 28 using ::payment_request_util::GetNameLabelFromAutofillProfile; | 28 using ::payment_request_util::GetNameLabelFromAutofillProfile; |
| 29 using ::payment_request_util::GetPhoneNumberLabelFromAutofillProfile; | 29 using ::payment_request_util::GetPhoneNumberLabelFromAutofillProfile; |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 @interface BillingAddressSelectionMediator () | 32 @interface BillingAddressSelectionMediator () |
| 33 | 33 |
| 34 // The PaymentRequest object owning an instance of web::PaymentRequest as | 34 // The PaymentRequest object owning an instance of web::PaymentRequest as |
| 35 // provided by the page invoking the Payment Request API. This is a weak | 35 // provided by the page invoking the Payment Request API. This is a weak |
| 36 // pointer and should outlive this class. | 36 // pointer and should outlive this class. |
| 37 @property(nonatomic, assign) PaymentRequest* paymentRequest; | 37 @property(nonatomic, assign) payments::PaymentRequest* paymentRequest; |
| 38 | 38 |
| 39 // The selected billing address, if any. | 39 // The selected billing address, if any. |
| 40 @property(nonatomic, assign) autofill::AutofillProfile* selectedBillingProfile; | 40 @property(nonatomic, assign) autofill::AutofillProfile* selectedBillingProfile; |
| 41 | 41 |
| 42 // The selectable items to display in the collection. | 42 // The selectable items to display in the collection. |
| 43 @property(nonatomic, strong) NSMutableArray<AutofillProfileItem*>* items; | 43 @property(nonatomic, strong) NSMutableArray<AutofillProfileItem*>* items; |
| 44 | 44 |
| 45 @end | 45 @end |
| 46 | 46 |
| 47 @implementation BillingAddressSelectionMediator | 47 @implementation BillingAddressSelectionMediator |
| 48 | 48 |
| 49 @synthesize state = _state; | 49 @synthesize state = _state; |
| 50 @synthesize selectedItemIndex = _selectedItemIndex; | 50 @synthesize selectedItemIndex = _selectedItemIndex; |
| 51 @synthesize paymentRequest = _paymentRequest; | 51 @synthesize paymentRequest = _paymentRequest; |
| 52 @synthesize selectedBillingProfile = _selectedBillingProfile; | 52 @synthesize selectedBillingProfile = _selectedBillingProfile; |
| 53 @synthesize items = _items; | 53 @synthesize items = _items; |
| 54 | 54 |
| 55 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest | 55 - (instancetype)initWithPaymentRequest:(payments::PaymentRequest*)paymentRequest |
| 56 selectedBillingProfile: | 56 selectedBillingProfile: |
| 57 (autofill::AutofillProfile*)selectedBillingProfile { | 57 (autofill::AutofillProfile*)selectedBillingProfile { |
| 58 self = [super init]; | 58 self = [super init]; |
| 59 if (self) { | 59 if (self) { |
| 60 DCHECK(paymentRequest); | 60 DCHECK(paymentRequest); |
| 61 _paymentRequest = paymentRequest; | 61 _paymentRequest = paymentRequest; |
| 62 _selectedBillingProfile = selectedBillingProfile; | 62 _selectedBillingProfile = selectedBillingProfile; |
| 63 _selectedItemIndex = NSUIntegerMax; | 63 _selectedItemIndex = NSUIntegerMax; |
| 64 [self loadItems]; | 64 [self loadItems]; |
| 65 } | 65 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 item.complete = _paymentRequest->profile_comparator()->IsShippingComplete( | 106 item.complete = _paymentRequest->profile_comparator()->IsShippingComplete( |
| 107 billingProfile); | 107 billingProfile); |
| 108 if (self.selectedBillingProfile == billingProfile) | 108 if (self.selectedBillingProfile == billingProfile) |
| 109 _selectedItemIndex = index; | 109 _selectedItemIndex = index; |
| 110 | 110 |
| 111 [_items addObject:item]; | 111 [_items addObject:item]; |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 @end | 115 @end |
| OLD | NEW |