| 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 <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 delegate_->GetPersonalDataManager(), delegate_.get()); | 92 delegate_->GetPersonalDataManager(), delegate_.get()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void PaymentRequest::Show() { | 95 void PaymentRequest::Show() { |
| 96 if (!client_.is_bound() || !binding_.is_bound()) { | 96 if (!client_.is_bound() || !binding_.is_bound()) { |
| 97 LOG(ERROR) << "Attempted Show(), but binding(s) missing."; | 97 LOG(ERROR) << "Attempted Show(), but binding(s) missing."; |
| 98 OnConnectionTerminated(); | 98 OnConnectionTerminated(); |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 | 101 |
| 102 // A tab can display only one PaymentRequest UI at a time. |
| 103 if (!manager_->CanShow(this)) { |
| 104 LOG(ERROR) << "A PaymentRequest UI is already showing"; |
| 105 client_->OnError(mojom::PaymentErrorReason::USER_CANCEL); |
| 106 OnConnectionTerminated(); |
| 107 return; |
| 108 } |
| 109 |
| 102 if (!state_->AreRequestedMethodsSupported()) { | 110 if (!state_->AreRequestedMethodsSupported()) { |
| 103 client_->OnError(mojom::PaymentErrorReason::NOT_SUPPORTED); | 111 client_->OnError(mojom::PaymentErrorReason::NOT_SUPPORTED); |
| 104 if (observer_for_testing_) | 112 if (observer_for_testing_) |
| 105 observer_for_testing_->OnNotSupportedError(); | 113 observer_for_testing_->OnNotSupportedError(); |
| 106 OnConnectionTerminated(); | 114 OnConnectionTerminated(); |
| 107 return; | 115 return; |
| 108 } | 116 } |
| 109 | 117 |
| 110 journey_logger_.SetShowCalled(); | 118 journey_logger_.SetShowCalled(); |
| 111 delegate_->ShowDialog(this); | 119 delegate_->ShowDialog(this); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 binding_.Close(); | 211 binding_.Close(); |
| 204 delegate_->CloseDialog(); | 212 delegate_->CloseDialog(); |
| 205 manager_->DestroyRequest(this); | 213 manager_->DestroyRequest(this); |
| 206 } | 214 } |
| 207 | 215 |
| 208 void PaymentRequest::Pay() { | 216 void PaymentRequest::Pay() { |
| 209 state_->GeneratePaymentResponse(); | 217 state_->GeneratePaymentResponse(); |
| 210 } | 218 } |
| 211 | 219 |
| 212 } // namespace payments | 220 } // namespace payments |
| OLD | NEW |