OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/chrome/browser/payments/payment_request_error_coordinator.h" |
| 6 |
| 7 #import "base/ios/weak_nsobject.h" |
| 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "components/strings/grit/components_strings.h" |
| 10 #include "ui/base/l10n/l10n_util.h" |
| 11 |
| 12 @interface PaymentRequestErrorCoordinator () { |
| 13 base::WeakNSProtocol<id<PaymentRequestErrorCoordinatorDelegate>> _delegate; |
| 14 base::scoped_nsobject<PaymentRequestErrorViewController> _viewController; |
| 15 } |
| 16 |
| 17 @end |
| 18 |
| 19 @implementation PaymentRequestErrorCoordinator |
| 20 |
| 21 @synthesize callback = _callback; |
| 22 |
| 23 - (id<PaymentRequestErrorCoordinatorDelegate>)delegate { |
| 24 return _delegate.get(); |
| 25 } |
| 26 |
| 27 - (void)setDelegate:(id<PaymentRequestErrorCoordinatorDelegate>)delegate { |
| 28 _delegate.reset(delegate); |
| 29 } |
| 30 |
| 31 - (void)start { |
| 32 _viewController.reset([[PaymentRequestErrorViewController alloc] init]); |
| 33 [_viewController |
| 34 setErrorMessage:l10n_util::GetNSString(IDS_PAYMENTS_ERROR_MESSAGE)]; |
| 35 [_viewController setDelegate:self]; |
| 36 [_viewController loadModel]; |
| 37 |
| 38 [[self baseViewController] presentViewController:_viewController |
| 39 animated:YES |
| 40 completion:nil]; |
| 41 } |
| 42 |
| 43 - (void)stop { |
| 44 [[_viewController presentingViewController] |
| 45 dismissViewControllerAnimated:YES |
| 46 completion:nil]; |
| 47 _viewController.reset(); |
| 48 } |
| 49 |
| 50 #pragma mark - PaymentRequestErrorViewControllerDelegate |
| 51 |
| 52 - (void)paymentRequestErrorViewControllerDidDismiss: |
| 53 (PaymentRequestErrorViewController*)controller { |
| 54 [_delegate paymentRequestErrorCoordinatorDidDismiss:self]; |
| 55 } |
| 56 |
| 57 @end |
OLD | NEW |