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

Unified Diff: components/payments/payment_request.cc

Issue 2621153002: [WebPayments] Add the Payment Method section in the Payment Sheet (Closed)
Patch Set: Fix BUILD.gn deps. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/payments/payment_request.h ('k') | components/payments/payment_request_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « components/payments/payment_request.h ('k') | components/payments/payment_request_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698