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 #ifndef COMPONENTS_PAYMENTS_CONTENT_ANDROID_COMPONENT_JNI_REGISTRAR_H_ |
6 #define COMPONENTS_PAYMENTS_CONTENT_ANDROID_CURRENCY_FORMATTER_ANDROID_H_ | 6 #define COMPONENTS_PAYMENTS_CONTENT_ANDROID_COMPONENT_JNI_REGISTRAR_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <memory> | |
10 | |
11 #include "base/android/scoped_java_ref.h" | |
12 #include "base/macros.h" | |
13 | 9 |
14 namespace payments { | 10 namespace payments { |
15 | 11 |
16 class CurrencyFormatter; | 12 namespace android { |
17 | 13 |
18 // Forwarding calls to payments::CurrencyFormatter. | 14 // Register all JNI bindings necessary for the payments component. |
19 class CurrencyFormatterAndroid { | 15 bool RegisterPayments(JNIEnv* env); |
20 public: | |
21 CurrencyFormatterAndroid( | |
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 | 16 |
29 // Message from Java to destroy this object. | 17 } // namespace android |
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 }; | |
50 | 18 |
51 } // namespace payments | 19 } // namespace payments |
52 | 20 |
53 #endif // COMPONENTS_PAYMENTS_CONTENT_ANDROID_CURRENCY_FORMATTER_ANDROID_H_ | 21 #endif // COMPONENTS_PAYMENTS_CONTENT_ANDROID_COMPONENT_JNI_REGISTRAR_H_ |
OLD | NEW |