Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: ui/base/l10n/l10n_util_android.cc

Issue 628263004: [Android] Simplify logic for grabbing initial country-code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 base::android::ConvertJavaStringToUTF16(env, string)); 23 base::android::ConvertJavaStringToUTF16(env, string));
24 } 24 }
25 25
26 std::string GetDefaultLocale() { 26 std::string GetDefaultLocale() {
27 JNIEnv* env = base::android::AttachCurrentThread(); 27 JNIEnv* env = base::android::AttachCurrentThread();
28 ScopedJavaLocalRef<jstring> locale = Java_LocalizationUtils_getDefaultLocale( 28 ScopedJavaLocalRef<jstring> locale = Java_LocalizationUtils_getDefaultLocale(
29 env); 29 env);
30 return ConvertJavaStringToUTF8(locale); 30 return ConvertJavaStringToUTF8(locale);
31 } 31 }
32 32
33 std::string GetDefaultCountryCode() {
34 JNIEnv* env = base::android::AttachCurrentThread();
35 return ConvertJavaStringToUTF8(
36 Java_LocalizationUtils_getDefaultCountryCode(env));
37 }
38
33 bool IsLayoutRtl() { 39 bool IsLayoutRtl() {
34 static bool is_layout_rtl_cached = false; 40 static bool is_layout_rtl_cached = false;
35 static bool layout_rtl_cache; 41 static bool layout_rtl_cache;
36 42
37 if (!is_layout_rtl_cached) { 43 if (!is_layout_rtl_cached) {
38 is_layout_rtl_cached = true; 44 is_layout_rtl_cached = true;
39 JNIEnv* env = base::android::AttachCurrentThread(); 45 JNIEnv* env = base::android::AttachCurrentThread();
40 layout_rtl_cache = 46 layout_rtl_cache =
41 static_cast<bool>(Java_LocalizationUtils_isLayoutRtl(env)); 47 static_cast<bool>(Java_LocalizationUtils_isLayoutRtl(env));
42 } 48 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 ui::TimeFormat::FORMAT_REMAINING, ui::TimeFormat::LENGTH_SHORT, 113 ui::TimeFormat::FORMAT_REMAINING, ui::TimeFormat::LENGTH_SHORT,
108 base::TimeDelta::FromMilliseconds(timeInMillis))); 114 base::TimeDelta::FromMilliseconds(timeInMillis)));
109 return jtime_remaining.Release(); 115 return jtime_remaining.Release();
110 } 116 }
111 117
112 bool RegisterLocalizationUtil(JNIEnv* env) { 118 bool RegisterLocalizationUtil(JNIEnv* env) {
113 return RegisterNativesImpl(env); 119 return RegisterNativesImpl(env);
114 } 120 }
115 121
116 } // namespace l10n_util 122 } // namespace l10n_util
OLDNEW
« ui/base/l10n/l10n_util_android.h ('K') | « ui/base/l10n/l10n_util_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698