| Index: components/payments/payment_request.cc
|
| diff --git a/components/payments/payment_request.cc b/components/payments/payment_request.cc
|
| index 98182c155672e0a96ae518de2a66c1702ffb3226..f78d83f0a8ae0e2038b8c027f9bda4c87c8d322b 100644
|
| --- a/components/payments/payment_request.cc
|
| +++ b/components/payments/payment_request.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "components/payments/payment_request.h"
|
|
|
| +#include "components/autofill/core/browser/personal_data_manager.h"
|
| #include "components/payments/payment_details_validation.h"
|
| #include "components/payments/payment_request_delegate.h"
|
| #include "components/payments/payment_request_web_contents_manager.h"
|
| @@ -61,4 +62,23 @@ void PaymentRequest::OnError() {
|
| manager_->DestroyRequest(this);
|
| }
|
|
|
| +autofill::CreditCard* PaymentRequest::GetCurrentlySelectedCreditCard() {
|
| + // TODO(anthonyvd): Change this code to prioritize server cards and implement
|
| + // a way to modify this function's return value.
|
| + autofill::PersonalDataManager* data_manager =
|
| + delegate_->GetDataManagerFromWebContents(web_contents());
|
| +
|
| + const std::vector<autofill::CreditCard*> cards =
|
| + data_manager->GetCreditCardsToSuggest();
|
| +
|
| + auto first_complete_card = std::find_if(
|
| + cards.begin(),
|
| + cards.end(),
|
| + [] (autofill::CreditCard* card) {
|
| + return card->IsValid();
|
| + });
|
| +
|
| + return first_complete_card == cards.end() ? nullptr : *first_complete_card;
|
| +}
|
| +
|
| } // namespace payments
|
|
|