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 526f74e012afc41f47604f1cb3a1970a470def45..9146745902d9aa6bcb62e5dce82109ef97ff99f3 100644 |
--- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp |
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp |
@@ -13,6 +13,8 @@ |
#include "bindings/core/v8/V8StringResource.h" |
#include "bindings/modules/v8/V8AndroidPayMethodData.h" |
#include "bindings/modules/v8/V8BasicCardRequest.h" |
+#include "bindings/modules/v8/V8NativeAndroidPaymentAppManifest.h" |
+#include "bindings/modules/v8/V8NativeAndroidPaymentAppManifestSection.h" |
#include "bindings/modules/v8/V8PaymentDetails.h" |
#include "core/EventTypeNames.h" |
#include "core/dom/DOMException.h" |
@@ -30,6 +32,8 @@ |
#include "modules/payments/AndroidPayTokenization.h" |
#include "modules/payments/BasicCardRequest.h" |
#include "modules/payments/HTMLIFrameElementPayments.h" |
+#include "modules/payments/NativeAndroidPaymentAppManifest.h" |
+#include "modules/payments/NativeAndroidPaymentAppManifestSection.h" |
#include "modules/payments/PaymentAddress.h" |
#include "modules/payments/PaymentItem.h" |
#include "modules/payments/PaymentRequestUpdateEvent.h" |
@@ -43,24 +47,46 @@ |
#include "public/platform/Platform.h" |
#include "public/platform/WebTraceLocation.h" |
#include "wtf/HashSet.h" |
+#include "wtf/Optional.h" |
-using payments::mojom::blink::CanMakePaymentQueryResult; |
-using payments::mojom::blink::PaymentAddressPtr; |
-using payments::mojom::blink::PaymentCurrencyAmount; |
-using payments::mojom::blink::PaymentCurrencyAmountPtr; |
-using payments::mojom::blink::PaymentDetailsModifierPtr; |
-using payments::mojom::blink::PaymentDetailsPtr; |
-using payments::mojom::blink::PaymentErrorReason; |
-using payments::mojom::blink::PaymentItemPtr; |
-using payments::mojom::blink::PaymentMethodDataPtr; |
-using payments::mojom::blink::PaymentOptionsPtr; |
-using payments::mojom::blink::PaymentResponsePtr; |
-using payments::mojom::blink::PaymentShippingOptionPtr; |
-using payments::mojom::blink::PaymentShippingType; |
+namespace { |
+ |
+using ::payments::mojom::blink::CanMakePaymentQueryResult; |
+using ::payments::mojom::blink::NativeAndroidPaymentAppManifestSection; |
+using ::payments::mojom::blink::NativeAndroidPaymentAppManifestSectionPtr; |
+using ::payments::mojom::blink::PaymentAddressPtr; |
+using ::payments::mojom::blink::PaymentCurrencyAmount; |
+using ::payments::mojom::blink::PaymentCurrencyAmountPtr; |
+using ::payments::mojom::blink::PaymentDetailsModifierPtr; |
+using ::payments::mojom::blink::PaymentDetailsPtr; |
+using ::payments::mojom::blink::PaymentErrorReason; |
+using ::payments::mojom::blink::PaymentItemPtr; |
+using ::payments::mojom::blink::PaymentMethodDataPtr; |
+using ::payments::mojom::blink::PaymentOptionsPtr; |
+using ::payments::mojom::blink::PaymentResponsePtr; |
+using ::payments::mojom::blink::PaymentShippingOptionPtr; |
+using ::payments::mojom::blink::PaymentShippingType; |
+ |
+} // namespace |
namespace mojo { |
template <> |
+struct TypeConverter<NativeAndroidPaymentAppManifestSectionPtr, |
+ blink::NativeAndroidPaymentAppManifestSection> { |
+ static NativeAndroidPaymentAppManifestSectionPtr Convert( |
+ const blink::NativeAndroidPaymentAppManifestSection& input) { |
+ NativeAndroidPaymentAppManifestSectionPtr output = |
+ NativeAndroidPaymentAppManifestSection::New(); |
+ output->package_name = input.package(); |
+ output->version = input.hasVersion() ? input.version() : 0; |
+ if (input.hasSha256_cert_fingerprints()) |
+ output->sha256_cert_fingerprints = input.sha256_cert_fingerprints(); |
+ return output; |
+ } |
+}; |
+ |
+template <> |
struct TypeConverter<PaymentCurrencyAmountPtr, blink::PaymentCurrencyAmount> { |
static PaymentCurrencyAmountPtr Convert( |
const blink::PaymentCurrencyAmount& input) { |
@@ -1054,6 +1080,48 @@ void PaymentRequest::OnCanMakePayment(CanMakePaymentQueryResult result) { |
m_canMakePaymentResolver.clear(); |
} |
+void PaymentRequest::ParsePaymentManifest( |
+ const String& content, |
+ const ParsePaymentManifestCallback& callback) { |
+ Optional<Vector<NativeAndroidPaymentAppManifestSectionPtr>> result; |
+ |
+ ScriptState* state = ScriptState::forMainWorld(frame()); |
Marijn Kruisselbrink
2017/02/23 20:07:06
I don't think using ScriptState::forMainWorld (or
|
+ if (!state->contextIsValid()) { |
+ callback.Run(std::move(result)); |
+ return; |
+ } |
+ |
+ ScriptState::Scope scope(state); |
+ ExceptionState exceptionState(state->isolate(), |
+ ExceptionState::ConstructionContext, |
+ "NativeAndroidPaymentAppManifest"); |
+ v8::Local<v8::Value> input = |
+ fromJSONString(state->isolate(), content, exceptionState); |
+ if (exceptionState.hadException()) { |
+ callback.Run(std::move(result)); |
+ return; |
+ } |
+ |
+ NativeAndroidPaymentAppManifest manifest; |
+ V8NativeAndroidPaymentAppManifest::toImpl(state->isolate(), input, manifest, |
+ exceptionState); |
+ if (exceptionState.hadException()) { |
+ callback.Run(std::move(result)); |
+ return; |
+ } |
+ |
+ if (manifest.hasAndroid() && !manifest.android().isEmpty()) { |
+ result = Vector<NativeAndroidPaymentAppManifestSectionPtr>(); |
+ for (const auto& section : manifest.android()) { |
+ result->push_back( |
+ payments::mojom::blink::NativeAndroidPaymentAppManifestSection::From( |
+ section)); |
+ } |
+ } |
+ |
+ callback.Run(std::move(result)); |
+} |
+ |
void PaymentRequest::onCompleteTimeout(TimerBase*) { |
m_paymentProvider->Complete(payments::mojom::blink::PaymentComplete(Fail)); |
clearResolversAndCloseMojoConnection(); |