// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_PAYMENTS_CONTENT_ANDROID_UI_CURRENCY_FORMATTER_ANDROID_H_
#define COMPONENTS_PAYMENTS_CONTENT_ANDROID_UI_CURRENCY_FORMATTER_ANDROID_H_

#include <jni.h>
#include <memory>

#include "base/android/scoped_java_ref.h"

namespace payments {

class CurrencyFormatter;

// Forwarding calls to payments::CurrencyFormatter.
class CurrencyFormatterAndroid {
 public:
  CurrencyFormatterAndroid(JNIEnv* env,
                           const base::android::JavaRef<jstring>& currency_code,
                           const base::android::JavaRef<jstring>& locale_name);

  CurrencyFormatterAndroid(const CurrencyFormatterAndroid&) = delete;
  CurrencyFormatterAndroid& operator=(const CurrencyFormatterAndroid&) = delete;

  ~CurrencyFormatterAndroid();

  // Message from Java to destroy this object.
  void Destroy(JNIEnv* env);

  // Set the maximum number of fractional digits.
  void SetMaxFractionalDigits(JNIEnv* env, int32_t jnum_fractional_digits);

  // Refer to CurrencyFormatter::Format documentation.
  base::android::ScopedJavaLocalRef<jstring> Format(
      JNIEnv* env,
      const base::android::JavaRef<jstring>& amount);

  base::android::ScopedJavaLocalRef<jstring> GetFormattedCurrencyCode(
      JNIEnv* env);

 private:
  std::unique_ptr<CurrencyFormatter> currency_formatter_;
};

}  // namespace payments

#endif  // COMPONENTS_PAYMENTS_CONTENT_ANDROID_UI_CURRENCY_FORMATTER_ANDROID_H_
