| 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_CURRENCY_FORMATTER_ANDROID_H_ |
| 6 #define COMPONENTS_PAYMENTS_CONTENT_ANDROID_CURRENCY_FORMATTER_ANDROID_H_ | 6 #define COMPONENTS_PAYMENTS_CONTENT_ANDROID_CURRENCY_FORMATTER_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 | 13 |
| 14 namespace payments { | 14 namespace payments { |
| 15 | 15 |
| 16 class CurrencyFormatter; | 16 class CurrencyFormatter; |
| 17 | 17 |
| 18 // Forwarding calls to payments::CurrencyFormatter. | 18 // Forwarding calls to payments::CurrencyFormatter. |
| 19 class CurrencyFormatterAndroid { | 19 class CurrencyFormatterAndroid { |
| 20 public: | 20 public: |
| 21 // Registers the JNI bindings for this class. |
| 22 static bool Register(JNIEnv* env); |
| 23 |
| 21 CurrencyFormatterAndroid( | 24 CurrencyFormatterAndroid( |
| 22 JNIEnv* env, | 25 JNIEnv* env, |
| 23 jobject unused_obj, | 26 jobject jcaller, |
| 24 const base::android::JavaParamRef<jstring>& currency_code, | 27 const base::android::JavaParamRef<jstring>& currency_code, |
| 25 const base::android::JavaParamRef<jstring>& currency_system, | 28 const base::android::JavaParamRef<jstring>& currency_system, |
| 26 const base::android::JavaParamRef<jstring>& locale_name); | 29 const base::android::JavaParamRef<jstring>& locale_name); |
| 27 ~CurrencyFormatterAndroid(); | 30 ~CurrencyFormatterAndroid(); |
| 28 | 31 |
| 29 // Message from Java to destroy this object. | 32 // Message from Java to destroy this object. |
| 30 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 33 void Destroy(JNIEnv* env, |
| 34 const base::android::JavaParamRef<jobject>& jcaller); |
| 31 | 35 |
| 32 // Refer to CurrencyFormatter::Format documentation. | 36 // Refer to CurrencyFormatter::Format documentation. |
| 33 base::android::ScopedJavaLocalRef<jstring> Format( | 37 base::android::ScopedJavaLocalRef<jstring> Format( |
| 34 JNIEnv* env, | 38 JNIEnv* env, |
| 35 const base::android::JavaParamRef<jobject>& unused_obj, | 39 const base::android::JavaParamRef<jobject>& jcaller, |
| 36 const base::android::JavaParamRef<jstring>& amount); | 40 const base::android::JavaParamRef<jstring>& amount); |
| 37 | 41 |
| 38 base::android::ScopedJavaLocalRef<jstring> GetFormattedCurrencyCode( | 42 base::android::ScopedJavaLocalRef<jstring> GetFormattedCurrencyCode( |
| 39 JNIEnv* env, | 43 JNIEnv* env, |
| 40 const base::android::JavaParamRef<jobject>& unused_obj); | 44 const base::android::JavaParamRef<jobject>& jcaller); |
| 41 | |
| 42 // Registers the JNI bindings for this class. | |
| 43 static bool Register(JNIEnv* env); | |
| 44 | 45 |
| 45 private: | 46 private: |
| 46 std::unique_ptr<CurrencyFormatter> currency_formatter_; | 47 std::unique_ptr<CurrencyFormatter> currency_formatter_; |
| 47 | 48 |
| 48 DISALLOW_COPY_AND_ASSIGN(CurrencyFormatterAndroid); | 49 DISALLOW_COPY_AND_ASSIGN(CurrencyFormatterAndroid); |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 } // namespace payments | 52 } // namespace payments |
| 52 | 53 |
| 53 #endif // COMPONENTS_PAYMENTS_CONTENT_ANDROID_CURRENCY_FORMATTER_ANDROID_H_ | 54 #endif // COMPONENTS_PAYMENTS_CONTENT_ANDROID_CURRENCY_FORMATTER_ANDROID_H_ |
| OLD | NEW |