| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/payments/android/payments_jni_registrar.h" |
| 6 |
| 7 #include <string> |
| 8 #include <utility> |
| 9 |
| 10 #include "components/payments/payment_details_validation.h" |
| 11 #include "components/payments/payment_request.mojom.h" |
| 12 #include "jni/PaymentValidator_jni.h" |
| 13 |
| 14 namespace payments { |
| 15 |
| 16 jboolean ValidatePaymentDetails( |
| 17 JNIEnv* env, |
| 18 const base::android::JavaParamRef<jclass>& jcaller, |
| 19 const base::android::JavaParamRef<jobject>& buffer) { |
| 20 jbyte* buf_in = static_cast<jbyte*>(env->GetDirectBufferAddress(buffer)); |
| 21 jlong buf_size = env->GetDirectBufferCapacity(buffer); |
| 22 mojo::Array<uint8_t> mojo_buffer = mojo::Array<uint8_t>::New(buf_size); |
| 23 memcpy(&mojo_buffer[0], buf_in, buf_size); |
| 24 blink::mojom::PaymentDetailsPtr details; |
| 25 if (!blink::mojom::PaymentDetails::Deserialize(std::move(mojo_buffer), |
| 26 &details)) |
| 27 return false; |
| 28 std::string unused_error_message; |
| 29 return payments::validatePaymentDetails(details, &unused_error_message); |
| 30 } |
| 31 |
| 32 } // namespace payments |
| 33 |
| 34 bool RegisterPaymentValidator(JNIEnv* env) { |
| 35 return payments::RegisterNativesImpl(env); |
| 36 } |
| OLD | NEW |