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

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

Issue 2062583002: Add totalAmount to PaymentResponse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase #2 Created 4 years, 6 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 unified diff | Download patch
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/JSONValuesForV8.h" 7 #include "bindings/core/v8/JSONValuesForV8.h"
8 #include "modules/payments/PaymentAddress.h" 8 #include "modules/payments/PaymentAddress.h"
9 #include "modules/payments/PaymentCompleter.h" 9 #include "modules/payments/PaymentCompleter.h"
10 #include "wtf/Assertions.h" 10 #include "wtf/Assertions.h"
11 11
12 namespace mojo {
13
14 template <>
15 struct TypeConverter<blink::CurrencyAmount, blink::mojom::blink::CurrencyAmount> {
16 static blink::CurrencyAmount Convert(const blink::mojom::blink::CurrencyAmou nt& input)
17 {
18 blink::CurrencyAmount output;
19 output.setCurrency(input.currency);
20 output.setValue(input.value);
21 return output;
22 }
23 };
24
25 } // namespace mojo
26
12 namespace blink { 27 namespace blink {
13 28
14 PaymentResponse::PaymentResponse(mojom::blink::PaymentResponsePtr response, Paym entCompleter* paymentCompleter) 29 PaymentResponse::PaymentResponse(mojom::blink::PaymentResponsePtr response, Paym entCompleter* paymentCompleter)
15 : m_methodName(response->method_name) 30 : m_methodName(response->method_name)
31 , m_totalAmount(response->total_amount->To<CurrencyAmount>())
16 , m_stringifiedDetails(response->stringified_details) 32 , m_stringifiedDetails(response->stringified_details)
17 , m_shippingAddress(response->shipping_address ? new PaymentAddress(std::mov e(response->shipping_address)) : nullptr) 33 , m_shippingAddress(response->shipping_address ? new PaymentAddress(std::mov e(response->shipping_address)) : nullptr)
18 , m_paymentCompleter(paymentCompleter) 34 , m_paymentCompleter(paymentCompleter)
19 { 35 {
20 DCHECK(m_paymentCompleter); 36 DCHECK(m_paymentCompleter);
21 } 37 }
22 38
23 PaymentResponse::~PaymentResponse() 39 PaymentResponse::~PaymentResponse()
24 { 40 {
25 } 41 }
26 42
27 ScriptValue PaymentResponse::details(ScriptState* scriptState, ExceptionState& e xceptionState) const 43 ScriptValue PaymentResponse::details(ScriptState* scriptState, ExceptionState& e xceptionState) const
28 { 44 {
29 return ScriptValue(scriptState, fromJSONString(scriptState, m_stringifiedDet ails, exceptionState)); 45 return ScriptValue(scriptState, fromJSONString(scriptState, m_stringifiedDet ails, exceptionState));
30 } 46 }
31 47
32 ScriptPromise PaymentResponse::complete(ScriptState* scriptState, bool success) 48 ScriptPromise PaymentResponse::complete(ScriptState* scriptState, bool success)
33 { 49 {
34 return m_paymentCompleter->complete(scriptState, success); 50 return m_paymentCompleter->complete(scriptState, success);
35 } 51 }
36 52
37 DEFINE_TRACE(PaymentResponse) 53 DEFINE_TRACE(PaymentResponse)
38 { 54 {
39 visitor->trace(m_shippingAddress); 55 visitor->trace(m_shippingAddress);
40 visitor->trace(m_paymentCompleter); 56 visitor->trace(m_paymentCompleter);
41 } 57 }
42 58
43 } // namespace blink 59 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698