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: chrome/browser/payments/payment_request_impl.cc

Issue 2592833002: [WebPayments] Start populating the Payment Sheet. (Closed)
Patch Set: Address comments 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 "chrome/browser/payments/payment_request_impl.h" 5 #include "chrome/browser/payments/payment_request_impl.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "chrome/browser/ui/browser_dialogs.h" 10 #include "chrome/browser/ui/browser_dialogs.h"
11 #include "components/payments/payment_details_validation.h"
11 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
13 14
14 namespace { 15 namespace {
15 16
16 class PaymentRequestFactory { 17 class PaymentRequestFactory {
17 public: 18 public:
18 bool AssignPaymentRequest( 19 bool AssignPaymentRequest(
19 content::WebContents* web_contents, 20 content::WebContents* web_contents,
20 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request) { 21 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 55 }
55 56
56 PaymentRequestImpl::~PaymentRequestImpl() {} 57 PaymentRequestImpl::~PaymentRequestImpl() {}
57 58
58 void PaymentRequestImpl::Init( 59 void PaymentRequestImpl::Init(
59 payments::mojom::PaymentRequestClientPtr client, 60 payments::mojom::PaymentRequestClientPtr client,
60 std::vector<payments::mojom::PaymentMethodDataPtr> methodData, 61 std::vector<payments::mojom::PaymentMethodDataPtr> methodData,
61 payments::mojom::PaymentDetailsPtr details, 62 payments::mojom::PaymentDetailsPtr details,
62 payments::mojom::PaymentOptionsPtr options) { 63 payments::mojom::PaymentOptionsPtr options) {
63 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 64 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
65 std::string error;
66 if (!payments::validatePaymentDetails(details, &error)) {
please use gerrit instead 2017/01/04 19:17:11 LOG(ERROR) << error;
anthonyvd 2017/01/05 16:45:42 Done.
67 OnError();
68 return;
69 }
64 client_ = std::move(client); 70 client_ = std::move(client);
71 details_ = std::move(details);
65 } 72 }
66 73
67 void PaymentRequestImpl::Show() { 74 void PaymentRequestImpl::Show() {
68 chrome::ShowPaymentRequestDialog(this); 75 chrome::ShowPaymentRequestDialog(this);
69 } 76 }
70 77
71 void PaymentRequestImpl::Cancel() { 78 void PaymentRequestImpl::Cancel() {
72 client_->OnError(payments::mojom::PaymentErrorReason::USER_CANCEL); 79 client_->OnError(payments::mojom::PaymentErrorReason::USER_CANCEL);
73 } 80 }
74 81
75 void PaymentRequestImpl::OnError() { 82 void PaymentRequestImpl::OnError() {
76 binding_.Close(); 83 binding_.Close();
77 // TODO(krb): Close the dialog here, but avoid double-free 84 // TODO(krb): Close the dialog here, but avoid double-free
78 payment_request_factory.Get().UnassignPaymentRequest(web_contents_); 85 payment_request_factory.Get().UnassignPaymentRequest(web_contents_);
79 } 86 }
80 87
81 } // namespace payments 88 } // namespace payments
82 89
83 void CreatePaymentRequestHandler( 90 void CreatePaymentRequestHandler(
84 content::WebContents* web_contents, 91 content::WebContents* web_contents,
85 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request) { 92 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request) {
86 payment_request_factory.Get().AssignPaymentRequest(web_contents, 93 payment_request_factory.Get().AssignPaymentRequest(web_contents,
87 std::move(request)); 94 std::move(request));
88 } 95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698