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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // Common prototype of ICU uloc_getXXX() functions. | 42 // Common prototype of ICU uloc_getXXX() functions. |
43 typedef int32_t (*UlocGetComponentFunc)(const char*, char*, int32_t, | 43 typedef int32_t (*UlocGetComponentFunc)(const char*, char*, int32_t, |
44 UErrorCode*); | 44 UErrorCode*); |
45 | 45 |
46 std::string GetLocaleComponent(const std::string& locale, | 46 std::string GetLocaleComponent(const std::string& locale, |
47 UlocGetComponentFunc uloc_func, | 47 UlocGetComponentFunc uloc_func, |
48 int32_t max_capacity) { | 48 int32_t max_capacity) { |
49 std::string result; | 49 std::string result; |
50 UErrorCode error = U_ZERO_ERROR; | 50 UErrorCode error = U_ZERO_ERROR; |
51 int32_t actual_length = uloc_func(locale.c_str(), | 51 int32_t actual_length = uloc_func(locale.c_str(), |
52 WriteInto(&result, max_capacity), | 52 base::WriteInto(&result, max_capacity), |
53 max_capacity, | 53 max_capacity, |
54 &error); | 54 &error); |
55 DCHECK(U_SUCCESS(error)); | 55 DCHECK(U_SUCCESS(error)); |
56 DCHECK(actual_length < max_capacity); | 56 DCHECK(actual_length < max_capacity); |
57 result.resize(actual_length); | 57 result.resize(actual_length); |
58 return result; | 58 return result; |
59 } | 59 } |
60 | 60 |
61 ScopedJavaLocalRef<jobject> NewJavaLocale( | 61 ScopedJavaLocalRef<jobject> NewJavaLocale( |
62 JNIEnv* env, | 62 JNIEnv* env, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 ui::TimeFormat::FORMAT_REMAINING, ui::TimeFormat::LENGTH_SHORT, | 100 ui::TimeFormat::FORMAT_REMAINING, ui::TimeFormat::LENGTH_SHORT, |
101 base::TimeDelta::FromMilliseconds(timeInMillis))); | 101 base::TimeDelta::FromMilliseconds(timeInMillis))); |
102 return jtime_remaining.Release(); | 102 return jtime_remaining.Release(); |
103 } | 103 } |
104 | 104 |
105 bool RegisterLocalizationUtil(JNIEnv* env) { | 105 bool RegisterLocalizationUtil(JNIEnv* env) { |
106 return RegisterNativesImpl(env); | 106 return RegisterNativesImpl(env); |
107 } | 107 } |
108 | 108 |
109 } // namespace l10n_util | 109 } // namespace l10n_util |
OLD | NEW |