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

Unified Diff: components/payments/android/payments_jni_registrar.cc

Issue 2373103002: [Web Payments] Common Payments validation (Closed)
Patch Set: Deps 2 Created 4 years, 2 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: components/payments/android/payments_jni_registrar.cc
diff --git a/components/payments/android/payments_jni_registrar.cc b/components/payments/android/payments_jni_registrar.cc
new file mode 100644
index 0000000000000000000000000000000000000000..37bf6024a8103e961ca9a3f4496769f2747734f6
--- /dev/null
+++ b/components/payments/android/payments_jni_registrar.cc
@@ -0,0 +1,36 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/payments/android/payments_jni_registrar.h"
+
+#include <string>
+#include <utility>
+
+#include "components/payments/payment_details_validation.h"
+#include "components/payments/payment_request.mojom.h"
+#include "jni/PaymentValidator_jni.h"
+
+namespace payments {
+
+jboolean ValidatePaymentDetails(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jclass>& jcaller,
+ const base::android::JavaParamRef<jobject>& buffer) {
+ jbyte* buf_in = static_cast<jbyte*>(env->GetDirectBufferAddress(buffer));
+ jlong buf_size = env->GetDirectBufferCapacity(buffer);
+ mojo::Array<uint8_t> mojo_buffer = mojo::Array<uint8_t>::New(buf_size);
+ memcpy(&mojo_buffer[0], buf_in, buf_size);
+ blink::mojom::PaymentDetailsPtr details;
+ if (!blink::mojom::PaymentDetails::Deserialize(std::move(mojo_buffer),
+ &details))
+ return false;
+ std::string unused_error_message;
+ return payments::validatePaymentDetails(details, &unused_error_message);
+}
+
+} // namespace payments
+
+bool RegisterPaymentValidator(JNIEnv* env) {
+ return payments::RegisterNativesImpl(env);
+}

Powered by Google App Engine
This is Rietveld 408576698