| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/base/l10n/l10n_util_android.h" | 5 #include "ui/base/l10n/l10n_util_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "jni/LocalizationUtils_jni.h" | 14 #include "jni/LocalizationUtils_jni.h" |
| 15 #include "third_party/icu/source/common/unicode/uloc.h" | 15 #include "third_party/icu/source/common/unicode/uloc.h" |
| 16 #include "ui/base/l10n/time_format.h" | 16 #include "ui/base/l10n/time_format.h" |
| 17 | 17 |
| 18 namespace l10n_util { | 18 namespace l10n_util { |
| 19 | 19 |
| 20 jint GetFirstStrongCharacterDirection(JNIEnv* env, jclass clazz, | 20 jint GetFirstStrongCharacterDirection(JNIEnv* env, |
| 21 jstring string) { | 21 const JavaParamRef<jclass>& clazz, |
| 22 const JavaParamRef<jstring>& string) { |
| 22 return base::i18n::GetFirstStrongCharacterDirection( | 23 return base::i18n::GetFirstStrongCharacterDirection( |
| 23 base::android::ConvertJavaStringToUTF16(env, string)); | 24 base::android::ConvertJavaStringToUTF16(env, string)); |
| 24 } | 25 } |
| 25 | 26 |
| 26 bool IsLayoutRtl() { | 27 bool IsLayoutRtl() { |
| 27 static bool is_layout_rtl_cached = false; | 28 static bool is_layout_rtl_cached = false; |
| 28 static bool layout_rtl_cache; | 29 static bool layout_rtl_cache; |
| 29 | 30 |
| 30 if (!is_layout_rtl_cached) { | 31 if (!is_layout_rtl_cached) { |
| 31 is_layout_rtl_cached = true; | 32 is_layout_rtl_cached = true; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 87 |
| 87 ScopedJavaLocalRef<jstring> java_result( | 88 ScopedJavaLocalRef<jstring> java_result( |
| 88 Java_LocalizationUtils_getDisplayNameForLocale( | 89 Java_LocalizationUtils_getDisplayNameForLocale( |
| 89 env, | 90 env, |
| 90 java_locale.obj(), | 91 java_locale.obj(), |
| 91 java_display_locale.obj())); | 92 java_display_locale.obj())); |
| 92 return ConvertJavaStringToUTF16(java_result); | 93 return ConvertJavaStringToUTF16(java_result); |
| 93 } | 94 } |
| 94 | 95 |
| 95 ScopedJavaLocalRef<jstring> GetDurationString(JNIEnv* env, | 96 ScopedJavaLocalRef<jstring> GetDurationString(JNIEnv* env, |
| 96 jclass clazz, | 97 const JavaParamRef<jclass>& clazz, |
| 97 jlong timeInMillis) { | 98 jlong timeInMillis) { |
| 98 ScopedJavaLocalRef<jstring> jtime_remaining = | 99 ScopedJavaLocalRef<jstring> jtime_remaining = |
| 99 base::android::ConvertUTF16ToJavaString( | 100 base::android::ConvertUTF16ToJavaString( |
| 100 env, | 101 env, |
| 101 ui::TimeFormat::Simple( | 102 ui::TimeFormat::Simple( |
| 102 ui::TimeFormat::FORMAT_REMAINING, ui::TimeFormat::LENGTH_SHORT, | 103 ui::TimeFormat::FORMAT_REMAINING, ui::TimeFormat::LENGTH_SHORT, |
| 103 base::TimeDelta::FromMilliseconds(timeInMillis))); | 104 base::TimeDelta::FromMilliseconds(timeInMillis))); |
| 104 return jtime_remaining; | 105 return jtime_remaining; |
| 105 } | 106 } |
| 106 | 107 |
| 107 bool RegisterLocalizationUtil(JNIEnv* env) { | 108 bool RegisterLocalizationUtil(JNIEnv* env) { |
| 108 return RegisterNativesImpl(env); | 109 return RegisterNativesImpl(env); |
| 109 } | 110 } |
| 110 | 111 |
| 111 } // namespace l10n_util | 112 } // namespace l10n_util |
| OLD | NEW |