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/PaymentAppRequestDataConversion.h" | 5 #include "modules/payments/PaymentAppRequestConversion.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
8 #include "bindings/core/v8/ToV8.h" | 8 #include "bindings/core/v8/ToV8.h" |
9 #include "modules/payments/PaymentAppRequestData.h" | 9 #include "modules/payments/PaymentAppRequest.h" |
10 #include "modules/payments/PaymentCurrencyAmount.h" | 10 #include "modules/payments/PaymentCurrencyAmount.h" |
11 #include "modules/payments/PaymentDetailsModifier.h" | 11 #include "modules/payments/PaymentDetailsModifier.h" |
12 #include "modules/payments/PaymentItem.h" | 12 #include "modules/payments/PaymentItem.h" |
13 #include "modules/payments/PaymentMethodData.h" | 13 #include "modules/payments/PaymentMethodData.h" |
14 #include "public/platform/modules/payments/WebPaymentAppRequestData.h" | 14 #include "public/platform/modules/payments/WebPaymentAppRequest.h" |
15 #include "public/platform/modules/payments/WebPaymentMethodData.h" | 15 #include "public/platform/modules/payments/WebPaymentMethodData.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 namespace { | 18 namespace { |
19 | 19 |
20 PaymentCurrencyAmount toPaymentCurrencyAmount( | 20 PaymentCurrencyAmount toPaymentCurrencyAmount( |
21 const WebPaymentCurrencyAmount& webAmount) { | 21 const WebPaymentCurrencyAmount& webAmount) { |
22 PaymentCurrencyAmount amount; | 22 PaymentCurrencyAmount amount; |
23 amount.setCurrency(webAmount.currency); | 23 amount.setCurrency(webAmount.currency); |
24 amount.setValue(webAmount.value); | 24 amount.setValue(webAmount.value); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 supportedMethods.push_back(method); | 76 supportedMethods.push_back(method); |
77 } | 77 } |
78 methodData.setSupportedMethods(supportedMethods); | 78 methodData.setSupportedMethods(supportedMethods); |
79 methodData.setData( | 79 methodData.setData( |
80 stringDataToScriptValue(scriptState, webMethodData.stringifiedData)); | 80 stringDataToScriptValue(scriptState, webMethodData.stringifiedData)); |
81 return methodData; | 81 return methodData; |
82 } | 82 } |
83 | 83 |
84 } // namespace | 84 } // namespace |
85 | 85 |
86 PaymentAppRequestData PaymentAppRequestDataConversion::toPaymentAppRequestData( | 86 PaymentAppRequest PaymentAppRequestConversion::toPaymentAppRequest( |
87 ScriptState* scriptState, | 87 ScriptState* scriptState, |
88 const WebPaymentAppRequestData& webData) { | 88 const WebPaymentAppRequest& webAppRequest) { |
89 PaymentAppRequestData data; | 89 PaymentAppRequest appRequest; |
90 | 90 |
91 data.setOrigin(webData.origin); | 91 appRequest.setOrigin(webAppRequest.origin); |
92 HeapVector<PaymentMethodData> methodData; | 92 HeapVector<PaymentMethodData> methodData; |
93 for (const auto& md : webData.methodData) { | 93 for (const auto& md : webAppRequest.methodData) { |
94 methodData.push_back(toPaymentMethodData(scriptState, md)); | 94 methodData.push_back(toPaymentMethodData(scriptState, md)); |
95 } | 95 } |
96 data.setMethodData(methodData); | 96 appRequest.setMethodData(methodData); |
97 data.setTotal(toPaymentItem(webData.total)); | 97 appRequest.setTotal(toPaymentItem(webAppRequest.total)); |
98 HeapVector<PaymentDetailsModifier> modifiers; | 98 HeapVector<PaymentDetailsModifier> modifiers; |
99 for (const auto& modifier : webData.modifiers) { | 99 for (const auto& modifier : webAppRequest.modifiers) { |
100 modifiers.push_back(toPaymentDetailsModifier(scriptState, modifier)); | 100 modifiers.push_back(toPaymentDetailsModifier(scriptState, modifier)); |
101 } | 101 } |
102 data.setOptionId(webData.optionId); | 102 appRequest.setOptionId(webAppRequest.optionId); |
103 return data; | 103 return appRequest; |
104 } | 104 } |
105 | 105 |
106 } // namespace blink | 106 } // namespace blink |
OLD | NEW |