Chromium Code Reviews| 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_request_coordinator.h" | 5 #import "ios/chrome/browser/payments/payment_request_coordinator.h" |
| 6 | 6 |
| 7 #include <unordered_set> | 7 #include <unordered_set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #import "base/ios/weak_nsobject.h" | |
| 11 #include "base/mac/objc_property_releaser.h" | |
| 12 #include "base/mac/scoped_nsobject.h" | |
| 13 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 14 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 15 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 17 #include "components/autofill/core/browser/autofill_client.h" | 14 #include "components/autofill/core/browser/autofill_client.h" |
| 18 #include "components/autofill/core/browser/autofill_data_util.h" | 15 #include "components/autofill/core/browser/autofill_data_util.h" |
| 19 #include "components/autofill/core/browser/autofill_profile.h" | 16 #include "components/autofill/core/browser/autofill_profile.h" |
| 20 #include "components/autofill/core/browser/credit_card.h" | 17 #include "components/autofill/core/browser/credit_card.h" |
| 21 #include "components/autofill/core/browser/field_types.h" | 18 #include "components/autofill/core/browser/field_types.h" |
| 22 #include "components/autofill/core/browser/payments/full_card_request.h" | 19 #include "components/autofill/core/browser/payments/full_card_request.h" |
| 23 #include "components/autofill/core/browser/personal_data_manager.h" | 20 #include "components/autofill/core/browser/personal_data_manager.h" |
| 24 #include "components/autofill/core/browser/ui/card_unmask_prompt_controller_impl .h" | 21 #include "components/autofill/core/browser/ui/card_unmask_prompt_controller_impl .h" |
| 25 #include "ios/chrome/browser/application_context.h" | 22 #include "ios/chrome/browser/application_context.h" |
| 26 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 23 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 27 #include "ios/chrome/browser/payments/payment_request.h" | 24 #include "ios/chrome/browser/payments/payment_request.h" |
| 28 #include "ios/chrome/browser/payments/payment_request_util.h" | 25 #include "ios/chrome/browser/payments/payment_request_util.h" |
| 29 #include "ios/chrome/browser/ui/autofill/card_unmask_prompt_view_bridge.h" | 26 #include "ios/chrome/browser/ui/autofill/card_unmask_prompt_view_bridge.h" |
| 30 | 27 |
| 28 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 29 #error "This file requires ARC support." | |
| 30 #endif | |
| 31 | |
| 31 // The unmask prompt UI for Payment Request. | 32 // The unmask prompt UI for Payment Request. |
| 32 class PRCardUnmaskPromptViewBridge | 33 class PRCardUnmaskPromptViewBridge |
| 33 : public autofill::CardUnmaskPromptViewBridge { | 34 : public autofill::CardUnmaskPromptViewBridge { |
| 34 public: | 35 public: |
| 35 explicit PRCardUnmaskPromptViewBridge( | 36 explicit PRCardUnmaskPromptViewBridge( |
| 36 autofill::CardUnmaskPromptController* controller, | 37 autofill::CardUnmaskPromptController* controller, |
| 37 UIViewController* base_view_controller) | 38 UIViewController* base_view_controller) |
| 38 : autofill::CardUnmaskPromptViewBridge(controller), | 39 : autofill::CardUnmaskPromptViewBridge(controller), |
| 39 base_view_controller_(base_view_controller){}; | 40 base_view_controller_(base_view_controller){}; |
|
sdefresne
2017/02/21 17:22:35
nit: remove trailing ;
stkhapugin
2017/02/22 17:47:06
Done.
| |
| 40 | 41 |
| 41 // autofill::CardUnmaskPromptView: | 42 // autofill::CardUnmaskPromptView: |
| 42 void Show() override { | 43 void Show() override { |
| 43 view_controller_.reset( | 44 view_controller_.reset( |
| 44 [[CardUnmaskPromptViewController alloc] initWithBridge:this]); | 45 [[CardUnmaskPromptViewController alloc] initWithBridge:this]); |
| 45 [base_view_controller_ presentViewController:view_controller_ | 46 [base_view_controller_ presentViewController:view_controller_ |
| 46 animated:YES | 47 animated:YES |
| 47 completion:nil]; | 48 completion:nil]; |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 private: | 51 private: |
| 51 UIViewController* base_view_controller_; // Weak. | 52 __weak UIViewController* base_view_controller_; |
| 52 DISALLOW_COPY_AND_ASSIGN(PRCardUnmaskPromptViewBridge); | 53 DISALLOW_COPY_AND_ASSIGN(PRCardUnmaskPromptViewBridge); |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 // Receives the full credit card details. Also displays the unmask prompt UI. | 56 // Receives the full credit card details. Also displays the unmask prompt UI. |
| 56 class FullCardRequester | 57 class FullCardRequester |
| 57 : public autofill::payments::FullCardRequest::ResultDelegate, | 58 : public autofill::payments::FullCardRequest::ResultDelegate, |
| 58 public autofill::payments::FullCardRequest::UIDelegate, | 59 public autofill::payments::FullCardRequest::UIDelegate, |
| 59 public base::SupportsWeakPtr<FullCardRequester> { | 60 public base::SupportsWeakPtr<FullCardRequester> { |
| 60 public: | 61 public: |
| 61 explicit FullCardRequester(PaymentRequestCoordinator* owner, | 62 explicit FullCardRequester(PaymentRequestCoordinator* owner, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 card, reason, delegate); | 102 card, reason, delegate); |
| 102 } | 103 } |
| 103 | 104 |
| 104 // payments::FullCardRequest::UIDelegate: | 105 // payments::FullCardRequest::UIDelegate: |
| 105 void OnUnmaskVerificationResult( | 106 void OnUnmaskVerificationResult( |
| 106 autofill::AutofillClient::PaymentsRpcResult result) override { | 107 autofill::AutofillClient::PaymentsRpcResult result) override { |
| 107 unmask_controller_.OnVerificationResult(result); | 108 unmask_controller_.OnVerificationResult(result); |
| 108 } | 109 } |
| 109 | 110 |
| 110 private: | 111 private: |
| 111 PaymentRequestCoordinator* owner_; // Weak. Owns this instance. | 112 __weak PaymentRequestCoordinator* owner_; |
| 112 UIViewController* base_view_controller_; // Weak. | 113 __weak UIViewController* base_view_controller_; |
| 113 autofill::CardUnmaskPromptControllerImpl unmask_controller_; | 114 autofill::CardUnmaskPromptControllerImpl unmask_controller_; |
| 114 | 115 |
| 115 DISALLOW_COPY_AND_ASSIGN(FullCardRequester); | 116 DISALLOW_COPY_AND_ASSIGN(FullCardRequester); |
| 116 }; | 117 }; |
| 117 | 118 |
| 118 @interface PaymentRequestCoordinator () { | 119 @implementation PaymentRequestCoordinator { |
| 119 base::WeakNSProtocol<id<PaymentRequestCoordinatorDelegate>> _delegate; | 120 UINavigationController* _navigationController; |
| 120 base::scoped_nsobject<UINavigationController> _navigationController; | 121 PaymentRequestViewController* _viewController; |
| 121 base::scoped_nsobject<PaymentRequestViewController> _viewController; | 122 PaymentItemsDisplayCoordinator* _itemsDisplayCoordinator; |
| 122 base::scoped_nsobject<PaymentItemsDisplayCoordinator> | 123 ShippingAddressSelectionCoordinator* _shippingAddressSelectionCoordinator; |
| 123 _itemsDisplayCoordinator; | 124 ShippingOptionSelectionCoordinator* _shippingOptionSelectionCoordinator; |
| 124 base::scoped_nsobject<ShippingAddressSelectionCoordinator> | 125 PaymentMethodSelectionCoordinator* _methodSelectionCoordinator; |
| 125 _shippingAddressSelectionCoordinator; | |
| 126 base::scoped_nsobject<ShippingOptionSelectionCoordinator> | |
| 127 _shippingOptionSelectionCoordinator; | |
| 128 base::scoped_nsobject<PaymentMethodSelectionCoordinator> | |
| 129 _methodSelectionCoordinator; | |
| 130 | 126 |
| 131 // Receiver of the full credit card details. Also displays the unmask prompt | 127 // Receiver of the full credit card details. Also displays the unmask prompt |
| 132 // UI. | 128 // UI. |
| 133 std::unique_ptr<FullCardRequester> _fullCardRequester; | 129 std::unique_ptr<FullCardRequester> _fullCardRequester; |
| 134 | 130 |
| 135 base::mac::ObjCPropertyReleaser _propertyReleaser_PaymentRequestCoordinator; | |
| 136 } | |
| 137 | |
| 138 @end | |
| 139 | |
| 140 @implementation PaymentRequestCoordinator { | |
| 141 // The selected shipping address, pending approval from the page. | 131 // The selected shipping address, pending approval from the page. |
| 142 autofill::AutofillProfile* _pendingShippingAddress; | 132 autofill::AutofillProfile* _pendingShippingAddress; |
| 143 } | 133 } |
| 144 | 134 |
| 145 @synthesize paymentRequest = _paymentRequest; | 135 @synthesize paymentRequest = _paymentRequest; |
| 146 @synthesize autofillManager = _autofillManager; | 136 @synthesize autofillManager = _autofillManager; |
| 147 @synthesize browserState = _browserState; | 137 @synthesize browserState = _browserState; |
| 148 @synthesize pageFavicon = _pageFavicon; | 138 @synthesize pageFavicon = _pageFavicon; |
| 149 @synthesize pageTitle = _pageTitle; | 139 @synthesize pageTitle = _pageTitle; |
| 150 @synthesize pageHost = _pageHost; | 140 @synthesize pageHost = _pageHost; |
| 141 @synthesize delegate = _delegate; | |
| 151 | 142 |
| 152 - (instancetype)initWithBaseViewController: | 143 - (instancetype)initWithBaseViewController:(UIViewController*)viewController { |
|
sdefresne
2017/02/21 17:22:35
maybe remove this method as you're just forwarding
marq (ping after 24h)
2017/02/22 11:55:58
+1
stkhapugin
2017/02/22 17:47:06
I originally tried doing this (see patchset 2). Ho
| |
| 153 (UIViewController*)baseViewController { | 144 return [super initWithBaseViewController:viewController]; |
| 154 if ((self = [super initWithBaseViewController:baseViewController])) { | |
| 155 _propertyReleaser_PaymentRequestCoordinator.Init( | |
| 156 self, [PaymentRequestCoordinator class]); | |
| 157 } | |
| 158 return self; | |
| 159 } | |
| 160 | |
| 161 - (id<PaymentRequestCoordinatorDelegate>)delegate { | |
| 162 return _delegate.get(); | |
| 163 } | |
| 164 | |
| 165 - (void)setDelegate:(id<PaymentRequestCoordinatorDelegate>)delegate { | |
| 166 _delegate.reset(delegate); | |
| 167 } | 145 } |
| 168 | 146 |
| 169 - (void)start { | 147 - (void)start { |
| 170 _viewController.reset([[PaymentRequestViewController alloc] | 148 _viewController = [[PaymentRequestViewController alloc] |
| 171 initWithPaymentRequest:_paymentRequest]); | 149 initWithPaymentRequest:_paymentRequest]; |
| 172 [_viewController setPageFavicon:_pageFavicon]; | 150 [_viewController setPageFavicon:_pageFavicon]; |
| 173 [_viewController setPageTitle:_pageTitle]; | 151 [_viewController setPageTitle:_pageTitle]; |
| 174 [_viewController setPageHost:_pageHost]; | 152 [_viewController setPageHost:_pageHost]; |
| 175 [_viewController setDelegate:self]; | 153 [_viewController setDelegate:self]; |
| 176 [_viewController loadModel]; | 154 [_viewController loadModel]; |
| 177 | 155 |
| 178 _navigationController.reset([[UINavigationController alloc] | 156 _navigationController = [[UINavigationController alloc] |
| 179 initWithRootViewController:_viewController]); | 157 initWithRootViewController:_viewController]; |
| 180 [_navigationController setNavigationBarHidden:YES]; | 158 [_navigationController setNavigationBarHidden:YES]; |
| 181 | 159 |
| 182 [[self baseViewController] presentViewController:_navigationController | 160 [[self baseViewController] presentViewController:_navigationController |
| 183 animated:YES | 161 animated:YES |
| 184 completion:nil]; | 162 completion:nil]; |
| 185 } | 163 } |
| 186 | 164 |
| 187 - (void)stop { | 165 - (void)stop { |
| 188 [[_navigationController presentingViewController] | 166 [[_navigationController presentingViewController] |
| 189 dismissViewControllerAnimated:YES | 167 dismissViewControllerAnimated:YES |
| 190 completion:nil]; | 168 completion:nil]; |
| 191 _itemsDisplayCoordinator.reset(); | 169 _itemsDisplayCoordinator = nil; |
| 192 _shippingAddressSelectionCoordinator.reset(); | 170 _shippingAddressSelectionCoordinator = nil; |
| 193 _shippingOptionSelectionCoordinator.reset(); | 171 _shippingOptionSelectionCoordinator = nil; |
| 194 _methodSelectionCoordinator.reset(); | 172 _methodSelectionCoordinator = nil; |
| 195 _navigationController.reset(); | 173 _navigationController = nil; |
| 196 _viewController.reset(); | 174 _viewController = nil; |
| 197 } | 175 } |
| 198 | 176 |
| 199 - (void)sendPaymentResponse { | 177 - (void)sendPaymentResponse { |
| 200 DCHECK(_paymentRequest->selected_credit_card()); | 178 DCHECK(_paymentRequest->selected_credit_card()); |
| 201 autofill::CreditCard* card = _paymentRequest->selected_credit_card(); | 179 autofill::CreditCard* card = _paymentRequest->selected_credit_card(); |
| 202 _fullCardRequester = base::MakeUnique<FullCardRequester>( | 180 _fullCardRequester = base::MakeUnique<FullCardRequester>( |
| 203 self, _navigationController, _browserState); | 181 self, _navigationController, _browserState); |
| 204 _fullCardRequester->GetFullCard(card, _autofillManager); | 182 _fullCardRequester->GetFullCard(card, _autofillManager); |
| 205 } | 183 } |
| 206 | 184 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 | 231 |
| 254 if (_shippingAddressSelectionCoordinator) { | 232 if (_shippingAddressSelectionCoordinator) { |
| 255 // Set the selected shipping address and update the selected shipping | 233 // Set the selected shipping address and update the selected shipping |
| 256 // address in the payment request summary view. | 234 // address in the payment request summary view. |
| 257 _paymentRequest->set_selected_shipping_profile(_pendingShippingAddress); | 235 _paymentRequest->set_selected_shipping_profile(_pendingShippingAddress); |
| 258 _pendingShippingAddress = nil; | 236 _pendingShippingAddress = nil; |
| 259 [_viewController updateSelectedShippingAddressUI]; | 237 [_viewController updateSelectedShippingAddressUI]; |
| 260 | 238 |
| 261 // Dismiss the shipping address selection view. | 239 // Dismiss the shipping address selection view. |
| 262 [_shippingAddressSelectionCoordinator stop]; | 240 [_shippingAddressSelectionCoordinator stop]; |
| 263 _shippingAddressSelectionCoordinator.reset(); | 241 _shippingAddressSelectionCoordinator = nil; |
| 264 } else if (_shippingOptionSelectionCoordinator) { | 242 } else if (_shippingOptionSelectionCoordinator) { |
| 265 // Update the selected shipping option in the payment request summary | 243 // Update the selected shipping option in the payment request summary |
| 266 // view. The updated selection is already reflected in |_paymentRequest|. | 244 // view. The updated selection is already reflected in |_paymentRequest|. |
| 267 [_viewController updateSelectedShippingOptionUI]; | 245 [_viewController updateSelectedShippingOptionUI]; |
| 268 | 246 |
| 269 // Dismiss the shipping option selection view. | 247 // Dismiss the shipping option selection view. |
| 270 [_shippingOptionSelectionCoordinator stop]; | 248 [_shippingOptionSelectionCoordinator stop]; |
| 271 _shippingOptionSelectionCoordinator.reset(); | 249 _shippingOptionSelectionCoordinator = nil; |
| 272 } | 250 } |
| 273 } | 251 } |
| 274 } | 252 } |
| 275 | 253 |
| 276 #pragma mark - PaymentRequestViewControllerDelegate | 254 #pragma mark - PaymentRequestViewControllerDelegate |
| 277 | 255 |
| 278 - (void)paymentRequestViewControllerDidCancel: | 256 - (void)paymentRequestViewControllerDidCancel: |
| 279 (PaymentRequestViewController*)controller { | 257 (PaymentRequestViewController*)controller { |
| 280 [_delegate paymentRequestCoordinatorDidCancel:self]; | 258 [_delegate paymentRequestCoordinatorDidCancel:self]; |
| 281 } | 259 } |
| 282 | 260 |
| 283 - (void)paymentRequestViewControllerDidConfirm: | 261 - (void)paymentRequestViewControllerDidConfirm: |
| 284 (PaymentRequestViewController*)controller { | 262 (PaymentRequestViewController*)controller { |
| 285 [self sendPaymentResponse]; | 263 [self sendPaymentResponse]; |
| 286 } | 264 } |
| 287 | 265 |
| 288 - (void)paymentRequestViewControllerDidSelectPaymentSummaryItem: | 266 - (void)paymentRequestViewControllerDidSelectPaymentSummaryItem: |
| 289 (PaymentRequestViewController*)controller { | 267 (PaymentRequestViewController*)controller { |
| 290 _itemsDisplayCoordinator.reset([[PaymentItemsDisplayCoordinator alloc] | 268 _itemsDisplayCoordinator = [[PaymentItemsDisplayCoordinator alloc] |
| 291 initWithBaseViewController:_viewController]); | 269 initWithBaseViewController:_viewController]; |
| 292 [_itemsDisplayCoordinator setPaymentRequest:_paymentRequest]; | 270 [_itemsDisplayCoordinator setPaymentRequest:_paymentRequest]; |
| 293 [_itemsDisplayCoordinator setDelegate:self]; | 271 [_itemsDisplayCoordinator setDelegate:self]; |
| 294 | 272 |
| 295 [_itemsDisplayCoordinator start]; | 273 [_itemsDisplayCoordinator start]; |
| 296 } | 274 } |
| 297 | 275 |
| 298 - (void)paymentRequestViewControllerDidSelectShippingAddressItem: | 276 - (void)paymentRequestViewControllerDidSelectShippingAddressItem: |
| 299 (PaymentRequestViewController*)controller { | 277 (PaymentRequestViewController*)controller { |
| 300 _shippingAddressSelectionCoordinator.reset( | 278 _shippingAddressSelectionCoordinator = |
| 301 [[ShippingAddressSelectionCoordinator alloc] | 279 [[ShippingAddressSelectionCoordinator alloc] |
| 302 initWithBaseViewController:_viewController]); | 280 initWithBaseViewController:_viewController]; |
| 303 [_shippingAddressSelectionCoordinator setPaymentRequest:_paymentRequest]; | 281 [_shippingAddressSelectionCoordinator setPaymentRequest:_paymentRequest]; |
| 304 [_shippingAddressSelectionCoordinator setDelegate:self]; | 282 [_shippingAddressSelectionCoordinator setDelegate:self]; |
| 305 | 283 |
| 306 [_shippingAddressSelectionCoordinator start]; | 284 [_shippingAddressSelectionCoordinator start]; |
| 307 } | 285 } |
| 308 | 286 |
| 309 - (void)paymentRequestViewControllerDidSelectShippingOptionItem: | 287 - (void)paymentRequestViewControllerDidSelectShippingOptionItem: |
| 310 (PaymentRequestViewController*)controller { | 288 (PaymentRequestViewController*)controller { |
| 311 _shippingOptionSelectionCoordinator.reset( | 289 _shippingOptionSelectionCoordinator = |
| 312 [[ShippingOptionSelectionCoordinator alloc] | 290 [[ShippingOptionSelectionCoordinator alloc] |
| 313 initWithBaseViewController:_viewController]); | 291 initWithBaseViewController:_viewController]; |
| 314 [_shippingOptionSelectionCoordinator setPaymentRequest:_paymentRequest]; | 292 [_shippingOptionSelectionCoordinator setPaymentRequest:_paymentRequest]; |
| 315 [_shippingOptionSelectionCoordinator setDelegate:self]; | 293 [_shippingOptionSelectionCoordinator setDelegate:self]; |
| 316 | 294 |
| 317 [_shippingOptionSelectionCoordinator start]; | 295 [_shippingOptionSelectionCoordinator start]; |
| 318 } | 296 } |
| 319 | 297 |
| 320 - (void)paymentRequestViewControllerDidSelectPaymentMethodItem: | 298 - (void)paymentRequestViewControllerDidSelectPaymentMethodItem: |
| 321 (PaymentRequestViewController*)controller { | 299 (PaymentRequestViewController*)controller { |
| 322 _methodSelectionCoordinator.reset([[PaymentMethodSelectionCoordinator alloc] | 300 _methodSelectionCoordinator = [[PaymentMethodSelectionCoordinator alloc] |
| 323 initWithBaseViewController:_viewController]); | 301 initWithBaseViewController:_viewController]; |
| 324 [_methodSelectionCoordinator setPaymentRequest:_paymentRequest]; | 302 [_methodSelectionCoordinator setPaymentRequest:_paymentRequest]; |
| 325 [_methodSelectionCoordinator setDelegate:self]; | 303 [_methodSelectionCoordinator setDelegate:self]; |
| 326 | 304 |
| 327 [_methodSelectionCoordinator start]; | 305 [_methodSelectionCoordinator start]; |
| 328 } | 306 } |
| 329 | 307 |
| 330 #pragma mark - PaymentItemsDisplayCoordinatorDelegate | 308 #pragma mark - PaymentItemsDisplayCoordinatorDelegate |
| 331 | 309 |
| 332 - (void)paymentItemsDisplayCoordinatorDidReturn: | 310 - (void)paymentItemsDisplayCoordinatorDidReturn: |
| 333 (PaymentItemsDisplayCoordinator*)coordinator { | 311 (PaymentItemsDisplayCoordinator*)coordinator { |
| 334 // Clear the 'Updated' label on the payment summary item, if there is one. | 312 // Clear the 'Updated' label on the payment summary item, if there is one. |
| 335 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; | 313 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; |
| 336 | 314 |
| 337 [_itemsDisplayCoordinator stop]; | 315 [_itemsDisplayCoordinator stop]; |
| 338 _itemsDisplayCoordinator.reset(); | 316 _itemsDisplayCoordinator = nil; |
| 339 } | 317 } |
| 340 | 318 |
| 341 - (void)paymentItemsDisplayCoordinatorDidConfirm: | 319 - (void)paymentItemsDisplayCoordinatorDidConfirm: |
| 342 (PaymentItemsDisplayCoordinator*)coordinator { | 320 (PaymentItemsDisplayCoordinator*)coordinator { |
| 343 [self sendPaymentResponse]; | 321 [self sendPaymentResponse]; |
| 344 } | 322 } |
| 345 | 323 |
| 346 #pragma mark - ShippingAddressSelectionCoordinatorDelegate | 324 #pragma mark - ShippingAddressSelectionCoordinatorDelegate |
| 347 | 325 |
| 348 - (void)shippingAddressSelectionCoordinator: | 326 - (void)shippingAddressSelectionCoordinator: |
| 349 (ShippingAddressSelectionCoordinator*)coordinator | 327 (ShippingAddressSelectionCoordinator*)coordinator |
| 350 didSelectShippingAddress: | 328 didSelectShippingAddress: |
| 351 (autofill::AutofillProfile*)shippingAddress { | 329 (autofill::AutofillProfile*)shippingAddress { |
| 352 _pendingShippingAddress = shippingAddress; | 330 _pendingShippingAddress = shippingAddress; |
| 353 | 331 |
| 354 web::PaymentAddress address = | 332 web::PaymentAddress address = |
| 355 payment_request_util::PaymentAddressFromAutofillProfile(shippingAddress); | 333 payment_request_util::PaymentAddressFromAutofillProfile(shippingAddress); |
| 356 [_delegate paymentRequestCoordinator:self didSelectShippingAddress:address]; | 334 [_delegate paymentRequestCoordinator:self didSelectShippingAddress:address]; |
| 357 } | 335 } |
| 358 | 336 |
| 359 - (void)shippingAddressSelectionCoordinatorDidReturn: | 337 - (void)shippingAddressSelectionCoordinatorDidReturn: |
| 360 (ShippingAddressSelectionCoordinator*)coordinator { | 338 (ShippingAddressSelectionCoordinator*)coordinator { |
| 361 // Clear the 'Updated' label on the payment summary item, if there is one. | 339 // Clear the 'Updated' label on the payment summary item, if there is one. |
| 362 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; | 340 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; |
| 363 | 341 |
| 364 [_shippingAddressSelectionCoordinator stop]; | 342 [_shippingAddressSelectionCoordinator stop]; |
| 365 _shippingAddressSelectionCoordinator.reset(); | 343 _shippingAddressSelectionCoordinator = nil; |
| 366 } | 344 } |
| 367 | 345 |
| 368 #pragma mark - ShippingOptionSelectionCoordinatorDelegate | 346 #pragma mark - ShippingOptionSelectionCoordinatorDelegate |
| 369 | 347 |
| 370 - (void)shippingOptionSelectionCoordinator: | 348 - (void)shippingOptionSelectionCoordinator: |
| 371 (ShippingOptionSelectionCoordinator*)coordinator | 349 (ShippingOptionSelectionCoordinator*)coordinator |
| 372 didSelectShippingOption: | 350 didSelectShippingOption: |
| 373 (web::PaymentShippingOption*)shippingOption { | 351 (web::PaymentShippingOption*)shippingOption { |
| 374 [_delegate paymentRequestCoordinator:self | 352 [_delegate paymentRequestCoordinator:self |
| 375 didSelectShippingOption:*shippingOption]; | 353 didSelectShippingOption:*shippingOption]; |
| 376 } | 354 } |
| 377 | 355 |
| 378 - (void)shippingOptionSelectionCoordinatorDidReturn: | 356 - (void)shippingOptionSelectionCoordinatorDidReturn: |
| 379 (ShippingAddressSelectionCoordinator*)coordinator { | 357 (ShippingAddressSelectionCoordinator*)coordinator { |
| 380 // Clear the 'Updated' label on the payment summary item, if there is one. | 358 // Clear the 'Updated' label on the payment summary item, if there is one. |
| 381 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; | 359 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; |
| 382 | 360 |
| 383 [_shippingOptionSelectionCoordinator stop]; | 361 [_shippingOptionSelectionCoordinator stop]; |
| 384 _shippingOptionSelectionCoordinator.reset(); | 362 _shippingOptionSelectionCoordinator = nil; |
| 385 } | 363 } |
| 386 | 364 |
| 387 #pragma mark - PaymentMethodSelectionCoordinatorDelegate | 365 #pragma mark - PaymentMethodSelectionCoordinatorDelegate |
| 388 | 366 |
| 389 - (void)paymentMethodSelectionCoordinator: | 367 - (void)paymentMethodSelectionCoordinator: |
| 390 (PaymentMethodSelectionCoordinator*)coordinator | 368 (PaymentMethodSelectionCoordinator*)coordinator |
| 391 didSelectPaymentMethod:(autofill::CreditCard*)creditCard { | 369 didSelectPaymentMethod:(autofill::CreditCard*)creditCard { |
| 392 _paymentRequest->set_selected_credit_card(creditCard); | 370 _paymentRequest->set_selected_credit_card(creditCard); |
| 393 | 371 |
| 394 [_viewController updateSelectedPaymentMethodUI]; | 372 [_viewController updateSelectedPaymentMethodUI]; |
| 395 | 373 |
| 396 // Clear the 'Updated' label on the payment summary item, if there is one. | 374 // Clear the 'Updated' label on the payment summary item, if there is one. |
| 397 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; | 375 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; |
| 398 | 376 |
| 399 [_methodSelectionCoordinator stop]; | 377 [_methodSelectionCoordinator stop]; |
| 400 _methodSelectionCoordinator.reset(); | 378 _methodSelectionCoordinator = nil; |
| 401 } | 379 } |
| 402 | 380 |
| 403 - (void)paymentMethodSelectionCoordinatorDidReturn: | 381 - (void)paymentMethodSelectionCoordinatorDidReturn: |
| 404 (PaymentMethodSelectionCoordinator*)coordinator { | 382 (PaymentMethodSelectionCoordinator*)coordinator { |
| 405 // Clear the 'Updated' label on the payment summary item, if there is one. | 383 // Clear the 'Updated' label on the payment summary item, if there is one. |
| 406 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; | 384 [_viewController updatePaymentSummaryWithTotalValueChanged:NO]; |
| 407 | 385 |
| 408 [_methodSelectionCoordinator stop]; | 386 [_methodSelectionCoordinator stop]; |
| 409 _methodSelectionCoordinator.reset(); | 387 _methodSelectionCoordinator = nil; |
| 410 } | 388 } |
| 411 | 389 |
| 412 @end | 390 @end |
| OLD | NEW |