Chromium Code Reviews| Index: third_party/WebKit/Source/modules/payments/PaymentResponse.cpp |
| diff --git a/third_party/WebKit/Source/modules/payments/PaymentResponse.cpp b/third_party/WebKit/Source/modules/payments/PaymentResponse.cpp |
| index 42c46f176abac29c747697633e90ee1e22173564..691fe8ba1362a486c02c24691be62837a0544ce0 100644 |
| --- a/third_party/WebKit/Source/modules/payments/PaymentResponse.cpp |
| +++ b/third_party/WebKit/Source/modules/payments/PaymentResponse.cpp |
| @@ -4,7 +4,9 @@ |
| #include "modules/payments/PaymentResponse.h" |
| +#include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| #include "bindings/core/v8/JSONValuesForV8.h" |
| +#include "bindings/core/v8/V8ObjectBuilder.h" |
| #include "modules/payments/PaymentAddress.h" |
| #include "modules/payments/PaymentCompleter.h" |
| #include "wtf/Assertions.h" |
| @@ -28,6 +30,35 @@ PaymentResponse::~PaymentResponse() |
| { |
| } |
| +ScriptValue PaymentResponse::toJSONForBinding(ScriptState* scriptState) const |
| +{ |
| + V8ObjectBuilder result(scriptState); |
| + result.addString("methodName", methodName()); |
| + result.add("details", details(scriptState, ASSERT_NO_EXCEPTION)); |
| + |
| + if (shippingAddress()) |
| + result.add("shippingAddress", shippingAddress()->toJSONForBinding(scriptState)); |
| + else |
| + result.addNull("shippingAddress"); |
|
please use gerrit instead
2016/09/20 08:15:46
Do we need to add null shippingAddress, shippingOp
zino
2016/09/20 16:55:43
I'm not sure but we can not omit them even if the
|
| + |
| + if (shippingOption().isNull()) |
| + result.addNull("shippingOption"); |
| + else |
| + result.addString("shippingOption", shippingOption()); |
| + |
| + if (payerEmail().isNull()) |
| + result.addNull("payerEmail"); |
| + else |
| + result.addString("payerEmail", payerEmail()); |
| + |
| + if (payerPhone().isNull()) |
| + result.addNull("payerPhone"); |
| + else |
| + result.addString("payerPhone", payerPhone()); |
| + |
| + return result.scriptValue(); |
| +} |
| + |
| ScriptValue PaymentResponse::details(ScriptState* scriptState, ExceptionState& exceptionState) const |
| { |
| return ScriptValue(scriptState, fromJSONString(scriptState, m_stringifiedDetails, exceptionState)); |