| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 void PaymentRequest::Abort() { | 69 void PaymentRequest::Abort() { |
| 70 // The API user has decided to abort. We return a successful abort message to | 70 // The API user has decided to abort. We return a successful abort message to |
| 71 // the renderer, which closes the Mojo message pipe, which triggers | 71 // the renderer, which closes the Mojo message pipe, which triggers |
| 72 // PaymentRequest::OnConnectionTerminated, which destroys this object. | 72 // PaymentRequest::OnConnectionTerminated, which destroys this object. |
| 73 if (client_.is_bound()) | 73 if (client_.is_bound()) |
| 74 client_->OnAbort(true /* aborted_successfully */); | 74 client_->OnAbort(true /* aborted_successfully */); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void PaymentRequest::Complete(payments::mojom::PaymentComplete result) { | 77 void PaymentRequest::Complete(mojom::PaymentComplete result) { |
| 78 if (!client_.is_bound()) | 78 if (!client_.is_bound()) |
| 79 return; | 79 return; |
| 80 | 80 |
| 81 // TODO(mathp): Validate |result|. | 81 if (result != mojom::PaymentComplete::SUCCESS) { |
| 82 | 82 delegate_->ShowErrorMessage(); |
| 83 // When the renderer closes the connection, | 83 } else { |
| 84 // PaymentRequest::OnConnectionTerminated will be called. | 84 // When the renderer closes the connection, |
| 85 client_->OnComplete(); | 85 // PaymentRequest::OnConnectionTerminated will be called. |
| 86 client_->OnComplete(); |
| 87 } |
| 86 } | 88 } |
| 87 | 89 |
| 88 void PaymentRequest::CanMakePayment() { | 90 void PaymentRequest::CanMakePayment() { |
| 89 // TODO(crbug.com/704676): Implement a quota policy for this method. | 91 // TODO(crbug.com/704676): Implement a quota policy for this method. |
| 90 // PaymentRequest.canMakePayments() never returns false in incognito mode. | 92 // PaymentRequest.canMakePayments() never returns false in incognito mode. |
| 91 client_->OnCanMakePayment( | 93 client_->OnCanMakePayment( |
| 92 delegate_->IsIncognito() || state()->CanMakePayment() | 94 delegate_->IsIncognito() || state()->CanMakePayment() |
| 93 ? mojom::CanMakePaymentQueryResult::CAN_MAKE_PAYMENT | 95 ? mojom::CanMakePaymentQueryResult::CAN_MAKE_PAYMENT |
| 94 : mojom::CanMakePaymentQueryResult::CANNOT_MAKE_PAYMENT); | 96 : mojom::CanMakePaymentQueryResult::CANNOT_MAKE_PAYMENT); |
| 95 if (observer_for_testing_) | 97 if (observer_for_testing_) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 binding_.Close(); | 132 binding_.Close(); |
| 131 delegate_->CloseDialog(); | 133 delegate_->CloseDialog(); |
| 132 manager_->DestroyRequest(this); | 134 manager_->DestroyRequest(this); |
| 133 } | 135 } |
| 134 | 136 |
| 135 void PaymentRequest::Pay() { | 137 void PaymentRequest::Pay() { |
| 136 state_->GeneratePaymentResponse(); | 138 state_->GeneratePaymentResponse(); |
| 137 } | 139 } |
| 138 | 140 |
| 139 } // namespace payments | 141 } // namespace payments |
| OLD | NEW |