diff options
author | Ben Murdoch <benm@google.com> | 2011-07-13 12:36:52 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-07-13 16:57:35 +0100 |
commit | 74b084c38a376b8c8ee24cadcc3e65bfb4b47160 (patch) | |
tree | 059767b30133481e868bb49247ae1b2cb7f84a05 /android | |
parent | 9f5ee29cc6202d523b1002cf85116b583156e107 (diff) | |
download | external_chromium-74b084c38a376b8c8ee24cadcc3e65bfb4b47160.zip external_chromium-74b084c38a376b8c8ee24cadcc3e65bfb4b47160.tar.gz external_chromium-74b084c38a376b8c8ee24cadcc3e65bfb4b47160.tar.bz2 |
Implement AutofillCountry::ApplicationLocale() on Android.
Call JNI to determine the current locale for the system.
Bug: 4959752
Change-Id: I6429239356842175599f1f458c77226b933a8c26
Diffstat (limited to 'android')
-rw-r--r-- | android/ui/base/l10n/l10n_util.cc | 16 | ||||
-rw-r--r-- | android/ui/base/l10n/l10n_util.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/android/ui/base/l10n/l10n_util.cc b/android/ui/base/l10n/l10n_util.cc index 649b86e..93217be 100644 --- a/android/ui/base/l10n/l10n_util.cc +++ b/android/ui/base/l10n/l10n_util.cc @@ -94,4 +94,20 @@ string16 GetStringFUTF16(int message_id, const string16& a, const string16& b, c return ReplaceStringPlaceholders(str, replacements, NULL); } +std::string GetApplicationLocale() +{ + JNIEnv* env = android::GetJNIEnv(); + jclass locale_class = env->FindClass("java/util/Locale"); + jmethodID get_default_locale = env->GetStaticMethodID(locale_class, "getDefault", "()Ljava/util/Locale;"); + jmethodID to_string = env->GetMethodID(locale_class, "toString", "()Ljava/lang/String;"); + jobject locale_jobj = env->CallStaticObjectMethod(locale_class, get_default_locale); + jstring locale_jstr = static_cast<jstring>(env->CallObjectMethod(locale_jobj, to_string)); + std::string locale = android::JstringToStdString(env, locale_jstr); + env->DeleteLocalRef(locale_jstr); + env->DeleteLocalRef(locale_jobj); + env->DeleteLocalRef(locale_class); + + return locale; +} + } diff --git a/android/ui/base/l10n/l10n_util.h b/android/ui/base/l10n/l10n_util.h index 9c14f55..248f49f 100644 --- a/android/ui/base/l10n/l10n_util.h +++ b/android/ui/base/l10n/l10n_util.h @@ -94,5 +94,6 @@ namespace l10n_util { string16 GetStringUTF16(int message_id); string16 GetStringFUTF16(int message_id, const string16& a, const string16& b, const string16& c); +std::string GetApplicationLocale(); } #endif |