locale_utils.cc 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "base/android/locale_utils.h"
  5. #include "base/android/jni_android.h"
  6. #include "base/android/jni_string.h"
  7. #include "base/base_jni_headers/LocaleUtils_jni.h"
  8. namespace base {
  9. namespace android {
  10. std::string GetDefaultCountryCode() {
  11. JNIEnv* env = base::android::AttachCurrentThread();
  12. return ConvertJavaStringToUTF8(Java_LocaleUtils_getDefaultCountryCode(env));
  13. }
  14. std::string GetDefaultLocaleString() {
  15. JNIEnv* env = base::android::AttachCurrentThread();
  16. ScopedJavaLocalRef<jstring> locale =
  17. Java_LocaleUtils_getDefaultLocaleString(env);
  18. return ConvertJavaStringToUTF8(locale);
  19. }
  20. std::string GetDefaultLocaleListString() {
  21. JNIEnv* env = base::android::AttachCurrentThread();
  22. ScopedJavaLocalRef<jstring> locales =
  23. Java_LocaleUtils_getDefaultLocaleListString(env);
  24. return ConvertJavaStringToUTF8(locales);
  25. }
  26. } // namespace android
  27. } // namespace base