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

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

Issue 2898223002: PaymentHandler: Rename PaymentAppRequest with PaymentRequestEventData. (Closed)
Patch Set: Rename Created 3 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/PaymentAppRequestConversion.h" 5 #include "modules/payments/PaymentRequestEventDataConversion.h"
6 6
7 #include "bindings/core/v8/ToV8ForCore.h" 7 #include "bindings/core/v8/ToV8ForCore.h"
8 #include "modules/payments/PaymentAppRequest.h"
9 #include "modules/payments/PaymentCurrencyAmount.h" 8 #include "modules/payments/PaymentCurrencyAmount.h"
10 #include "modules/payments/PaymentDetailsModifier.h" 9 #include "modules/payments/PaymentDetailsModifier.h"
11 #include "modules/payments/PaymentItem.h" 10 #include "modules/payments/PaymentItem.h"
12 #include "modules/payments/PaymentMethodData.h" 11 #include "modules/payments/PaymentMethodData.h"
12 #include "modules/payments/PaymentRequestEventInit.h"
13 #include "platform/bindings/ScriptState.h" 13 #include "platform/bindings/ScriptState.h"
14 #include "public/platform/modules/payments/WebPaymentAppRequest.h"
15 #include "public/platform/modules/payments/WebPaymentMethodData.h" 14 #include "public/platform/modules/payments/WebPaymentMethodData.h"
15 #include "public/platform/modules/payments/WebPaymentRequestEventData.h"
16 16
17 namespace blink { 17 namespace blink {
18 namespace { 18 namespace {
19 19
20 PaymentCurrencyAmount ToPaymentCurrencyAmount( 20 PaymentCurrencyAmount ToPaymentCurrencyAmount(
21 const WebPaymentCurrencyAmount& web_amount) { 21 const WebPaymentCurrencyAmount& web_amount) {
22 PaymentCurrencyAmount amount; 22 PaymentCurrencyAmount amount;
23 amount.setCurrency(web_amount.currency); 23 amount.setCurrency(web_amount.currency);
24 amount.setValue(web_amount.value); 24 amount.setValue(web_amount.value);
25 amount.setCurrencySystem(web_amount.currency_system); 25 amount.setCurrencySystem(web_amount.currency_system);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 supported_methods.push_back(method); 76 supported_methods.push_back(method);
77 } 77 }
78 method_data.setSupportedMethods(supported_methods); 78 method_data.setSupportedMethods(supported_methods);
79 method_data.setData( 79 method_data.setData(
80 StringDataToScriptValue(script_state, web_method_data.stringified_data)); 80 StringDataToScriptValue(script_state, web_method_data.stringified_data));
81 return method_data; 81 return method_data;
82 } 82 }
83 83
84 } // namespace 84 } // namespace
85 85
86 PaymentAppRequest PaymentAppRequestConversion::ToPaymentAppRequest( 86 PaymentRequestEventInit
87 PaymentRequestEventDataConversion::ToPaymentRequestEventInit(
87 ScriptState* script_state, 88 ScriptState* script_state,
88 const WebPaymentAppRequest& web_app_request) { 89 const WebPaymentRequestEventData& web_event_data) {
89 DCHECK(script_state); 90 DCHECK(script_state);
90 91
91 PaymentAppRequest app_request; 92 PaymentRequestEventInit event_data;
92 if (!script_state->ContextIsValid()) 93 if (!script_state->ContextIsValid())
93 return app_request; 94 return event_data;
94 95
95 ScriptState::Scope scope(script_state); 96 ScriptState::Scope scope(script_state);
96 97
97 app_request.setTopLevelOrigin(web_app_request.top_level_origin); 98 event_data.setTopLevelOrigin(web_event_data.top_level_origin);
98 app_request.setPaymentRequestOrigin(web_app_request.payment_request_origin); 99 event_data.setPaymentRequestOrigin(web_event_data.payment_request_origin);
99 app_request.setPaymentRequestId(web_app_request.payment_request_id); 100 event_data.setPaymentRequestId(web_event_data.payment_request_id);
100 HeapVector<PaymentMethodData> method_data; 101 HeapVector<PaymentMethodData> method_data;
101 for (const auto& md : web_app_request.method_data) { 102 for (const auto& md : web_event_data.method_data) {
102 method_data.push_back(ToPaymentMethodData(script_state, md)); 103 method_data.push_back(ToPaymentMethodData(script_state, md));
103 } 104 }
104 app_request.setMethodData(method_data); 105 event_data.setMethodData(method_data);
105 app_request.setTotal(ToPaymentItem(web_app_request.total)); 106 event_data.setTotal(ToPaymentItem(web_event_data.total));
106 HeapVector<PaymentDetailsModifier> modifiers; 107 HeapVector<PaymentDetailsModifier> modifiers;
107 for (const auto& modifier : web_app_request.modifiers) { 108 for (const auto& modifier : web_event_data.modifiers) {
108 modifiers.push_back(ToPaymentDetailsModifier(script_state, modifier)); 109 modifiers.push_back(ToPaymentDetailsModifier(script_state, modifier));
109 } 110 }
110 app_request.setModifiers(modifiers); 111 event_data.setModifiers(modifiers);
111 app_request.setInstrumentKey(web_app_request.instrument_key); 112 event_data.setInstrumentKey(web_event_data.instrument_key);
112 return app_request; 113 return event_data;
113 } 114 }
114 115
115 } // namespace blink 116 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698