| 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/payment_method_selection_mediator.h" | 7 #import "ios/chrome/browser/ui/payments/payment_method_selection_mediator.h" |
| 8 | 8 |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 using ::payment_request_util::GetBillingAddressLabelFromAutofillProfile; | 31 using ::payment_request_util::GetBillingAddressLabelFromAutofillProfile; |
| 32 using ::payment_request_util:: | 32 using ::payment_request_util:: |
| 33 GetPaymentMethodNotificationLabelFromPaymentMethod; | 33 GetPaymentMethodNotificationLabelFromPaymentMethod; |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 @interface PaymentMethodSelectionMediator () | 36 @interface PaymentMethodSelectionMediator () |
| 37 | 37 |
| 38 // The PaymentRequest object owning an instance of web::PaymentRequest as | 38 // The PaymentRequest object owning an instance of web::PaymentRequest as |
| 39 // provided by the page invoking the Payment Request API. This is a weak | 39 // provided by the page invoking the Payment Request API. This is a weak |
| 40 // pointer and should outlive this class. | 40 // pointer and should outlive this class. |
| 41 @property(nonatomic, assign) PaymentRequest* paymentRequest; | 41 @property(nonatomic, assign) payments::PaymentRequest* paymentRequest; |
| 42 | 42 |
| 43 // The selectable items to display in the collection. | 43 // The selectable items to display in the collection. |
| 44 @property(nonatomic, strong) NSMutableArray<PaymentMethodItem*>* items; | 44 @property(nonatomic, strong) NSMutableArray<PaymentMethodItem*>* items; |
| 45 | 45 |
| 46 @end | 46 @end |
| 47 | 47 |
| 48 @implementation PaymentMethodSelectionMediator | 48 @implementation PaymentMethodSelectionMediator |
| 49 | 49 |
| 50 @synthesize state = _state; | 50 @synthesize state = _state; |
| 51 @synthesize selectedItemIndex = _selectedItemIndex; | 51 @synthesize selectedItemIndex = _selectedItemIndex; |
| 52 @synthesize paymentRequest = _paymentRequest; | 52 @synthesize paymentRequest = _paymentRequest; |
| 53 @synthesize items = _items; | 53 @synthesize items = _items; |
| 54 | 54 |
| 55 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest { | 55 - (instancetype)initWithPaymentRequest: |
| 56 (payments::PaymentRequest*)paymentRequest { |
| 56 self = [super init]; | 57 self = [super init]; |
| 57 if (self) { | 58 if (self) { |
| 58 _paymentRequest = paymentRequest; | 59 _paymentRequest = paymentRequest; |
| 59 _selectedItemIndex = NSUIntegerMax; | 60 _selectedItemIndex = NSUIntegerMax; |
| 60 [self loadItems]; | 61 [self loadItems]; |
| 61 } | 62 } |
| 62 return self; | 63 return self; |
| 63 } | 64 } |
| 64 | 65 |
| 65 #pragma mark - PaymentRequestSelectorViewControllerDataSource | 66 #pragma mark - PaymentRequestSelectorViewControllerDataSource |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 124 |
| 124 item.reserveRoomForAccessoryType = YES; | 125 item.reserveRoomForAccessoryType = YES; |
| 125 if (_paymentRequest->selected_payment_method() == paymentMethod) | 126 if (_paymentRequest->selected_payment_method() == paymentMethod) |
| 126 _selectedItemIndex = index; | 127 _selectedItemIndex = index; |
| 127 | 128 |
| 128 [_items addObject:item]; | 129 [_items addObject:item]; |
| 129 } | 130 } |
| 130 } | 131 } |
| 131 | 132 |
| 132 @end | 133 @end |
| OLD | NEW |