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

Side by Side Diff: ios/chrome/browser/ui/payments/shipping_option_selection_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
« no previous file with comments | « ios/chrome/browser/ui/payments/shipping_option_selection_mediator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <vector> 5 #include <vector>
6 6
7 #import "ios/chrome/browser/ui/payments/shipping_option_selection_mediator.h" 7 #import "ios/chrome/browser/ui/payments/shipping_option_selection_mediator.h"
8 8
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "components/payments/core/currency_formatter.h" 11 #include "components/payments/core/currency_formatter.h"
12 #include "ios/chrome/browser/payments/payment_request.h" 12 #include "ios/chrome/browser/payments/payment_request.h"
13 #import "ios/chrome/browser/ui/payments/cells/payments_text_item.h" 13 #import "ios/chrome/browser/ui/payments/cells/payments_text_item.h"
14 #include "ios/chrome/browser/ui/uikit_ui_util.h" 14 #include "ios/chrome/browser/ui/uikit_ui_util.h"
15 #include "ios/chrome/grit/ios_theme_resources.h" 15 #include "ios/chrome/grit/ios_theme_resources.h"
16 #include "ios/web/public/payments/payment_request.h" 16 #include "ios/web/public/payments/payment_request.h"
17 17
18 #if !defined(__has_feature) || !__has_feature(objc_arc) 18 #if !defined(__has_feature) || !__has_feature(objc_arc)
19 #error "This file requires ARC support." 19 #error "This file requires ARC support."
20 #endif 20 #endif
21 21
22 @interface ShippingOptionSelectionMediator () 22 @interface ShippingOptionSelectionMediator ()
23 23
24 // The PaymentRequest object owning an instance of web::PaymentRequest as 24 // The PaymentRequest object owning an instance of web::PaymentRequest as
25 // provided by the page invoking the Payment Request API. This is a weak 25 // provided by the page invoking the Payment Request API. This is a weak
26 // pointer and should outlive this class. 26 // pointer and should outlive this class.
27 @property(nonatomic, assign) PaymentRequest* paymentRequest; 27 @property(nonatomic, assign) payments::PaymentRequest* paymentRequest;
28 28
29 // The selectable items to display in the collection. 29 // The selectable items to display in the collection.
30 @property(nonatomic, strong) NSMutableArray<PaymentsTextItem*>* items; 30 @property(nonatomic, strong) NSMutableArray<PaymentsTextItem*>* items;
31 31
32 // Creates and stores the selectable items to display in the collection. 32 // Creates and stores the selectable items to display in the collection.
33 - (void)loadItems; 33 - (void)loadItems;
34 34
35 @end 35 @end
36 36
37 @implementation ShippingOptionSelectionMediator 37 @implementation ShippingOptionSelectionMediator
38 38
39 @synthesize headerText = _headerText; 39 @synthesize headerText = _headerText;
40 @synthesize state = _state; 40 @synthesize state = _state;
41 @synthesize selectedItemIndex = _selectedItemIndex; 41 @synthesize selectedItemIndex = _selectedItemIndex;
42 @synthesize paymentRequest = _paymentRequest; 42 @synthesize paymentRequest = _paymentRequest;
43 @synthesize items = _items; 43 @synthesize items = _items;
44 44
45 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest { 45 - (instancetype)initWithPaymentRequest:
46 (payments::PaymentRequest*)paymentRequest {
46 self = [super init]; 47 self = [super init];
47 if (self) { 48 if (self) {
48 _paymentRequest = paymentRequest; 49 _paymentRequest = paymentRequest;
49 _selectedItemIndex = NSUIntegerMax; 50 _selectedItemIndex = NSUIntegerMax;
50 [self loadItems]; 51 [self loadItems];
51 } 52 }
52 return self; 53 return self;
53 } 54 }
54 55
55 #pragma mark - PaymentRequestSelectorViewControllerDataSource 56 #pragma mark - PaymentRequestSelectorViewControllerDataSource
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 item.detailText = SysUTF16ToNSString(currencyFormatter->Format( 94 item.detailText = SysUTF16ToNSString(currencyFormatter->Format(
94 base::UTF16ToASCII(shippingOption->amount.value))); 95 base::UTF16ToASCII(shippingOption->amount.value)));
95 if (_paymentRequest->selected_shipping_option() == shippingOption) 96 if (_paymentRequest->selected_shipping_option() == shippingOption)
96 _selectedItemIndex = index; 97 _selectedItemIndex = index;
97 98
98 [_items addObject:item]; 99 [_items addObject:item];
99 } 100 }
100 } 101 }
101 102
102 @end 103 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/payments/shipping_option_selection_mediator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698