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

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp

Issue 2351533002: PaymentRequest: Add support for shipping type. (in blink side) (Closed)
Patch Set: PaymentRequest: Add support for shipping type. (in blink side) Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
index 0adcb7c08c18fef7a5854aad5bb668a64e8c21d6..4d453547a2c7e48ec6abf6e41700a1f88176814a 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
@@ -361,6 +361,20 @@ String getSelectedShippingOption(const PaymentDetails& details)
return result;
}
+String getValidShippingType(const String& shippingType)
+{
+ static const char* const validValues[] = {
+ "shipping",
+ "delivery",
+ "pickup",
+ };
+ for (size_t i = 0; i < WTF_ARRAY_LENGTH(validValues); i++) {
+ if (shippingType == validValues[i])
+ return shippingType;
+ }
+ return validValues[0];
+}
+
} // namespace
PaymentRequest* PaymentRequest::create(ScriptState* scriptState, const HeapVector<PaymentMethodData>& methodData, const PaymentDetails& details, ExceptionState& exceptionState)
@@ -519,8 +533,10 @@ PaymentRequest::PaymentRequest(ScriptState* scriptState, const HeapVector<Paymen
if (exceptionState.hadException())
return;
- if (m_options.requestShipping())
+ if (m_options.requestShipping()) {
m_shippingOption = getSelectedShippingOption(details);
+ m_shippingType = getValidShippingType(m_options.shippingType());
+ }
scriptState->domWindow()->frame()->interfaceProvider()->getInterface(mojo::GetProxy(&m_paymentProvider));
m_paymentProvider.set_connection_error_handler(convertToBaseCallback(WTF::bind(&PaymentRequest::OnError, wrapWeakPersistent(this), mojom::blink::PaymentErrorReason::UNKNOWN)));

Powered by Google App Engine
This is Rietveld 408576698