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

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

Issue 2956453003: [Payment Request] Makes sure only complete credit cards can be selected (Closed)
Patch Set: Fixed unit test Created 3 years, 5 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_manager.h" 5 #import "ios/chrome/browser/ui/payments/payment_request_manager.h"
6 6
7 #include "base/ios/block_types.h" 7 #include "base/ios/block_types.h"
8 #include "base/ios/ios_util.h" 8 #include "base/ios/ios_util.h"
9 #import "base/mac/bind_objc_block.h" 9 #import "base/mac/bind_objc_block.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 653
654 [self terminateRequestWithErrorMessage:kCancelMessage callback:callback]; 654 [self terminateRequestWithErrorMessage:kCancelMessage callback:callback];
655 } 655 }
656 656
657 - (void)paymentRequestCoordinator:(PaymentRequestCoordinator*)coordinator 657 - (void)paymentRequestCoordinator:(PaymentRequestCoordinator*)coordinator
658 didCompletePaymentRequestWithCard:(const autofill::CreditCard&)card 658 didCompletePaymentRequestWithCard:(const autofill::CreditCard&)card
659 verificationCode:(const base::string16&)verificationCode { 659 verificationCode:(const base::string16&)verificationCode {
660 _pendingPaymentResponse.creditCard = card; 660 _pendingPaymentResponse.creditCard = card;
661 _pendingPaymentResponse.verificationCode = verificationCode; 661 _pendingPaymentResponse.verificationCode = verificationCode;
662 662
663 // TODO(crbug.com/714768): Make sure the billing address is set and valid 663 DCHECK(!card.billing_address_id().empty());
664 // before getting here. Once the bug is addressed, there will be no need to 664 autofill::AutofillProfile* billingAddress =
665 // copy the address, *billing_address_ptr can be used to get the basic card 665 autofill::PersonalDataManager::GetProfileFromProfilesByGUID(
666 // response. 666 card.billing_address_id(), _paymentRequest->billing_profiles());
667 if (!card.billing_address_id().empty()) { 667 DCHECK(billingAddress);
668 autofill::AutofillProfile* billingAddressPtr = 668 _pendingPaymentResponse.billingAddress = *billingAddress;
669 autofill::PersonalDataManager::GetProfileFromProfilesByGUID( 669 _addressNormalizationManager->StartNormalizingAddress(
670 card.billing_address_id(), _paymentRequest->billing_profiles()); 670 &_pendingPaymentResponse.billingAddress);
671 if (billingAddressPtr) {
672 _pendingPaymentResponse.billingAddress = *billingAddressPtr;
673 _addressNormalizationManager->StartNormalizingAddress(
674 &_pendingPaymentResponse.billingAddress);
675 }
676 }
677 671
678 if (_paymentRequest->request_shipping()) { 672 if (_paymentRequest->request_shipping()) {
679 // TODO(crbug.com/602666): User should get here only if they have selected 673 // TODO(crbug.com/602666): User should get here only if they have selected
680 // a shipping address. 674 // a shipping address.
681 DCHECK(_paymentRequest->selected_shipping_profile()); 675 DCHECK(_paymentRequest->selected_shipping_profile());
682 _pendingPaymentResponse.shippingAddress = 676 _pendingPaymentResponse.shippingAddress =
683 *_paymentRequest->selected_shipping_profile(); 677 *_paymentRequest->selected_shipping_profile();
684 _addressNormalizationManager->StartNormalizingAddress( 678 _addressNormalizationManager->StartNormalizingAddress(
685 &_pendingPaymentResponse.shippingAddress); 679 &_pendingPaymentResponse.shippingAddress);
686 } 680 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 #pragma mark - CRWWebStateObserver methods 776 #pragma mark - CRWWebStateObserver methods
783 777
784 - (void)webState:(web::WebState*)webState 778 - (void)webState:(web::WebState*)webState
785 didCommitNavigationWithDetails: 779 didCommitNavigationWithDetails:
786 (const web::LoadCommittedDetails&)load_details { 780 (const web::LoadCommittedDetails&)load_details {
787 [self dismissUI]; 781 [self dismissUI];
788 [self enableCurrentWebState]; 782 [self enableCurrentWebState];
789 } 783 }
790 784
791 @end 785 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698