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

Unified Diff: ios/chrome/browser/ui/payments/credit_card_edit_coordinator.mm

Issue 2964213003: [Payment Request] Create billing address directly from credit card editor (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/ui/payments/credit_card_edit_coordinator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/payments/credit_card_edit_coordinator.mm
diff --git a/ios/chrome/browser/ui/payments/credit_card_edit_coordinator.mm b/ios/chrome/browser/ui/payments/credit_card_edit_coordinator.mm
index c0160bfab13ed445e2b1c30a9f863ede95868fa3..b31867ed58d5b97ac6a1668459fde6949c7f818d 100644
--- a/ios/chrome/browser/ui/payments/credit_card_edit_coordinator.mm
+++ b/ios/chrome/browser/ui/payments/credit_card_edit_coordinator.mm
@@ -72,6 +72,8 @@ bool IsValidCreditCardNumber(const base::string16& card_number,
@property(nonatomic, strong)
BillingAddressSelectionCoordinator* billingAddressSelectionCoordinator;
+@property(nonatomic, strong) AddressEditCoordinator* addressEditCoordinator;
+
@property(nonatomic, strong) UINavigationController* viewController;
@property(nonatomic, strong)
@@ -88,6 +90,7 @@ bool IsValidCreditCardNumber(const base::string16& card_number,
@synthesize delegate = _delegate;
@synthesize billingAddressSelectionCoordinator =
_billingAddressSelectionCoordinator;
+@synthesize addressEditCoordinator = _addressEditCoordinator;
@synthesize viewController = _viewController;
@synthesize editViewController = _editViewController;
@synthesize mediator = _mediator;
@@ -124,6 +127,8 @@ bool IsValidCreditCardNumber(const base::string16& card_number,
[[self.viewController presentingViewController]
dismissViewControllerAnimated:YES
completion:nil];
+ [self.addressEditCoordinator stop];
+ self.addressEditCoordinator = nil;
[self.billingAddressSelectionCoordinator stop];
self.billingAddressSelectionCoordinator = nil;
self.editViewController = nil;
@@ -171,15 +176,24 @@ bool IsValidCreditCardNumber(const base::string16& card_number,
(PaymentRequestEditViewController*)controller
didSelectField:(EditorField*)field {
if (field.autofillUIType == AutofillUITypeCreditCardBillingAddress) {
- self.billingAddressSelectionCoordinator =
- [[BillingAddressSelectionCoordinator alloc]
- initWithBaseViewController:self.editViewController];
- [self.billingAddressSelectionCoordinator
- setPaymentRequest:self.paymentRequest];
- [self.billingAddressSelectionCoordinator
- setSelectedBillingProfile:self.mediator.billingProfile];
- [self.billingAddressSelectionCoordinator setDelegate:self];
- [self.billingAddressSelectionCoordinator start];
+ if (_paymentRequest->billing_profiles().empty()) {
+ self.addressEditCoordinator = [[AddressEditCoordinator alloc]
+ initWithBaseViewController:_viewController];
+ [self.addressEditCoordinator setPaymentRequest:_paymentRequest];
+ [self.addressEditCoordinator setDelegate:self];
+ [self.addressEditCoordinator start];
+ return;
+ } else {
+ self.billingAddressSelectionCoordinator =
+ [[BillingAddressSelectionCoordinator alloc]
+ initWithBaseViewController:self.editViewController];
+ [self.billingAddressSelectionCoordinator
+ setPaymentRequest:self.paymentRequest];
+ [self.billingAddressSelectionCoordinator
+ setSelectedBillingProfile:self.mediator.billingProfile];
+ [self.billingAddressSelectionCoordinator setDelegate:self];
+ [self.billingAddressSelectionCoordinator start];
+ }
}
}
@@ -274,4 +288,24 @@ bool IsValidCreditCardNumber(const base::string16& card_number,
self.billingAddressSelectionCoordinator = nil;
}
+#pragma mark - AddressEditCoordinatorDelegate
+
+- (void)addressEditCoordinator:(AddressEditCoordinator*)coordinator
+ didFinishEditingAddress:(autofill::AutofillProfile*)address {
+ // Update view controller's data source with the selection and reload the view
+ // controller.
+ DCHECK(address);
+ [self.mediator setBillingProfile:address];
+ [self.editViewController loadModel];
+ [self.editViewController.collectionView reloadData];
+
+ [self.addressEditCoordinator stop];
+ self.addressEditCoordinator = nil;
+}
+
+- (void)addressEditCoordinatorDidCancel:(AddressEditCoordinator*)coordinator {
+ [self.addressEditCoordinator stop];
+ self.addressEditCoordinator = nil;
+}
+
@end
« no previous file with comments | « ios/chrome/browser/ui/payments/credit_card_edit_coordinator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698