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 #import "ios/chrome/browser/payments/shipping_option_selection_coordinator.h" | 5 #import "ios/chrome/browser/payments/shipping_option_selection_coordinator.h" |
6 | 6 |
7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
8 | 8 |
9 #if !defined(__has_feature) || !__has_feature(objc_arc) | 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
10 #error "This file requires ARC support." | 10 #error "This file requires ARC support." |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 - (void)stop { | 45 - (void)stop { |
46 [self.baseViewController.navigationController popViewControllerAnimated:YES]; | 46 [self.baseViewController.navigationController popViewControllerAnimated:YES]; |
47 _viewController = nil; | 47 _viewController = nil; |
48 } | 48 } |
49 | 49 |
50 - (void)stopSpinnerAndDisplayError { | 50 - (void)stopSpinnerAndDisplayError { |
51 // Re-enable user interactions that were disabled earlier in | 51 // Re-enable user interactions that were disabled earlier in |
52 // delayedNotifyDelegateOfSelection. | 52 // delayedNotifyDelegateOfSelection. |
53 _viewController.view.userInteractionEnabled = YES; | 53 _viewController.view.userInteractionEnabled = YES; |
54 | 54 |
55 [_viewController setIsLoading:NO]; | 55 [_viewController setIsPending:NO]; |
56 [_viewController | 56 [_viewController |
57 setErrorMessage:base::SysUTF16ToNSString( | 57 setErrorMessage:base::SysUTF16ToNSString( |
58 _paymentRequest->payment_details().error)]; | 58 _paymentRequest->payment_details().error)]; |
59 [_viewController loadModel]; | 59 [_viewController loadModel]; |
60 [[_viewController collectionView] reloadData]; | 60 [[_viewController collectionView] reloadData]; |
61 } | 61 } |
62 | 62 |
63 #pragma mark - ShippingOptionSelectionViewControllerDelegate | 63 #pragma mark - ShippingOptionSelectionViewControllerDelegate |
64 | 64 |
65 - (void)shippingOptionSelectionViewController: | 65 - (void)shippingOptionSelectionViewController: |
(...skipping 12 matching lines...) Expand all Loading... |
78 (web::PaymentShippingOption*)shippingOption { | 78 (web::PaymentShippingOption*)shippingOption { |
79 _viewController.view.userInteractionEnabled = NO; | 79 _viewController.view.userInteractionEnabled = NO; |
80 __weak ShippingOptionSelectionCoordinator* weakSelf = self; | 80 __weak ShippingOptionSelectionCoordinator* weakSelf = self; |
81 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, | 81 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, |
82 static_cast<int64_t>(0.2 * NSEC_PER_SEC)), | 82 static_cast<int64_t>(0.2 * NSEC_PER_SEC)), |
83 dispatch_get_main_queue(), ^{ | 83 dispatch_get_main_queue(), ^{ |
84 ShippingOptionSelectionCoordinator* strongSelf = weakSelf; | 84 ShippingOptionSelectionCoordinator* strongSelf = weakSelf; |
85 // Early return if the coordinator has been deallocated. | 85 // Early return if the coordinator has been deallocated. |
86 if (!strongSelf) | 86 if (!strongSelf) |
87 return; | 87 return; |
88 [strongSelf.viewController setIsLoading:YES]; | 88 [strongSelf.viewController setIsPending:YES]; |
89 [strongSelf.viewController loadModel]; | 89 [strongSelf.viewController loadModel]; |
90 [[strongSelf.viewController collectionView] reloadData]; | 90 [[strongSelf.viewController collectionView] reloadData]; |
91 | 91 |
92 [strongSelf.delegate | 92 [strongSelf.delegate |
93 shippingOptionSelectionCoordinator:strongSelf | 93 shippingOptionSelectionCoordinator:strongSelf |
94 didSelectShippingOption:shippingOption]; | 94 didSelectShippingOption:shippingOption]; |
95 }); | 95 }); |
96 } | 96 } |
97 | 97 |
98 @end | 98 @end |
OLD | NEW |