OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef COMPONENTS_PAYMENTS_CONTENT_ANDROID_CURRENCY_FORMATTER_ANDROID_H_ | 5 #include "components/payments/content/android/component_jni_registrar.h" |
6 #define COMPONENTS_PAYMENTS_CONTENT_ANDROID_CURRENCY_FORMATTER_ANDROID_H_ | |
7 | 6 |
8 #include <jni.h> | 7 #include "base/android/jni_android.h" |
9 #include <memory> | 8 #include "base/android/jni_registrar.h" |
10 | |
11 #include "base/android/scoped_java_ref.h" | |
12 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "components/payments/content/android/currency_formatter_android.h" |
| 11 #include "components/payments/content/android/journey_logger_android.h" |
| 12 #include "components/payments/content/android/payment_details_validation_android
.h" |
| 13 #include "components/payments/content/android/payment_manifest_downloader_androi
d.h" |
| 14 #include "components/payments/content/android/payment_manifest_parser_android.h" |
13 | 15 |
14 namespace payments { | 16 namespace payments { |
| 17 namespace android { |
15 | 18 |
16 class CurrencyFormatter; | 19 static base::android::RegistrationMethod kPaymentsRegisteredMethods[] = { |
17 | 20 {"CurrencyFormatter", CurrencyFormatterAndroid::Register}, |
18 // Forwarding calls to payments::CurrencyFormatter. | 21 {"JourneyLogger", JourneyLoggerAndroid::Register}, |
19 class CurrencyFormatterAndroid { | 22 {"PaymentManifestDownloader", RegisterPaymentManifestDownloader}, |
20 public: | 23 {"PaymentManifestParser", RegisterPaymentManifestParser}, |
21 CurrencyFormatterAndroid( | 24 {"PaymentValidator", RegisterPaymentValidator}, |
22 JNIEnv* env, | |
23 jobject unused_obj, | |
24 const base::android::JavaParamRef<jstring>& currency_code, | |
25 const base::android::JavaParamRef<jstring>& currency_system, | |
26 const base::android::JavaParamRef<jstring>& locale_name); | |
27 ~CurrencyFormatterAndroid(); | |
28 | |
29 // Message from Java to destroy this object. | |
30 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | |
31 | |
32 // Refer to CurrencyFormatter::Format documentation. | |
33 base::android::ScopedJavaLocalRef<jstring> Format( | |
34 JNIEnv* env, | |
35 const base::android::JavaParamRef<jobject>& unused_obj, | |
36 const base::android::JavaParamRef<jstring>& amount); | |
37 | |
38 base::android::ScopedJavaLocalRef<jstring> GetFormattedCurrencyCode( | |
39 JNIEnv* env, | |
40 const base::android::JavaParamRef<jobject>& unused_obj); | |
41 | |
42 // Registers the JNI bindings for this class. | |
43 static bool Register(JNIEnv* env); | |
44 | |
45 private: | |
46 std::unique_ptr<CurrencyFormatter> currency_formatter_; | |
47 | |
48 DISALLOW_COPY_AND_ASSIGN(CurrencyFormatterAndroid); | |
49 }; | 25 }; |
50 | 26 |
51 } // namespace payments | 27 bool RegisterPayments(JNIEnv* env) { |
| 28 return base::android::RegisterNativeMethods( |
| 29 env, kPaymentsRegisteredMethods, arraysize(kPaymentsRegisteredMethods)); |
| 30 } |
52 | 31 |
53 #endif // COMPONENTS_PAYMENTS_CONTENT_ANDROID_CURRENCY_FORMATTER_ANDROID_H_ | 32 } // namespace android |
| 33 } // namespace payments |
OLD | NEW |