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> | 7 #include <stdint.h> |
8 | 8 |
9 #include <cstring> | 9 #include <cstring> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/android/jni_android.h" | 14 #include "base/android/jni_android.h" |
15 #include "components/payments/content/payment_details_validation.h" | 15 #include "components/payments/content/payment_details_validation.h" |
16 #include "components/payments/mojom/payment_request.mojom.h" | 16 #include "components/payments/content/payment_request.mojom.h" |
17 #include "jni/PaymentValidator_jni.h" | 17 #include "jni/PaymentValidator_jni.h" |
18 | 18 |
19 namespace payments { | 19 namespace payments { |
20 | 20 |
21 jboolean ValidatePaymentDetails( | 21 jboolean ValidatePaymentDetails( |
22 JNIEnv* env, | 22 JNIEnv* env, |
23 const base::android::JavaParamRef<jclass>& jcaller, | 23 const base::android::JavaParamRef<jclass>& jcaller, |
24 const base::android::JavaParamRef<jobject>& buffer) { | 24 const base::android::JavaParamRef<jobject>& buffer) { |
25 jbyte* buf_in = static_cast<jbyte*>(env->GetDirectBufferAddress(buffer)); | 25 jbyte* buf_in = static_cast<jbyte*>(env->GetDirectBufferAddress(buffer)); |
26 jlong buf_size = env->GetDirectBufferCapacity(buffer); | 26 jlong buf_size = env->GetDirectBufferCapacity(buffer); |
27 std::vector<uint8_t> mojo_buffer(buf_size); | 27 std::vector<uint8_t> mojo_buffer(buf_size); |
28 memcpy(&mojo_buffer[0], buf_in, buf_size); | 28 memcpy(&mojo_buffer[0], buf_in, buf_size); |
29 mojom::PaymentDetailsPtr details; | 29 mojom::PaymentDetailsPtr details; |
30 if (!mojom::PaymentDetails::Deserialize(std::move(mojo_buffer), &details)) | 30 if (!mojom::PaymentDetails::Deserialize(std::move(mojo_buffer), &details)) |
31 return false; | 31 return false; |
32 std::string unused_error_message; | 32 std::string unused_error_message; |
33 return validatePaymentDetails(details, &unused_error_message); | 33 return validatePaymentDetails(details, &unused_error_message); |
34 } | 34 } |
35 | 35 |
36 bool RegisterPaymentValidator(JNIEnv* env) { | 36 bool RegisterPaymentValidator(JNIEnv* env) { |
37 return RegisterNativesImpl(env); | 37 return RegisterNativesImpl(env); |
38 } | 38 } |
39 | 39 |
40 } // namespace payments | 40 } // namespace payments |
OLD | NEW |