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