Chromium Code Reviews| 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/PaymentAppRequestConversion.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/PaymentAppRequest.h" | 9 #include "modules/payments/PaymentAppRequest.h" |
| 10 #include "modules/payments/PaymentCurrencyAmount.h" | 10 #include "modules/payments/PaymentCurrencyAmount.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 PaymentAppRequest PaymentAppRequestConversion::toPaymentAppRequest( | 86 PaymentAppRequest PaymentAppRequestConversion::toPaymentAppRequest( |
| 87 ScriptState* scriptState, | 87 ScriptState* scriptState, |
| 88 const WebPaymentAppRequest& webAppRequest) { | 88 const WebPaymentAppRequest& webAppRequest) { |
| 89 PaymentAppRequest appRequest; | 89 PaymentAppRequest appRequest; |
| 90 if (!scriptState || !scriptState->contextIsValid()) | |
|
haraken
2017/03/14 16:15:51
scriptState should not be null.
zino
2017/03/16 13:47:31
Sorry, I don't understand exactly.
Did you mean th
haraken
2017/03/16 15:16:52
Yeah, you can use DCHECK.
zino
2017/03/16 16:34:19
Done.
| |
| 91 return appRequest; | |
| 92 | |
| 93 ScriptState::Scope scope(scriptState); | |
| 90 | 94 |
| 91 appRequest.setOrigin(webAppRequest.origin); | 95 appRequest.setOrigin(webAppRequest.origin); |
| 92 HeapVector<PaymentMethodData> methodData; | 96 HeapVector<PaymentMethodData> methodData; |
| 93 for (const auto& md : webAppRequest.methodData) { | 97 for (const auto& md : webAppRequest.methodData) { |
| 94 methodData.push_back(toPaymentMethodData(scriptState, md)); | 98 methodData.push_back(toPaymentMethodData(scriptState, md)); |
| 95 } | 99 } |
| 96 appRequest.setMethodData(methodData); | 100 appRequest.setMethodData(methodData); |
| 97 appRequest.setTotal(toPaymentItem(webAppRequest.total)); | 101 appRequest.setTotal(toPaymentItem(webAppRequest.total)); |
| 98 HeapVector<PaymentDetailsModifier> modifiers; | 102 HeapVector<PaymentDetailsModifier> modifiers; |
| 99 for (const auto& modifier : webAppRequest.modifiers) { | 103 for (const auto& modifier : webAppRequest.modifiers) { |
| 100 modifiers.push_back(toPaymentDetailsModifier(scriptState, modifier)); | 104 modifiers.push_back(toPaymentDetailsModifier(scriptState, modifier)); |
| 101 } | 105 } |
| 102 appRequest.setOptionId(webAppRequest.optionId); | 106 appRequest.setOptionId(webAppRequest.optionId); |
| 103 return appRequest; | 107 return appRequest; |
| 104 } | 108 } |
| 105 | 109 |
| 106 } // namespace blink | 110 } // namespace blink |
| OLD | NEW |