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/content/payment_request.h" | 5 #include "components/payments/content/payment_request.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "components/payments/content/payment_details_validation.h" | 10 #include "components/payments/content/payment_details_validation.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 std::vector<payments::mojom::PaymentMethodDataPtr> method_data, | 39 std::vector<payments::mojom::PaymentMethodDataPtr> method_data, |
40 payments::mojom::PaymentDetailsPtr details, | 40 payments::mojom::PaymentDetailsPtr details, |
41 payments::mojom::PaymentOptionsPtr options) { | 41 payments::mojom::PaymentOptionsPtr options) { |
42 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 42 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
43 std::string error; | 43 std::string error; |
44 if (!payments::validatePaymentDetails(details, &error)) { | 44 if (!payments::validatePaymentDetails(details, &error)) { |
45 LOG(ERROR) << error; | 45 LOG(ERROR) << error; |
46 OnConnectionTerminated(); | 46 OnConnectionTerminated(); |
47 return; | 47 return; |
48 } | 48 } |
49 if (!details->total) { | |
50 LOG(ERROR) << "Missing total"; | |
51 OnConnectionTerminated(); | |
52 return; | |
53 } | |
54 client_ = std::move(client); | 49 client_ = std::move(client); |
55 spec_ = base::MakeUnique<PaymentRequestSpec>( | 50 spec_ = base::MakeUnique<PaymentRequestSpec>( |
56 std::move(options), std::move(details), std::move(method_data), this, | 51 std::move(options), std::move(details), std::move(method_data), this, |
57 delegate_->GetApplicationLocale()); | 52 delegate_->GetApplicationLocale()); |
58 state_ = base::MakeUnique<PaymentRequestState>( | 53 state_ = base::MakeUnique<PaymentRequestState>( |
59 spec_.get(), this, delegate_->GetApplicationLocale(), | 54 spec_.get(), this, delegate_->GetApplicationLocale(), |
60 delegate_->GetPersonalDataManager()); | 55 delegate_->GetPersonalDataManager()); |
61 } | 56 } |
62 | 57 |
63 void PaymentRequest::Show() { | 58 void PaymentRequest::Show() { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 binding_.Close(); | 126 binding_.Close(); |
132 delegate_->CloseDialog(); | 127 delegate_->CloseDialog(); |
133 manager_->DestroyRequest(this); | 128 manager_->DestroyRequest(this); |
134 } | 129 } |
135 | 130 |
136 void PaymentRequest::Pay() { | 131 void PaymentRequest::Pay() { |
137 state_->GeneratePaymentResponse(); | 132 state_->GeneratePaymentResponse(); |
138 } | 133 } |
139 | 134 |
140 } // namespace payments | 135 } // namespace payments |
OLD | NEW |