Chromium Code Reviews| 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 client_.reset(); | |
|
Mathieu
2017/05/08 13:01:42
I'm curious why not OnConnectionTerminated here? I
please use gerrit instead
2017/05/08 13:12:35
Done.
| |
| 107 binding_.Close(); | |
| 108 manager_->DestroyRequest(this); | |
| 109 return; | |
| 110 } | |
| 111 | |
| 102 if (!state_->AreRequestedMethodsSupported()) { | 112 if (!state_->AreRequestedMethodsSupported()) { |
| 103 client_->OnError(mojom::PaymentErrorReason::NOT_SUPPORTED); | 113 client_->OnError(mojom::PaymentErrorReason::NOT_SUPPORTED); |
| 104 if (observer_for_testing_) | 114 if (observer_for_testing_) |
| 105 observer_for_testing_->OnNotSupportedError(); | 115 observer_for_testing_->OnNotSupportedError(); |
| 106 OnConnectionTerminated(); | 116 OnConnectionTerminated(); |
| 107 return; | 117 return; |
| 108 } | 118 } |
| 109 | 119 |
| 110 journey_logger_.SetShowCalled(); | 120 journey_logger_.SetShowCalled(); |
| 111 delegate_->ShowDialog(this); | 121 delegate_->ShowDialog(this); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 binding_.Close(); | 213 binding_.Close(); |
| 204 delegate_->CloseDialog(); | 214 delegate_->CloseDialog(); |
| 205 manager_->DestroyRequest(this); | 215 manager_->DestroyRequest(this); |
| 206 } | 216 } |
| 207 | 217 |
| 208 void PaymentRequest::Pay() { | 218 void PaymentRequest::Pay() { |
| 209 state_->GeneratePaymentResponse(); | 219 state_->GeneratePaymentResponse(); |
| 210 } | 220 } |
| 211 | 221 |
| 212 } // namespace payments | 222 } // namespace payments |
| OLD | NEW |