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

Unified Diff: chrome/browser/payments/android/component_jni_registrar.cc

Issue 2373103002: [Web Payments] Common Payments validation (Closed)
Patch Set: Split off moving Mojo file 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: chrome/browser/payments/android/component_jni_registrar.cc
diff --git a/chrome/browser/payments/android/component_jni_registrar.cc b/chrome/browser/payments/android/component_jni_registrar.cc
new file mode 100644
index 0000000000000000000000000000000000000000..494fd43915ff3124dadaab379d60aa928949f9b8
--- /dev/null
+++ b/chrome/browser/payments/android/component_jni_registrar.cc
@@ -0,0 +1,34 @@
+// 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/payment_details_validation.h"
+#include "components/payments/payment_request.mojom.h"
+#include "jni/PaymentValidator_jni.h"
+
+namespace payments {
please use gerrit instead 2016/10/27 17:14:25 Anonymous namespace should provide better encapsul
Kevin Bailey 2016/10/27 22:17:53 JNI picked this namespace. The functions need to b
+
+jlong Init(JNIEnv* env, const base::android::JavaParamRef<jclass>& jcaller) {
+ return (jlong)0;
+}
+
+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;
+ return payments::validatePaymentDetails(details);
+}
+
+} // namespace payments
+
+bool RegisterPaymentValidator(JNIEnv* env) {
+ return payments::RegisterNativesImpl(env);
please use gerrit instead 2016/10/27 17:14:25 Where is this payments::RegisterNativesImpl() defi
Kevin Bailey 2016/10/27 22:17:53 With the latest changes, it's here: out/*/gen/com
+}

Powered by Google App Engine
This is Rietveld 408576698