1 // Copyright 2014 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "base/android/locale_utils.h" 6 7 #include "base/android/jni_android.h" 8 #include "base/android/jni_string.h" 9 10 // Must come after all headers that specialize FromJniType() / ToJniType(). 11 #include "base/base_jni/LocaleUtils_jni.h" 12 13 namespace base { 14 namespace android { 15 GetDefaultCountryCode()16std::string GetDefaultCountryCode() { 17 JNIEnv* env = base::android::AttachCurrentThread(); 18 return ConvertJavaStringToUTF8(Java_LocaleUtils_getDefaultCountryCode(env)); 19 } 20 GetDefaultLocaleString()21std::string GetDefaultLocaleString() { 22 JNIEnv* env = base::android::AttachCurrentThread(); 23 ScopedJavaLocalRef<jstring> locale = 24 Java_LocaleUtils_getDefaultLocaleString(env); 25 return ConvertJavaStringToUTF8(locale); 26 } 27 GetDefaultLocaleListString()28std::string GetDefaultLocaleListString() { 29 JNIEnv* env = base::android::AttachCurrentThread(); 30 ScopedJavaLocalRef<jstring> locales = 31 Java_LocaleUtils_getDefaultLocaleListString(env); 32 return ConvertJavaStringToUTF8(locales); 33 } 34 35 } // namespace android 36 } // namespace base 37