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