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

Unified Diff: ios/chrome/browser/payments/payment_method_selection_coordinator.mm

Issue 2585233003: Upstream Chrome on iOS source code [2/11]. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/payments/payment_method_selection_coordinator.mm
diff --git a/ios/chrome/browser/payments/payment_method_selection_coordinator.mm b/ios/chrome/browser/payments/payment_method_selection_coordinator.mm
new file mode 100644
index 0000000000000000000000000000000000000000..ba5add4259a558ff5f8bc73041b21487de83f0ba
--- /dev/null
+++ b/ios/chrome/browser/payments/payment_method_selection_coordinator.mm
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/payments/payment_method_selection_coordinator.h"
+
+#import "base/ios/weak_nsobject.h"
+#include "base/mac/scoped_nsobject.h"
+#include "components/autofill/core/browser/credit_card.h"
+
+@interface PaymentMethodSelectionCoordinator () {
+ base::WeakNSProtocol<id<PaymentMethodSelectionCoordinatorDelegate>> _delegate;
+ base::scoped_nsobject<PaymentMethodSelectionViewController> _viewController;
+}
+
+@end
+
+@implementation PaymentMethodSelectionCoordinator
+
+@synthesize paymentMethods = _paymentMethods;
+@synthesize selectedPaymentMethod = _selectedPaymentMethod;
+
+- (id<PaymentMethodSelectionCoordinatorDelegate>)delegate {
+ return _delegate.get();
+}
+
+- (void)setDelegate:(id<PaymentMethodSelectionCoordinatorDelegate>)delegate {
+ _delegate.reset(delegate);
+}
+
+- (void)start {
+ _viewController.reset([[PaymentMethodSelectionViewController alloc] init]);
+ [_viewController setPaymentMethods:_paymentMethods];
+ [_viewController setSelectedPaymentMethod:_selectedPaymentMethod];
+ [_viewController setDelegate:self];
+ [_viewController loadModel];
+
+ DCHECK([self baseViewController].navigationController);
+ [[self baseViewController].navigationController
+ pushViewController:_viewController
+ animated:YES];
+}
+
+- (void)stop {
+ [[self baseViewController].navigationController
+ popViewControllerAnimated:YES];
+ _viewController.reset();
+}
+
+#pragma mark - PaymentMethodSelectionViewControllerDelegate
+
+- (void)paymentMethodSelectionViewController:
+ (PaymentMethodSelectionViewController*)controller
+ selectedPaymentMethod:
+ (autofill::CreditCard*)paymentMethod {
+ _selectedPaymentMethod = paymentMethod;
+ [_delegate paymentMethodSelectionCoordinator:self
+ selectedPaymentMethod:paymentMethod];
+}
+
+- (void)paymentMethodSelectionViewControllerDidReturn:
+ (PaymentMethodSelectionViewController*)controller {
+ [_delegate paymentMethodSelectionCoordinatorDidReturn:self];
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698