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

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentResponse.cpp

Issue 2491513002: [Payment] Clean up PaymentResponse::toJSONForBinding (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ExceptionStatePlaceholder.h" 7 #include "bindings/core/v8/ExceptionStatePlaceholder.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"
(...skipping 23 matching lines...) Expand all
34 V8ObjectBuilder result(scriptState); 34 V8ObjectBuilder result(scriptState);
35 result.addString("methodName", methodName()); 35 result.addString("methodName", methodName());
36 result.add("details", details(scriptState, ASSERT_NO_EXCEPTION)); 36 result.add("details", details(scriptState, ASSERT_NO_EXCEPTION));
37 37
38 if (shippingAddress()) 38 if (shippingAddress())
39 result.add("shippingAddress", 39 result.add("shippingAddress",
40 shippingAddress()->toJSONForBinding(scriptState)); 40 shippingAddress()->toJSONForBinding(scriptState));
41 else 41 else
42 result.addNull("shippingAddress"); 42 result.addNull("shippingAddress");
43 43
44 if (shippingOption().isNull()) 44 result.addStringOrNull("shippingOption", shippingOption())
45 result.addNull("shippingOption"); 45 .addStringOrNull("payerEmail", payerEmail())
46 else 46 .addStringOrNull("payerPhone", payerPhone());
please use gerrit instead 2016/11/09 18:55:17 You're missing payerName
47 result.addString("shippingOption", shippingOption());
48
49 if (payerEmail().isNull())
50 result.addNull("payerEmail");
51 else
52 result.addString("payerEmail", payerEmail());
53
54 if (payerPhone().isNull())
55 result.addNull("payerPhone");
56 else
57 result.addString("payerPhone", payerPhone());
58 47
59 return result.scriptValue(); 48 return result.scriptValue();
60 } 49 }
61 50
62 ScriptValue PaymentResponse::details(ScriptState* scriptState, 51 ScriptValue PaymentResponse::details(ScriptState* scriptState,
63 ExceptionState& exceptionState) const { 52 ExceptionState& exceptionState) const {
64 return ScriptValue( 53 return ScriptValue(
65 scriptState, fromJSONString(scriptState->isolate(), m_stringifiedDetails, 54 scriptState, fromJSONString(scriptState->isolate(), m_stringifiedDetails,
66 exceptionState)); 55 exceptionState));
67 } 56 }
68 57
69 ScriptPromise PaymentResponse::complete(ScriptState* scriptState, 58 ScriptPromise PaymentResponse::complete(ScriptState* scriptState,
70 const String& result) { 59 const String& result) {
71 PaymentCompleter::PaymentComplete convertedResult = PaymentCompleter::Unknown; 60 PaymentCompleter::PaymentComplete convertedResult = PaymentCompleter::Unknown;
72 if (result == "success") 61 if (result == "success")
73 convertedResult = PaymentCompleter::Success; 62 convertedResult = PaymentCompleter::Success;
74 else if (result == "fail") 63 else if (result == "fail")
75 convertedResult = PaymentCompleter::Fail; 64 convertedResult = PaymentCompleter::Fail;
76 return m_paymentCompleter->complete(scriptState, convertedResult); 65 return m_paymentCompleter->complete(scriptState, convertedResult);
77 } 66 }
78 67
79 DEFINE_TRACE(PaymentResponse) { 68 DEFINE_TRACE(PaymentResponse) {
80 visitor->trace(m_shippingAddress); 69 visitor->trace(m_shippingAddress);
81 visitor->trace(m_paymentCompleter); 70 visitor->trace(m_paymentCompleter);
82 } 71 }
83 72
84 } // namespace blink 73 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698