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

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

Issue 2705293010: PaymentApp: Implement respondWith() in PaymentRequestEvent. (blink side) (Closed)
Patch Set: PaymentApp: Implement respondWith() in PaymentRequestEvent. (blink side) Created 3 years, 9 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/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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 PaymentAppRequest PaymentAppRequestConversion::toPaymentAppRequest( 86 PaymentAppRequest PaymentAppRequestConversion::toPaymentAppRequest(
87 ScriptState* scriptState, 87 ScriptState* scriptState,
88 const WebPaymentAppRequest& webAppRequest) { 88 const WebPaymentAppRequest& webAppRequest) {
89 DCHECK(scriptState);
90
89 PaymentAppRequest appRequest; 91 PaymentAppRequest appRequest;
92 if (!scriptState->contextIsValid())
93 return appRequest;
94
95 ScriptState::Scope scope(scriptState);
90 96
91 appRequest.setOrigin(webAppRequest.origin); 97 appRequest.setOrigin(webAppRequest.origin);
92 HeapVector<PaymentMethodData> methodData; 98 HeapVector<PaymentMethodData> methodData;
93 for (const auto& md : webAppRequest.methodData) { 99 for (const auto& md : webAppRequest.methodData) {
94 methodData.push_back(toPaymentMethodData(scriptState, md)); 100 methodData.push_back(toPaymentMethodData(scriptState, md));
95 } 101 }
96 appRequest.setMethodData(methodData); 102 appRequest.setMethodData(methodData);
97 appRequest.setTotal(toPaymentItem(webAppRequest.total)); 103 appRequest.setTotal(toPaymentItem(webAppRequest.total));
98 HeapVector<PaymentDetailsModifier> modifiers; 104 HeapVector<PaymentDetailsModifier> modifiers;
99 for (const auto& modifier : webAppRequest.modifiers) { 105 for (const auto& modifier : webAppRequest.modifiers) {
100 modifiers.push_back(toPaymentDetailsModifier(scriptState, modifier)); 106 modifiers.push_back(toPaymentDetailsModifier(scriptState, modifier));
101 } 107 }
102 appRequest.setOptionId(webAppRequest.optionId); 108 appRequest.setOptionId(webAppRequest.optionId);
103 return appRequest; 109 return appRequest;
104 } 110 }
105 111
106 } // namespace blink 112 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/payments/BUILD.gn ('k') | third_party/WebKit/Source/modules/payments/PaymentAppResponse.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698