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 "modules/payments/PaymentResponse.h" | 5 #include "modules/payments/PaymentResponse.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/V8ObjectBuilder.h" | 8 #include "bindings/core/v8/V8ObjectBuilder.h" |
| 9 #include "modules/payments/PaymentAddress.h" | 9 #include "modules/payments/PaymentAddress.h" |
| 10 #include "modules/payments/PaymentCompleter.h" | 10 #include "modules/payments/PaymentCompleter.h" |
| 11 #include "wtf/Assertions.h" | 11 #include "wtf/Assertions.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 PaymentResponse::PaymentResponse( | 15 PaymentResponse::PaymentResponse( |
| 16 payments::mojom::blink::PaymentResponsePtr response, | 16 payments::mojom::blink::PaymentResponsePtr response, |
| 17 PaymentCompleter* paymentCompleter) | 17 PaymentCompleter* paymentCompleter) |
| 18 : m_methodName(response->method_name), | 18 : m_requestId(response->requestId), |
|
please use gerrit instead
2017/03/27 16:22:36
Use the "id" from the PaymentRequest in the render
rwlbuis
2017/03/27 20:45:29
Done.
| |
| 19 m_methodName(response->method_name), | |
| 19 m_stringifiedDetails(response->stringified_details), | 20 m_stringifiedDetails(response->stringified_details), |
| 20 m_shippingAddress( | 21 m_shippingAddress( |
| 21 response->shipping_address | 22 response->shipping_address |
| 22 ? new PaymentAddress(std::move(response->shipping_address)) | 23 ? new PaymentAddress(std::move(response->shipping_address)) |
| 23 : nullptr), | 24 : nullptr), |
| 24 m_shippingOption(response->shipping_option), | 25 m_shippingOption(response->shipping_option), |
| 25 m_payerName(response->payer_name), | 26 m_payerName(response->payer_name), |
| 26 m_payerEmail(response->payer_email), | 27 m_payerEmail(response->payer_email), |
| 27 m_payerPhone(response->payer_phone), | 28 m_payerPhone(response->payer_phone), |
| 28 m_paymentCompleter(paymentCompleter) { | 29 m_paymentCompleter(paymentCompleter) { |
| 29 DCHECK(m_paymentCompleter); | 30 DCHECK(m_paymentCompleter); |
| 30 } | 31 } |
| 31 | 32 |
| 32 PaymentResponse::~PaymentResponse() {} | 33 PaymentResponse::~PaymentResponse() {} |
| 33 | 34 |
| 34 ScriptValue PaymentResponse::toJSONForBinding(ScriptState* scriptState) const { | 35 ScriptValue PaymentResponse::toJSONForBinding(ScriptState* scriptState) const { |
| 35 V8ObjectBuilder result(scriptState); | 36 V8ObjectBuilder result(scriptState); |
| 37 result.addString("requestId", requestId()); | |
| 36 result.addString("methodName", methodName()); | 38 result.addString("methodName", methodName()); |
| 37 result.add("details", details(scriptState, ASSERT_NO_EXCEPTION)); | 39 result.add("details", details(scriptState, ASSERT_NO_EXCEPTION)); |
| 38 | 40 |
| 39 if (shippingAddress()) | 41 if (shippingAddress()) |
| 40 result.add("shippingAddress", | 42 result.add("shippingAddress", |
| 41 shippingAddress()->toJSONForBinding(scriptState)); | 43 shippingAddress()->toJSONForBinding(scriptState)); |
| 42 else | 44 else |
| 43 result.addNull("shippingAddress"); | 45 result.addNull("shippingAddress"); |
| 44 | 46 |
| 45 result.addStringOrNull("shippingOption", shippingOption()) | 47 result.addStringOrNull("shippingOption", shippingOption()) |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 66 convertedResult = PaymentCompleter::Fail; | 68 convertedResult = PaymentCompleter::Fail; |
| 67 return m_paymentCompleter->complete(scriptState, convertedResult); | 69 return m_paymentCompleter->complete(scriptState, convertedResult); |
| 68 } | 70 } |
| 69 | 71 |
| 70 DEFINE_TRACE(PaymentResponse) { | 72 DEFINE_TRACE(PaymentResponse) { |
| 71 visitor->trace(m_shippingAddress); | 73 visitor->trace(m_shippingAddress); |
| 72 visitor->trace(m_paymentCompleter); | 74 visitor->trace(m_paymentCompleter); |
| 73 } | 75 } |
| 74 | 76 |
| 75 } // namespace blink | 77 } // namespace blink |
| OLD | NEW |