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