OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/payment_method_selection_coordinator.h" | 5 #import "ios/chrome/browser/payments/payment_method_selection_coordinator.h" |
6 | 6 |
7 #include "components/autofill/core/browser/credit_card.h" | 7 #include "components/autofill/core/browser/credit_card.h" |
8 #include "ios/chrome/browser/payments/payment_request.h" | 8 #include "ios/chrome/browser/payments/payment_request.h" |
9 | 9 |
10 #if !defined(__has_feature) || !__has_feature(objc_arc) | 10 #if !defined(__has_feature) || !__has_feature(objc_arc) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 [_delegate paymentMethodSelectionCoordinatorDidReturn:self]; | 60 [_delegate paymentMethodSelectionCoordinatorDidReturn:self]; |
61 } | 61 } |
62 | 62 |
63 - (void)delayedNotifyDelegateOfSelection:(autofill::CreditCard*)paymentMethod { | 63 - (void)delayedNotifyDelegateOfSelection:(autofill::CreditCard*)paymentMethod { |
64 _viewController.view.userInteractionEnabled = NO; | 64 _viewController.view.userInteractionEnabled = NO; |
65 __weak PaymentMethodSelectionCoordinator* weakSelf = self; | 65 __weak PaymentMethodSelectionCoordinator* weakSelf = self; |
66 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, | 66 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, |
67 static_cast<int64_t>(0.2 * NSEC_PER_SEC)), | 67 static_cast<int64_t>(0.2 * NSEC_PER_SEC)), |
68 dispatch_get_main_queue(), ^{ | 68 dispatch_get_main_queue(), ^{ |
69 PaymentMethodSelectionCoordinator* strongSelf = weakSelf; | 69 PaymentMethodSelectionCoordinator* strongSelf = weakSelf; |
| 70 // Early return if the coordinator has been deallocated. |
| 71 if (!strongSelf) |
| 72 return; |
| 73 |
70 strongSelf.viewController.view.userInteractionEnabled = YES; | 74 strongSelf.viewController.view.userInteractionEnabled = YES; |
71 [strongSelf.delegate | 75 [strongSelf.delegate |
72 paymentMethodSelectionCoordinator:strongSelf | 76 paymentMethodSelectionCoordinator:strongSelf |
73 didSelectPaymentMethod:paymentMethod]; | 77 didSelectPaymentMethod:paymentMethod]; |
74 }); | 78 }); |
75 } | 79 } |
76 | 80 |
77 @end | 81 @end |
OLD | NEW |