| Index: components/payments/payment_request.cc
|
| diff --git a/components/payments/payment_request.cc b/components/payments/payment_request.cc
|
| index 1a426c8edf4ddfd3a8a2698727799857b54f3590..06ec2b4f46562699b0baa795d00e07d512754bd2 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"
|
| @@ -73,4 +74,23 @@ CurrencyFormatter* PaymentRequest::GetOrCreateCurrencyFormatter(
|
| return currency_formatter_.get();
|
| }
|
|
|
| +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_->GetPersonalDataManager();
|
| +
|
| + 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
|
|
|