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..7c0d805526318bb481fd97c5967dbe8d35ebd990 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) |
+{ |
+ const char* validValues[] = { |
+ "shipping", |
+ "delivery", |
+ "pickup", |
+ }; |
please use gerrit instead
2016/09/18 16:54:56
Is this allocated on the stack? We would not want
zino
2016/09/18 18:57:40
Good point.
I changed it to static const char* con
|
+ 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))); |