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

Side by Side Diff: ios/chrome/browser/ui/payments/payment_request_coordinator.mm

Issue 2925053002: Revert of [Payment Request] Moves PaymentRequestViewController to :payments_ui (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 unified diff | Download patch
OLDNEW
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/ui/payments/payment_request_coordinator.h" 5 #import "ios/chrome/browser/ui/payments/payment_request_coordinator.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "components/autofill/core/browser/autofill_profile.h" 8 #include "components/autofill/core/browser/autofill_profile.h"
9 #include "components/autofill/core/browser/credit_card.h" 9 #include "components/autofill/core/browser/credit_card.h"
10 #include "components/payments/core/payment_address.h" 10 #include "components/payments/core/payment_address.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 @synthesize autofillManager = _autofillManager; 48 @synthesize autofillManager = _autofillManager;
49 @synthesize browserState = _browserState; 49 @synthesize browserState = _browserState;
50 @synthesize pageFavicon = _pageFavicon; 50 @synthesize pageFavicon = _pageFavicon;
51 @synthesize pageTitle = _pageTitle; 51 @synthesize pageTitle = _pageTitle;
52 @synthesize pageHost = _pageHost; 52 @synthesize pageHost = _pageHost;
53 @synthesize connectionSecure = _connectionSecure; 53 @synthesize connectionSecure = _connectionSecure;
54 @synthesize delegate = _delegate; 54 @synthesize delegate = _delegate;
55 55
56 - (void)start { 56 - (void)start {
57 _mediator = 57 _mediator =
58 [[PaymentRequestMediator alloc] initWithBrowserState:_browserState 58 [[PaymentRequestMediator alloc] initWithBrowserState:_browserState];
59 paymentRequest:_paymentRequest];
60 59
61 _viewController = [[PaymentRequestViewController alloc] init]; 60 _viewController = [[PaymentRequestViewController alloc]
61 initWithPaymentRequest:_paymentRequest];
62 [_viewController setPageFavicon:_pageFavicon]; 62 [_viewController setPageFavicon:_pageFavicon];
63 [_viewController setPageTitle:_pageTitle]; 63 [_viewController setPageTitle:_pageTitle];
64 [_viewController setPageHost:_pageHost]; 64 [_viewController setPageHost:_pageHost];
65 [_viewController setConnectionSecure:_connectionSecure]; 65 [_viewController setConnectionSecure:_connectionSecure];
66 [_viewController setDelegate:self]; 66 [_viewController setDelegate:self];
67 [_viewController setDataSource:_mediator]; 67 [_viewController setDataSource:_mediator];
68 [_viewController loadModel]; 68 [_viewController loadModel];
69 69
70 _navigationController = [[UINavigationController alloc] 70 _navigationController = [[UINavigationController alloc]
71 initWithRootViewController:_viewController]; 71 initWithRootViewController:_viewController];
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 [[_viewController collectionView] reloadData]; 117 [[_viewController collectionView] reloadData];
118 118
119 [_delegate paymentRequestCoordinator:self 119 [_delegate paymentRequestCoordinator:self
120 didCompletePaymentRequestWithCard:card 120 didCompletePaymentRequestWithCard:card
121 verificationCode:verificationCode]; 121 verificationCode:verificationCode];
122 } 122 }
123 123
124 - (void)updatePaymentDetails:(web::PaymentDetails)paymentDetails { 124 - (void)updatePaymentDetails:(web::PaymentDetails)paymentDetails {
125 BOOL totalValueChanged = 125 BOOL totalValueChanged =
126 (_paymentRequest->payment_details().total != paymentDetails.total); 126 (_paymentRequest->payment_details().total != paymentDetails.total);
127 [_mediator setTotalValueChanged:totalValueChanged];
128 _paymentRequest->UpdatePaymentDetails(paymentDetails); 127 _paymentRequest->UpdatePaymentDetails(paymentDetails);
129 128
130 if (_paymentRequest->shipping_options().empty()) { 129 if (_paymentRequest->shipping_options().empty()) {
131 // Display error in the shipping address/option selection view. 130 // Display error in the shipping address/option selection view.
132 if (_shippingAddressSelectionCoordinator) { 131 if (_shippingAddressSelectionCoordinator) {
133 _paymentRequest->set_selected_shipping_profile(nil); 132 _paymentRequest->set_selected_shipping_profile(nil);
134 [_shippingAddressSelectionCoordinator stopSpinnerAndDisplayError]; 133 [_shippingAddressSelectionCoordinator stopSpinnerAndDisplayError];
135 } else if (_shippingOptionSelectionCoordinator) { 134 } else if (_shippingOptionSelectionCoordinator) {
136 [_shippingOptionSelectionCoordinator stopSpinnerAndDisplayError]; 135 [_shippingOptionSelectionCoordinator stopSpinnerAndDisplayError];
137 } 136 }
138 // Update the payment request summary view. 137 // Update the payment request summary view.
139 [_viewController loadModel]; 138 [_viewController loadModel];
140 [[_viewController collectionView] reloadData]; 139 [[_viewController collectionView] reloadData];
141 } else { 140 } else {
142 // Update the payment summary item. 141 // Update the payment summary section.
143 [_viewController updatePaymentSummaryItem]; 142 [_viewController
143 updatePaymentSummaryWithTotalValueChanged:totalValueChanged];
144 144
145 if (_shippingAddressSelectionCoordinator) { 145 if (_shippingAddressSelectionCoordinator) {
146 // Set the selected shipping address. 146 // Set the selected shipping address and update the selected shipping
147 // address in the payment request summary view.
147 _paymentRequest->set_selected_shipping_profile(_pendingShippingAddress); 148 _paymentRequest->set_selected_shipping_profile(_pendingShippingAddress);
148 _pendingShippingAddress = nil; 149 _pendingShippingAddress = nil;
150 [_viewController updateSelectedShippingAddressUI];
149 151
150 // Dismiss the shipping address selection view. 152 // Dismiss the shipping address selection view.
151 [_shippingAddressSelectionCoordinator stop]; 153 [_shippingAddressSelectionCoordinator stop];
152 _shippingAddressSelectionCoordinator = nil; 154 _shippingAddressSelectionCoordinator = nil;
153 } else if (_shippingOptionSelectionCoordinator) { 155 } else if (_shippingOptionSelectionCoordinator) {
156 // Update the selected shipping option in the payment request summary
157 // view. The updated selection is already reflected in |_paymentRequest|.
158 [_viewController updateSelectedShippingOptionUI];
159
154 // Dismiss the shipping option selection view. 160 // Dismiss the shipping option selection view.
155 [_shippingOptionSelectionCoordinator stop]; 161 [_shippingOptionSelectionCoordinator stop];
156 _shippingOptionSelectionCoordinator = nil; 162 _shippingOptionSelectionCoordinator = nil;
157 } 163 }
158
159 // Update the Shipping section in the payment request summary view.
160 [_viewController updateShippingSection];
161 } 164 }
162 } 165 }
163 166
164 - (void)displayErrorWithCallback:(ProceduralBlock)callback { 167 - (void)displayErrorWithCallback:(ProceduralBlock)callback {
165 _errorCoordinator = [[PaymentRequestErrorCoordinator alloc] 168 _errorCoordinator = [[PaymentRequestErrorCoordinator alloc]
166 initWithBaseViewController:_navigationController]; 169 initWithBaseViewController:_navigationController];
167 [_errorCoordinator setCallback:callback]; 170 [_errorCoordinator setCallback:callback];
168 [_errorCoordinator setDelegate:self]; 171 [_errorCoordinator setDelegate:self];
169 172
170 [_errorCoordinator start]; 173 [_errorCoordinator start];
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 253
251 if (callback) 254 if (callback)
252 callback(); 255 callback();
253 } 256 }
254 257
255 #pragma mark - PaymentItemsDisplayCoordinatorDelegate 258 #pragma mark - PaymentItemsDisplayCoordinatorDelegate
256 259
257 - (void)paymentItemsDisplayCoordinatorDidReturn: 260 - (void)paymentItemsDisplayCoordinatorDidReturn:
258 (PaymentItemsDisplayCoordinator*)coordinator { 261 (PaymentItemsDisplayCoordinator*)coordinator {
259 // Clear the 'Updated' label on the payment summary item, if there is one. 262 // Clear the 'Updated' label on the payment summary item, if there is one.
260 [_viewController updatePaymentSummaryItem]; 263 [_viewController updatePaymentSummaryWithTotalValueChanged:NO];
261 264
262 [_itemsDisplayCoordinator stop]; 265 [_itemsDisplayCoordinator stop];
263 _itemsDisplayCoordinator = nil; 266 _itemsDisplayCoordinator = nil;
264 } 267 }
265 268
266 - (void)paymentItemsDisplayCoordinatorDidConfirm: 269 - (void)paymentItemsDisplayCoordinatorDidConfirm:
267 (PaymentItemsDisplayCoordinator*)coordinator { 270 (PaymentItemsDisplayCoordinator*)coordinator {
268 [self sendPaymentResponse]; 271 [self sendPaymentResponse];
269 } 272 }
270 273
271 #pragma mark - ContactInfoSelectionCoordinatorDelegate 274 #pragma mark - ContactInfoSelectionCoordinatorDelegate
272 275
273 - (void) 276 - (void)
274 contactInfoSelectionCoordinator:(ContactInfoSelectionCoordinator*)coordinator 277 contactInfoSelectionCoordinator:(ContactInfoSelectionCoordinator*)coordinator
275 didSelectContactProfile:(autofill::AutofillProfile*)contactProfile { 278 didSelectContactProfile:(autofill::AutofillProfile*)contactProfile {
276 _paymentRequest->set_selected_contact_profile(contactProfile); 279 _paymentRequest->set_selected_contact_profile(contactProfile);
277 280
278 [_viewController updateContactInfoSection]; 281 [_viewController updateSelectedContactInfoUI];
279 282
280 [_contactInfoSelectionCoordinator stop]; 283 [_contactInfoSelectionCoordinator stop];
281 _contactInfoSelectionCoordinator = nil; 284 _contactInfoSelectionCoordinator = nil;
282 } 285 }
283 286
284 - (void)contactInfoSelectionCoordinatorDidReturn: 287 - (void)contactInfoSelectionCoordinatorDidReturn:
285 (ContactInfoSelectionCoordinator*)coordinator { 288 (ContactInfoSelectionCoordinator*)coordinator {
286 [_contactInfoSelectionCoordinator stop]; 289 [_contactInfoSelectionCoordinator stop];
287 _contactInfoSelectionCoordinator = nil; 290 _contactInfoSelectionCoordinator = nil;
288 } 291 }
289 292
290 #pragma mark - ShippingAddressSelectionCoordinatorDelegate 293 #pragma mark - ShippingAddressSelectionCoordinatorDelegate
291 294
292 - (void)shippingAddressSelectionCoordinator: 295 - (void)shippingAddressSelectionCoordinator:
293 (ShippingAddressSelectionCoordinator*)coordinator 296 (ShippingAddressSelectionCoordinator*)coordinator
294 didSelectShippingAddress: 297 didSelectShippingAddress:
295 (autofill::AutofillProfile*)shippingAddress { 298 (autofill::AutofillProfile*)shippingAddress {
296 _pendingShippingAddress = shippingAddress; 299 _pendingShippingAddress = shippingAddress;
297 DCHECK(shippingAddress); 300 DCHECK(shippingAddress);
298 payments::PaymentAddress address = GetPaymentAddressFromAutofillProfile( 301 payments::PaymentAddress address = GetPaymentAddressFromAutofillProfile(
299 *shippingAddress, GetApplicationContext()->GetApplicationLocale()); 302 *shippingAddress, GetApplicationContext()->GetApplicationLocale());
300 [_delegate paymentRequestCoordinator:self didSelectShippingAddress:address]; 303 [_delegate paymentRequestCoordinator:self didSelectShippingAddress:address];
301 } 304 }
302 305
303 - (void)shippingAddressSelectionCoordinatorDidReturn: 306 - (void)shippingAddressSelectionCoordinatorDidReturn:
304 (ShippingAddressSelectionCoordinator*)coordinator { 307 (ShippingAddressSelectionCoordinator*)coordinator {
305 // Clear the 'Updated' label on the payment summary item, if there is one. 308 // Clear the 'Updated' label on the payment summary item, if there is one.
306 [_viewController updatePaymentSummaryItem]; 309 [_viewController updatePaymentSummaryWithTotalValueChanged:NO];
307 310
308 [_shippingAddressSelectionCoordinator stop]; 311 [_shippingAddressSelectionCoordinator stop];
309 _shippingAddressSelectionCoordinator = nil; 312 _shippingAddressSelectionCoordinator = nil;
310 } 313 }
311 314
312 #pragma mark - ShippingOptionSelectionCoordinatorDelegate 315 #pragma mark - ShippingOptionSelectionCoordinatorDelegate
313 316
314 - (void)shippingOptionSelectionCoordinator: 317 - (void)shippingOptionSelectionCoordinator:
315 (ShippingOptionSelectionCoordinator*)coordinator 318 (ShippingOptionSelectionCoordinator*)coordinator
316 didSelectShippingOption: 319 didSelectShippingOption:
317 (web::PaymentShippingOption*)shippingOption { 320 (web::PaymentShippingOption*)shippingOption {
318 [_delegate paymentRequestCoordinator:self 321 [_delegate paymentRequestCoordinator:self
319 didSelectShippingOption:*shippingOption]; 322 didSelectShippingOption:*shippingOption];
320 } 323 }
321 324
322 - (void)shippingOptionSelectionCoordinatorDidReturn: 325 - (void)shippingOptionSelectionCoordinatorDidReturn:
323 (ShippingAddressSelectionCoordinator*)coordinator { 326 (ShippingAddressSelectionCoordinator*)coordinator {
324 // Clear the 'Updated' label on the payment summary item, if there is one. 327 // Clear the 'Updated' label on the payment summary item, if there is one.
325 [_viewController updatePaymentSummaryItem]; 328 [_viewController updatePaymentSummaryWithTotalValueChanged:NO];
326 329
327 [_shippingOptionSelectionCoordinator stop]; 330 [_shippingOptionSelectionCoordinator stop];
328 _shippingOptionSelectionCoordinator = nil; 331 _shippingOptionSelectionCoordinator = nil;
329 } 332 }
330 333
331 #pragma mark - PaymentMethodSelectionCoordinatorDelegate 334 #pragma mark - PaymentMethodSelectionCoordinatorDelegate
332 335
333 - (void)paymentMethodSelectionCoordinator: 336 - (void)paymentMethodSelectionCoordinator:
334 (PaymentMethodSelectionCoordinator*)coordinator 337 (PaymentMethodSelectionCoordinator*)coordinator
335 didSelectPaymentMethod:(autofill::CreditCard*)creditCard { 338 didSelectPaymentMethod:(autofill::CreditCard*)creditCard {
336 _paymentRequest->set_selected_credit_card(creditCard); 339 _paymentRequest->set_selected_credit_card(creditCard);
337 340
338 [_viewController updatePaymentMethodSection]; 341 [_viewController updateSelectedPaymentMethodUI];
339 342
340 // Clear the 'Updated' label on the payment summary item, if there is one. 343 // Clear the 'Updated' label on the payment summary item, if there is one.
341 [_viewController updatePaymentSummaryItem]; 344 [_viewController updatePaymentSummaryWithTotalValueChanged:NO];
342 345
343 [_methodSelectionCoordinator stop]; 346 [_methodSelectionCoordinator stop];
344 _methodSelectionCoordinator = nil; 347 _methodSelectionCoordinator = nil;
345 } 348 }
346 349
347 - (void)paymentMethodSelectionCoordinatorDidReturn: 350 - (void)paymentMethodSelectionCoordinatorDidReturn:
348 (PaymentMethodSelectionCoordinator*)coordinator { 351 (PaymentMethodSelectionCoordinator*)coordinator {
349 // Clear the 'Updated' label on the payment summary item, if there is one. 352 // Clear the 'Updated' label on the payment summary item, if there is one.
350 [_viewController updatePaymentSummaryItem]; 353 [_viewController updatePaymentSummaryWithTotalValueChanged:NO];
351 354
352 [_methodSelectionCoordinator stop]; 355 [_methodSelectionCoordinator stop];
353 _methodSelectionCoordinator = nil; 356 _methodSelectionCoordinator = nil;
354 } 357 }
355 358
356 @end 359 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/payments/BUILD.gn ('k') | ios/chrome/browser/ui/payments/payment_request_mediator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698