Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(907)

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentResponse.cpp

Issue 2349133002: PaymentRequest: Make the PaymentResponse interface serializable. (Closed)
Patch Set: PaymentRequest: Make the PaymentResponse interface serializable. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 bf3d7662f2e52a463842400554baf2365e5a8418..b2e9b574223c4016e602b3b5ced2536aad1e0936 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"
@@ -27,6 +29,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");
+
+ 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));

Powered by Google App Engine
This is Rietveld 408576698