| OLD | NEW |
| 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/payments/payment_details_validation.h" | 7 #include "components/payments/payment_details_validation.h" |
| 8 #include "components/payments/payment_request_delegate.h" | 8 #include "components/payments/payment_request_delegate.h" |
| 9 #include "components/payments/payment_request_web_contents_manager.h" | 9 #include "components/payments/payment_request_web_contents_manager.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 void PaymentRequest::Init( | 30 void PaymentRequest::Init( |
| 31 payments::mojom::PaymentRequestClientPtr client, | 31 payments::mojom::PaymentRequestClientPtr client, |
| 32 std::vector<payments::mojom::PaymentMethodDataPtr> methodData, | 32 std::vector<payments::mojom::PaymentMethodDataPtr> methodData, |
| 33 payments::mojom::PaymentDetailsPtr details, | 33 payments::mojom::PaymentDetailsPtr details, |
| 34 payments::mojom::PaymentOptionsPtr options) { | 34 payments::mojom::PaymentOptionsPtr options) { |
| 35 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 35 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 36 std::string error; | 36 std::string error; |
| 37 if (!payments::validatePaymentDetails(details, &error)) { | 37 if (!payments::validatePaymentDetails(details, &error)) { |
| 38 LOG(ERROR) << error; | 38 LOG(ERROR) << error; |
| 39 OnError(); | 39 OnError(); |
| 40 client_.reset(); |
| 40 return; | 41 return; |
| 41 } | 42 } |
| 42 client_ = std::move(client); | 43 client_ = std::move(client); |
| 43 details_ = std::move(details); | 44 details_ = std::move(details); |
| 44 } | 45 } |
| 45 | 46 |
| 46 void PaymentRequest::Show() { | 47 void PaymentRequest::Show() { |
| 48 if (!client_.is_bound() || !binding_.is_bound()) { |
| 49 OnError(); |
| 50 return; |
| 51 } |
| 47 delegate_->ShowPaymentRequestDialog(this); | 52 delegate_->ShowPaymentRequestDialog(this); |
| 48 } | 53 } |
| 49 | 54 |
| 50 void PaymentRequest::Cancel() { | 55 void PaymentRequest::Cancel() { |
| 51 client_->OnError(payments::mojom::PaymentErrorReason::USER_CANCEL); | 56 client_->OnError(payments::mojom::PaymentErrorReason::USER_CANCEL); |
| 52 } | 57 } |
| 53 | 58 |
| 54 void PaymentRequest::OnError() { | 59 void PaymentRequest::OnError() { |
| 55 binding_.Close(); | 60 binding_.Close(); |
| 56 manager_->DestroyRequest(this); | 61 manager_->DestroyRequest(this); |
| 57 } | 62 } |
| 58 | 63 |
| 59 } // namespace payments | 64 } // namespace payments |
| OLD | NEW |