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

Side by Side Diff: components/payments/payment_request.cc

Issue 2621153002: [WebPayments] Add the Payment Method section in the Payment Sheet (Closed)
Patch Set: Initial patch 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 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 #include "components/payments/payment_request.h" 5 #include "components/payments/payment_request.h"
6 6
7 #include "components/autofill/core/browser/personal_data_manager.h"
7 #include "components/payments/payment_details_validation.h" 8 #include "components/payments/payment_details_validation.h"
8 #include "components/payments/payment_request_delegate.h" 9 #include "components/payments/payment_request_delegate.h"
9 #include "components/payments/payment_request_web_contents_manager.h" 10 #include "components/payments/payment_request_web_contents_manager.h"
10 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
12 13
13 namespace payments { 14 namespace payments {
14 15
15 PaymentRequest::PaymentRequest( 16 PaymentRequest::PaymentRequest(
16 content::WebContents* web_contents, 17 content::WebContents* web_contents,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 55
55 void PaymentRequest::Cancel() { 56 void PaymentRequest::Cancel() {
56 client_->OnError(payments::mojom::PaymentErrorReason::USER_CANCEL); 57 client_->OnError(payments::mojom::PaymentErrorReason::USER_CANCEL);
57 } 58 }
58 59
59 void PaymentRequest::OnError() { 60 void PaymentRequest::OnError() {
60 binding_.Close(); 61 binding_.Close();
61 manager_->DestroyRequest(this); 62 manager_->DestroyRequest(this);
62 } 63 }
63 64
65 autofill::CreditCard* PaymentRequest::GetCurrentlySelectedCreditCard() {
66 // TODO(anthonyvd): Change this code to prioritize server cards and implement
67 // a way to modify this function's return value.
68 autofill::PersonalDataManager* data_manager =
69 delegate_->GetDataManagerFromWebContents(web_contents());
70
71 const std::vector<autofill::CreditCard*> cards =
72 data_manager->GetCreditCardsToSuggest();
73
74 auto first_complete_card = std::find_if(
75 cards.begin(),
76 cards.end(),
77 [] (autofill::CreditCard* card) {
78 return card->IsValid();
79 });
80
81 return first_complete_card == cards.end() ? nullptr : *first_complete_card;
82 }
83
64 } // namespace payments 84 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698