| 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/ExceptionStatePlaceholder.h" | 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 8 #include "bindings/core/v8/JSONValuesForV8.h" | |
| 9 #include "bindings/core/v8/V8ObjectBuilder.h" | 8 #include "bindings/core/v8/V8ObjectBuilder.h" |
| 10 #include "modules/payments/PaymentAddress.h" | 9 #include "modules/payments/PaymentAddress.h" |
| 11 #include "modules/payments/PaymentCompleter.h" | 10 #include "modules/payments/PaymentCompleter.h" |
| 12 #include "wtf/Assertions.h" | 11 #include "wtf/Assertions.h" |
| 13 | 12 |
| 14 namespace blink { | 13 namespace blink { |
| 15 | 14 |
| 16 PaymentResponse::PaymentResponse(mojom::blink::PaymentResponsePtr response, | 15 PaymentResponse::PaymentResponse(mojom::blink::PaymentResponsePtr response, |
| 17 PaymentCompleter* paymentCompleter) | 16 PaymentCompleter* paymentCompleter) |
| 18 : m_methodName(response->method_name), | 17 : m_methodName(response->method_name), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 result.addNull("payerPhone"); | 55 result.addNull("payerPhone"); |
| 57 else | 56 else |
| 58 result.addString("payerPhone", payerPhone()); | 57 result.addString("payerPhone", payerPhone()); |
| 59 | 58 |
| 60 return result.scriptValue(); | 59 return result.scriptValue(); |
| 61 } | 60 } |
| 62 | 61 |
| 63 ScriptValue PaymentResponse::details(ScriptState* scriptState, | 62 ScriptValue PaymentResponse::details(ScriptState* scriptState, |
| 64 ExceptionState& exceptionState) const { | 63 ExceptionState& exceptionState) const { |
| 65 return ScriptValue( | 64 return ScriptValue( |
| 66 scriptState, | 65 scriptState, fromJSONString(scriptState->isolate(), m_stringifiedDetails, |
| 67 fromJSONString(scriptState, m_stringifiedDetails, exceptionState)); | 66 exceptionState)); |
| 68 } | 67 } |
| 69 | 68 |
| 70 ScriptPromise PaymentResponse::complete(ScriptState* scriptState, | 69 ScriptPromise PaymentResponse::complete(ScriptState* scriptState, |
| 71 const String& result) { | 70 const String& result) { |
| 72 PaymentCompleter::PaymentComplete convertedResult = PaymentCompleter::Unknown; | 71 PaymentCompleter::PaymentComplete convertedResult = PaymentCompleter::Unknown; |
| 73 if (result == "success") | 72 if (result == "success") |
| 74 convertedResult = PaymentCompleter::Success; | 73 convertedResult = PaymentCompleter::Success; |
| 75 else if (result == "fail") | 74 else if (result == "fail") |
| 76 convertedResult = PaymentCompleter::Fail; | 75 convertedResult = PaymentCompleter::Fail; |
| 77 return m_paymentCompleter->complete(scriptState, convertedResult); | 76 return m_paymentCompleter->complete(scriptState, convertedResult); |
| 78 } | 77 } |
| 79 | 78 |
| 80 DEFINE_TRACE(PaymentResponse) { | 79 DEFINE_TRACE(PaymentResponse) { |
| 81 visitor->trace(m_shippingAddress); | 80 visitor->trace(m_shippingAddress); |
| 82 visitor->trace(m_paymentCompleter); | 81 visitor->trace(m_paymentCompleter); |
| 83 } | 82 } |
| 84 | 83 |
| 85 } // namespace blink | 84 } // namespace blink |
| OLD | NEW |