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

Unified Diff: components/payments/payment_request.cc

Issue 2695653004: [Web Payments] Add a mechanism to build item lists in the PR dialog. (Closed)
Patch Set: Created 3 years, 10 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
Index: components/payments/payment_request.cc
diff --git a/components/payments/payment_request.cc b/components/payments/payment_request.cc
index d7302df59c70c7fcda437a4df50d89570d0d376a..8a47f65de8a33cf3ed9416e455814f462650b1b4 100644
--- a/components/payments/payment_request.cc
+++ b/components/payments/payment_request.cc
@@ -120,23 +120,11 @@ const std::vector<autofill::AutofillProfile*>&
return contact_profiles_;
}
-autofill::CreditCard* PaymentRequest::GetCurrentlySelectedCreditCard() {
- // TODO(anthonyvd): Change this code to prioritize server cards and implement
- // a way to modify this function's return value.
+const std::vector<autofill::CreditCard*> PaymentRequest::credit_cards() {
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;
+ return data_manager->GetCreditCardsToSuggest();
please use gerrit instead 2017/02/14 00:29:14 These cards are owned by data_manager and can chan
anthonyvd 2017/02/22 20:15:21 Ahh, didn't know that! Done. I imagine we'll need
}
void PaymentRequest::PopulateProfileCache() {
@@ -165,6 +153,19 @@ void PaymentRequest::SetDefaultProfileSelections() {
if (!contact_profiles().empty())
set_selected_contact_profile(contact_profiles()[0]);
+
+ // TODO(anthonyvd): Change this code to prioritize server cards and implement
+ // a way to modify this function's return value.
+ const std::vector<autofill::CreditCard*> cards = credit_cards();
+ auto first_complete_card = std::find_if(
+ cards.begin(),
+ cards.end(),
+ [] (autofill::CreditCard* card) {
+ return card->IsValid();
+ });
+
+ selected_credit_card_ =
+ first_complete_card == cards.end() ?nullptr : *first_complete_card;
please use gerrit instead 2017/02/14 00:29:14 need space after "?"
anthonyvd 2017/02/22 20:15:21 Done.
}
} // namespace payments
« components/payments/payment_request.h ('K') | « components/payments/payment_request.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698