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, jclass clazz, |
21 jstring string) { | 21 jstring string) { |
22 return base::i18n::GetFirstStrongCharacterDirection( | 22 return base::i18n::GetFirstStrongCharacterDirection( |
23 base::android::ConvertJavaStringToUTF16(env, string)); | 23 base::android::ConvertJavaStringToUTF16(env, string)); |
24 } | 24 } |
25 | 25 |
26 std::string GetDefaultLocale() { | |
27 JNIEnv* env = base::android::AttachCurrentThread(); | |
28 ScopedJavaLocalRef<jstring> locale = Java_LocalizationUtils_getDefaultLocale( | |
29 env); | |
30 return ConvertJavaStringToUTF8(locale); | |
31 } | |
32 | |
33 bool IsLayoutRtl() { | 26 bool IsLayoutRtl() { |
34 static bool is_layout_rtl_cached = false; | 27 static bool is_layout_rtl_cached = false; |
35 static bool layout_rtl_cache; | 28 static bool layout_rtl_cache; |
36 | 29 |
37 if (!is_layout_rtl_cached) { | 30 if (!is_layout_rtl_cached) { |
38 is_layout_rtl_cached = true; | 31 is_layout_rtl_cached = true; |
39 JNIEnv* env = base::android::AttachCurrentThread(); | 32 JNIEnv* env = base::android::AttachCurrentThread(); |
40 layout_rtl_cache = | 33 layout_rtl_cache = |
41 static_cast<bool>(Java_LocalizationUtils_isLayoutRtl(env)); | 34 static_cast<bool>(Java_LocalizationUtils_isLayoutRtl(env)); |
42 } | 35 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 ui::TimeFormat::FORMAT_REMAINING, ui::TimeFormat::LENGTH_SHORT, | 100 ui::TimeFormat::FORMAT_REMAINING, ui::TimeFormat::LENGTH_SHORT, |
108 base::TimeDelta::FromMilliseconds(timeInMillis))); | 101 base::TimeDelta::FromMilliseconds(timeInMillis))); |
109 return jtime_remaining.Release(); | 102 return jtime_remaining.Release(); |
110 } | 103 } |
111 | 104 |
112 bool RegisterLocalizationUtil(JNIEnv* env) { | 105 bool RegisterLocalizationUtil(JNIEnv* env) { |
113 return RegisterNativesImpl(env); | 106 return RegisterNativesImpl(env); |
114 } | 107 } |
115 | 108 |
116 } // namespace l10n_util | 109 } // namespace l10n_util |
OLD | NEW |