Commit 38b46138 authored by yfriedman's avatar yfriedman Committed by Commit bot

[Android] Simplify logic for grabbing initial country-code.

The old way involved start-up code reading a value and setting a global
in template_url_prepopulate_data. Since the value can be computed
on-demand from device-information, just fetch it as needed instead.

BUG=169106
TBR=thakis

Review URL: https://codereview.chromium.org/628263004

Cr-Commit-Position: refs/heads/master@{#300317}
parent 96a96053
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "android_webview/browser/aw_result_codes.h" #include "android_webview/browser/aw_result_codes.h"
#include "android_webview/native/aw_assets.h" #include "android_webview/native/aw_assets.h"
#include "base/android/build_info.h" #include "base/android/build_info.h"
#include "base/android/locale_utils.h"
#include "base/android/memory_pressure_listener_android.h" #include "base/android/memory_pressure_listener_android.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
...@@ -21,7 +22,6 @@ ...@@ -21,7 +22,6 @@
#include "net/android/network_change_notifier_factory_android.h" #include "net/android/network_change_notifier_factory_android.h"
#include "net/base/network_change_notifier.h" #include "net/base/network_change_notifier.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_android.h"
#include "ui/base/layout.h" #include "ui/base/layout.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_paths.h"
...@@ -57,7 +57,7 @@ int AwBrowserMainParts::PreCreateThreads() { ...@@ -57,7 +57,7 @@ int AwBrowserMainParts::PreCreateThreads() {
// ResourceBundle/GetApplicationLocale to not require an instance to be // ResourceBundle/GetApplicationLocale to not require an instance to be
// initialized. // initialized.
ui::ResourceBundle::InitSharedInstanceWithLocale( ui::ResourceBundle::InitSharedInstanceWithLocale(
l10n_util::GetDefaultLocale(), base::android::GetDefaultLocale(),
NULL, NULL,
ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
std::string locale = l10n_util::GetApplicationLocale(std::string()) + ".pak"; std::string locale = l10n_util::GetApplicationLocale(std::string()) + ".pak";
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h" #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h"
#include "android_webview/common/render_view_messages.h" #include "android_webview/common/render_view_messages.h"
#include "android_webview/common/url_constants.h" #include "android_webview/common/url_constants.h"
#include "base/android/locale_utils.h"
#include "base/base_paths_android.h" #include "base/base_paths_android.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "components/cdm/browser/cdm_message_filter_android.h" #include "components/cdm/browser/cdm_message_filter_android.h"
...@@ -34,7 +35,6 @@ ...@@ -34,7 +35,6 @@
#include "net/android/network_library.h" #include "net/android/network_library.h"
#include "net/ssl/ssl_cert_request_info.h" #include "net/ssl/ssl_cert_request_info.h"
#include "net/ssl/ssl_info.h" #include "net/ssl/ssl_info.h"
#include "ui/base/l10n/l10n_util_android.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/resources/grit/ui_resources.h" #include "ui/resources/grit/ui_resources.h"
...@@ -155,7 +155,7 @@ void CancelProtectedMediaIdentifierPermissionRequests( ...@@ -155,7 +155,7 @@ void CancelProtectedMediaIdentifierPermissionRequests(
std::string AwContentBrowserClient::GetAcceptLangsImpl() { std::string AwContentBrowserClient::GetAcceptLangsImpl() {
// Start with the currnet locale. // Start with the currnet locale.
std::string langs = l10n_util::GetDefaultLocale(); std::string langs = base::android::GetDefaultLocale();
// If we're not en-US, add in en-US which will be // If we're not en-US, add in en-US which will be
// used with a lower q-value. // used with a lower q-value.
...@@ -259,7 +259,7 @@ void AwContentBrowserClient::AppendExtraCommandLineSwitches( ...@@ -259,7 +259,7 @@ void AwContentBrowserClient::AppendExtraCommandLineSwitches(
} }
std::string AwContentBrowserClient::GetApplicationLocale() { std::string AwContentBrowserClient::GetApplicationLocale() {
return l10n_util::GetDefaultLocale(); return base::android::GetDefaultLocale();
} }
std::string AwContentBrowserClient::GetAcceptLangs( std::string AwContentBrowserClient::GetAcceptLangs(
......
...@@ -3,12 +3,13 @@ ...@@ -3,12 +3,13 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "android_webview/browser/aw_form_database_service.h" #include "android_webview/browser/aw_form_database_service.h"
#include "base/android/locale_utils.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "components/autofill/core/browser/webdata/autofill_table.h" #include "components/autofill/core/browser/webdata/autofill_table.h"
#include "components/webdata/common/webdata_constants.h" #include "components/webdata/common/webdata_constants.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "ui/base/l10n/l10n_util_android.h"
using base::WaitableEvent; using base::WaitableEvent;
using content::BrowserThread; using content::BrowserThread;
...@@ -32,7 +33,7 @@ AwFormDatabaseService::AwFormDatabaseService(const base::FilePath path) { ...@@ -32,7 +33,7 @@ AwFormDatabaseService::AwFormDatabaseService(const base::FilePath path) {
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)); BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB));
web_database_->AddTable( web_database_->AddTable(
scoped_ptr<WebDatabaseTable>(new autofill::AutofillTable( scoped_ptr<WebDatabaseTable>(new autofill::AutofillTable(
l10n_util::GetDefaultLocale()))); base::android::GetDefaultLocale())));
web_database_->LoadDatabase(); web_database_->LoadDatabase();
autofill_data_ = new autofill::AutofillWebDataService( autofill_data_ = new autofill::AutofillWebDataService(
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/android/jni_array.h" #include "base/android/jni_array.h"
#include "base/android/jni_string.h" #include "base/android/jni_string.h"
#include "base/android/locale_utils.h"
#include "base/android/scoped_java_ref.h" #include "base/android/scoped_java_ref.h"
#include "base/atomicops.h" #include "base/atomicops.h"
#include "base/bind.h" #include "base/bind.h"
...@@ -62,7 +63,6 @@ ...@@ -62,7 +63,6 @@
#include "net/base/auth.h" #include "net/base/auth.h"
#include "net/cert/x509_certificate.h" #include "net/cert/x509_certificate.h"
#include "third_party/skia/include/core/SkPicture.h" #include "third_party/skia/include/core/SkPicture.h"
#include "ui/base/l10n/l10n_util_android.h"
#include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/android/java_bitmap.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "ui/gfx/size.h" #include "ui/gfx/size.h"
...@@ -252,7 +252,7 @@ void AwContents::InitAutofillIfNecessary(bool enabled) { ...@@ -252,7 +252,7 @@ void AwContents::InitAutofillIfNecessary(bool enabled) {
ContentAutofillDriver::CreateForWebContentsAndDelegate( ContentAutofillDriver::CreateForWebContentsAndDelegate(
web_contents, web_contents,
AwAutofillClient::FromWebContents(web_contents), AwAutofillClient::FromWebContents(web_contents),
l10n_util::GetDefaultLocale(), base::android::GetDefaultLocale(),
AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER); AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER);
} }
......
...@@ -39,6 +39,8 @@ component("base") { ...@@ -39,6 +39,8 @@ component("base") {
"android/fifo_utils.h", "android/fifo_utils.h",
"android/important_file_writer_android.cc", "android/important_file_writer_android.cc",
"android/important_file_writer_android.h", "android/important_file_writer_android.h",
"android/locale_utils.cc",
"android/locale_utils.h",
"android/scoped_java_ref.cc", "android/scoped_java_ref.cc",
"android/scoped_java_ref.h", "android/scoped_java_ref.h",
"android/jni_android.cc", "android/jni_android.cc",
...@@ -1398,6 +1400,7 @@ if (is_android) { ...@@ -1398,6 +1400,7 @@ if (is_android) {
"android/java/src/org/chromium/base/ImportantFileWriterAndroid.java", "android/java/src/org/chromium/base/ImportantFileWriterAndroid.java",
"android/java/src/org/chromium/base/JNIUtils.java", "android/java/src/org/chromium/base/JNIUtils.java",
"android/java/src/org/chromium/base/library_loader/LibraryLoader.java", "android/java/src/org/chromium/base/library_loader/LibraryLoader.java",
"android/java/src/org/chromium/base/LocaleUtils.java",
"android/java/src/org/chromium/base/MemoryPressureListener.java", "android/java/src/org/chromium/base/MemoryPressureListener.java",
"android/java/src/org/chromium/base/JavaHandlerThread.java", "android/java/src/org/chromium/base/JavaHandlerThread.java",
"android/java/src/org/chromium/base/PathService.java", "android/java/src/org/chromium/base/PathService.java",
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/android/jni_registrar.h" #include "base/android/jni_registrar.h"
#include "base/android/jni_utils.h" #include "base/android/jni_utils.h"
#include "base/android/locale_utils.h"
#include "base/android/memory_pressure_listener_android.h" #include "base/android/memory_pressure_listener_android.h"
#include "base/android/path_service_android.h" #include "base/android/path_service_android.h"
#include "base/android/path_utils.h" #include "base/android/path_utils.h"
...@@ -42,6 +43,7 @@ static RegistrationMethod kBaseRegisteredMethods[] = { ...@@ -42,6 +43,7 @@ static RegistrationMethod kBaseRegisteredMethods[] = {
{ "ImportantFileWriterAndroid", { "ImportantFileWriterAndroid",
base::android::RegisterImportantFileWriterAndroid }, base::android::RegisterImportantFileWriterAndroid },
{ "JNIUtils", base::android::RegisterJNIUtils }, { "JNIUtils", base::android::RegisterJNIUtils },
{ "LocaleUtils", base::android::RegisterLocaleUtils },
{ "MemoryPressureListenerAndroid", { "MemoryPressureListenerAndroid",
base::android::MemoryPressureListenerAndroid::Register }, base::android::MemoryPressureListenerAndroid::Register },
{ "JavaHandlerThread", base::android::JavaHandlerThread::RegisterBindings }, { "JavaHandlerThread", base::android::JavaHandlerThread::RegisterBindings },
......
...@@ -23,6 +23,9 @@ public abstract class BaseSwitches { ...@@ -23,6 +23,9 @@ public abstract class BaseSwitches {
// Adds additional thread idle time information into the trace event output. // Adds additional thread idle time information into the trace event output.
public static final String ENABLE_IDLE_TRACING = "enable-idle-tracing"; public static final String ENABLE_IDLE_TRACING = "enable-idle-tracing";
// Default country code to be used for search engine localization.
public static final String DEFAULT_COUNTRY_CODE_AT_INSTALL = "default-country-code";
// Prevent instantiation. // Prevent instantiation.
private BaseSwitches() {} private BaseSwitches() {}
} }
...@@ -20,6 +20,7 @@ public class LocaleUtils { ...@@ -20,6 +20,7 @@ public class LocaleUtils {
* @return the default locale, translating Android deprecated * @return the default locale, translating Android deprecated
* language codes into the modern ones used by Chromium. * language codes into the modern ones used by Chromium.
*/ */
@CalledByNative
public static String getDefaultLocale() { public static String getDefaultLocale() {
Locale locale = Locale.getDefault(); Locale locale = Locale.getDefault();
String language = locale.getLanguage(); String language = locale.getLanguage();
...@@ -38,4 +39,17 @@ public class LocaleUtils { ...@@ -38,4 +39,17 @@ public class LocaleUtils {
} }
return country.isEmpty() ? language : language + "-" + country; return country.isEmpty() ? language : language + "-" + country;
} }
/**
* Get the default country code set during install.
* @return country code.
*/
@CalledByNative
private static String getDefaultCountryCode() {
CommandLine commandLine = CommandLine.getInstance();
return commandLine.hasSwitch(BaseSwitches.DEFAULT_COUNTRY_CODE_AT_INSTALL) ?
commandLine.getSwitchValue(BaseSwitches.DEFAULT_COUNTRY_CODE_AT_INSTALL) :
Locale.getDefault().getCountry();
}
} }
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/android/locale_utils.h"
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "jni/LocaleUtils_jni.h"
namespace base {
namespace android {
std::string GetDefaultCountryCode() {
JNIEnv* env = base::android::AttachCurrentThread();
return ConvertJavaStringToUTF8(Java_LocaleUtils_getDefaultCountryCode(env));
}
std::string GetDefaultLocale() {
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jstring> locale = Java_LocaleUtils_getDefaultLocale(
env);
return ConvertJavaStringToUTF8(locale);
}
bool RegisterLocaleUtils(JNIEnv* env) {
return RegisterNativesImpl(env);
}
} // namespace android
} // namespace base
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_ANDROID_LOCALE_UTILS_H_
#define BASE_ANDROID_LOCALE_UTILS_H_
#include <jni.h>
#include <string>
#include "base/base_export.h"
namespace base {
namespace android {
BASE_EXPORT std::string GetDefaultCountryCode();
// Return the current default locale of the device.
BASE_EXPORT std::string GetDefaultLocale();
BASE_EXPORT bool RegisterLocaleUtils(JNIEnv* env);
} // namespace android
} // namespace base
#endif // BASE_ANDROID_LOCALE_UTILS_H_
...@@ -1276,6 +1276,7 @@ ...@@ -1276,6 +1276,7 @@
'android/java/src/org/chromium/base/ImportantFileWriterAndroid.java', 'android/java/src/org/chromium/base/ImportantFileWriterAndroid.java',
'android/java/src/org/chromium/base/JNIUtils.java', 'android/java/src/org/chromium/base/JNIUtils.java',
'android/java/src/org/chromium/base/library_loader/LibraryLoader.java', 'android/java/src/org/chromium/base/library_loader/LibraryLoader.java',
'android/java/src/org/chromium/base/LocaleUtils.java',
'android/java/src/org/chromium/base/MemoryPressureListener.java', 'android/java/src/org/chromium/base/MemoryPressureListener.java',
'android/java/src/org/chromium/base/JavaHandlerThread.java', 'android/java/src/org/chromium/base/JavaHandlerThread.java',
'android/java/src/org/chromium/base/PathService.java', 'android/java/src/org/chromium/base/PathService.java',
......
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
'android/fifo_utils.h', 'android/fifo_utils.h',
'android/important_file_writer_android.cc', 'android/important_file_writer_android.cc',
'android/important_file_writer_android.h', 'android/important_file_writer_android.h',
'android/locale_utils.h',
'android/locale_utils.cc',
'android/scoped_java_ref.cc', 'android/scoped_java_ref.cc',
'android/scoped_java_ref.h', 'android/scoped_java_ref.h',
'android/jni_android.cc', 'android/jni_android.cc',
......
...@@ -6,9 +6,6 @@ ...@@ -6,9 +6,6 @@
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/android/jni_registrar.h" #include "base/android/jni_registrar.h"
#include "components/search_engines/template_url_prepopulate_data.h"
static const char kDefaultCountryCode[] = "US";
ChromeMainDelegateAndroid* ChromeMainDelegateAndroid::Create() { ChromeMainDelegateAndroid* ChromeMainDelegateAndroid::Create() {
return new ChromeMainDelegateChromeShellAndroid(); return new ChromeMainDelegateChromeShellAndroid();
...@@ -22,7 +19,6 @@ ChromeMainDelegateChromeShellAndroid::~ChromeMainDelegateChromeShellAndroid() { ...@@ -22,7 +19,6 @@ ChromeMainDelegateChromeShellAndroid::~ChromeMainDelegateChromeShellAndroid() {
bool ChromeMainDelegateChromeShellAndroid::BasicStartupComplete( bool ChromeMainDelegateChromeShellAndroid::BasicStartupComplete(
int* exit_code) { int* exit_code) {
TemplateURLPrepopulateData::InitCountryCode(kDefaultCountryCode);
return ChromeMainDelegateAndroid::BasicStartupComplete(exit_code); return ChromeMainDelegateAndroid::BasicStartupComplete(exit_code);
} }
...@@ -6,11 +6,8 @@ ...@@ -6,11 +6,8 @@
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/android/jni_registrar.h" #include "base/android/jni_registrar.h"
#include "components/search_engines/template_url_prepopulate_data.h"
#include "sync/test/fake_server/android/fake_server_helper_android.h" #include "sync/test/fake_server/android/fake_server_helper_android.h"
static const char kDefaultCountryCode[] = "US";
ChromeMainDelegateAndroid* ChromeMainDelegateAndroid::Create() { ChromeMainDelegateAndroid* ChromeMainDelegateAndroid::Create() {
return new ChromeMainDelegateChromeSyncShellAndroid(); return new ChromeMainDelegateChromeSyncShellAndroid();
} }
...@@ -32,7 +29,6 @@ ChromeMainDelegateChromeSyncShellAndroid::RegisterApplicationNativeMethods( ...@@ -32,7 +29,6 @@ ChromeMainDelegateChromeSyncShellAndroid::RegisterApplicationNativeMethods(
bool ChromeMainDelegateChromeSyncShellAndroid::BasicStartupComplete( bool ChromeMainDelegateChromeSyncShellAndroid::BasicStartupComplete(
int* exit_code) { int* exit_code) {
TemplateURLPrepopulateData::InitCountryCode(kDefaultCountryCode);
return ChromeMainDelegateAndroid::BasicStartupComplete(exit_code); return ChromeMainDelegateAndroid::BasicStartupComplete(exit_code);
} }
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/search_engines/search_terms_data.h" #include "components/search_engines/search_terms_data.h"
#include "components/search_engines/template_url.h" #include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_prepopulate_data.h"
#include "components/search_engines/template_url_service.h" #include "components/search_engines/template_url_service.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/test/mock_render_process_host.h" #include "content/public/test/mock_render_process_host.h"
...@@ -154,10 +153,6 @@ SearchProviderInstallDataTest::SearchProviderInstallDataTest() ...@@ -154,10 +153,6 @@ SearchProviderInstallDataTest::SearchProviderInstallDataTest()
void SearchProviderInstallDataTest::SetUp() { void SearchProviderInstallDataTest::SetUp() {
testing::Test::SetUp(); testing::Test::SetUp();
#if defined(OS_ANDROID)
TemplateURLPrepopulateData::InitCountryCode(
std::string() /* unknown country code */);
#endif
process_.reset(new content::MockRenderProcessHost(util_.profile())); process_.reset(new content::MockRenderProcessHost(util_.profile()));
install_data_ = new SearchProviderInstallData( install_data_ = new SearchProviderInstallData(
util_.model(), SearchTermsData().GoogleBaseURLValue(), NULL, util_.model(), SearchTermsData().GoogleBaseURLValue(), NULL,
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "components/omnibox/autocomplete_provider.h" #include "components/omnibox/autocomplete_provider.h"
#include "components/omnibox/omnibox_field_trial.h" #include "components/omnibox/omnibox_field_trial.h"
#include "components/omnibox/test_scheme_classifier.h" #include "components/omnibox/test_scheme_classifier.h"
#include "components/search_engines/template_url_prepopulate_data.h"
#include "components/search_engines/template_url_service.h" #include "components/search_engines/template_url_service.h"
#include "components/variations/entropy_provider.h" #include "components/variations/entropy_provider.h"
#include "components/variations/variations_associated_data.h" #include "components/variations/variations_associated_data.h"
...@@ -90,10 +89,6 @@ class AutocompleteResultTest : public testing::Test { ...@@ -90,10 +89,6 @@ class AutocompleteResultTest : public testing::Test {
} }
virtual void SetUp() override { virtual void SetUp() override {
#if defined(OS_ANDROID)
TemplateURLPrepopulateData::InitCountryCode(
std::string() /* unknown country code */);
#endif
template_url_service_.reset(new TemplateURLService(NULL, 0)); template_url_service_.reset(new TemplateURLService(NULL, 0));
template_url_service_->Load(); template_url_service_->Load();
} }
......
...@@ -15,6 +15,7 @@ include_rules = [ ...@@ -15,6 +15,7 @@ include_rules = [
"+policy", "+policy",
"+sql", "+sql",
"+sync", "+sync",
"+ui/base",
"+ui/gfx", "+ui/gfx",
] ]
......
...@@ -29,6 +29,10 @@ ...@@ -29,6 +29,10 @@
#include "base/mac/scoped_cftyperef.h" #include "base/mac/scoped_cftyperef.h"
#endif #endif
#if defined(OS_ANDROID)
#include "base/android/locale_utils.h"
#endif
namespace TemplateURLPrepopulateData { namespace TemplateURLPrepopulateData {
...@@ -621,11 +625,11 @@ int GetCurrentCountryID() { ...@@ -621,11 +625,11 @@ int GetCurrentCountryID() {
#elif defined(OS_ANDROID) #elif defined(OS_ANDROID)
// Initialized by InitCountryCode().
int g_country_code_at_install = kCountryIDUnknown;
int GetCurrentCountryID() { int GetCurrentCountryID() {
return g_country_code_at_install; const std::string& country_code = base::android::GetDefaultCountryCode();
return (country_code.size() == 2) ?
CountryCharsToCountryIDWithUpdate(country_code[0], country_code[1]) :
kCountryIDUnknown;
} }
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
...@@ -1186,18 +1190,6 @@ bool SameDomain(const GURL& given_url, const GURL& prepopulated_url) { ...@@ -1186,18 +1190,6 @@ bool SameDomain(const GURL& given_url, const GURL& prepopulated_url) {
// Global functions ----------------------------------------------------------- // Global functions -----------------------------------------------------------
#if defined(OS_ANDROID)
void InitCountryCode(const std::string& country_code) {
if (country_code.size() != 2) {
DLOG(ERROR) << "Invalid country code: " << country_code;
g_country_code_at_install = kCountryIDUnknown;
} else {
g_country_code_at_install =
CountryCharsToCountryIDWithUpdate(country_code[0], country_code[1]);
}
}
#endif
void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterIntegerPref( registry->RegisterIntegerPref(
prefs::kCountryIDAtInstall, prefs::kCountryIDAtInstall,
......
...@@ -29,12 +29,6 @@ namespace TemplateURLPrepopulateData { ...@@ -29,12 +29,6 @@ namespace TemplateURLPrepopulateData {
extern const int kMaxPrepopulatedEngineID; extern const int kMaxPrepopulatedEngineID;
#if defined(OS_ANDROID)
// This must be called early only once. |country_code| is the country code at
// install following the ISO-3166 specification.
void InitCountryCode(const std::string& country_code);
#endif
void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
// Returns the current version of the prepopulate data, so callers can know when // Returns the current version of the prepopulate data, so callers can know when
......
...@@ -10,6 +10,7 @@ import android.os.Bundle; ...@@ -10,6 +10,7 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import org.chromium.base.CommandLine;
import org.chromium.base.PathUtils; import org.chromium.base.PathUtils;
import org.chromium.base.PowerMonitor; import org.chromium.base.PowerMonitor;
import org.chromium.base.ResourceExtractor; import org.chromium.base.ResourceExtractor;
...@@ -29,6 +30,8 @@ public class ChromeNativeTestActivity extends Activity { ...@@ -29,6 +30,8 @@ public class ChromeNativeTestActivity extends Activity {
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
CommandLine.init(new String[]{});
// Needed by path_utils_unittest.cc // Needed by path_utils_unittest.cc
PathUtils.setPrivateDataDirectorySuffix("chrome"); PathUtils.setPrivateDataDirectorySuffix("chrome");
......
...@@ -11,7 +11,6 @@ import org.chromium.base.ApiCompatibilityUtils; ...@@ -11,7 +11,6 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ApplicationStatus; import org.chromium.base.ApplicationStatus;
import org.chromium.base.CalledByNative; import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace; import org.chromium.base.JNINamespace;
import org.chromium.base.LocaleUtils;
import java.util.Locale; import java.util.Locale;
...@@ -30,16 +29,6 @@ public class LocalizationUtils { ...@@ -30,16 +29,6 @@ public class LocalizationUtils {
private LocalizationUtils() { /* cannot be instantiated */ } private LocalizationUtils() { /* cannot be instantiated */ }
/**
* @return the default locale, translating Android deprecated
* language codes into the modern ones used by Chromium.
*/
@CalledByNative
public static String getDefaultLocale() {
// TODO(vivekg): Native callers should use LocaleUtils directly instead of the redirection.
return LocaleUtils.getDefaultLocale();
}
@CalledByNative @CalledByNative
private static Locale getJavaLocale(String language, String country, String variant) { private static Locale getJavaLocale(String language, String country, String variant) {
return new Locale(language, country, variant); return new Locale(language, country, variant);
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_paths.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "base/android/locale_utils.h"
#include "ui/base/l10n/l10n_util_android.h" #include "ui/base/l10n/l10n_util_android.h"
#endif #endif
...@@ -447,7 +448,7 @@ std::string GetApplicationLocaleInternal(const std::string& pref_locale) { ...@@ -447,7 +448,7 @@ std::string GetApplicationLocaleInternal(const std::string& pref_locale) {
#elif defined(OS_ANDROID) #elif defined(OS_ANDROID)
// On Android, query java.util.Locale for the default locale. // On Android, query java.util.Locale for the default locale.
candidates.push_back(GetDefaultLocale()); candidates.push_back(base::android::GetDefaultLocale());
#elif defined(USE_GLIB) && !defined(OS_CHROMEOS) #elif defined(USE_GLIB) && !defined(OS_CHROMEOS)
......
...@@ -23,13 +23,6 @@ jint GetFirstStrongCharacterDirection(JNIEnv* env, jclass clazz, ...@@ -23,13 +23,6 @@ jint GetFirstStrongCharacterDirection(JNIEnv* env, jclass clazz,
base::android::ConvertJavaStringToUTF16(env, string)); base::android::ConvertJavaStringToUTF16(env, string));
} }
std::string GetDefaultLocale() {
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jstring> locale = Java_LocalizationUtils_getDefaultLocale(
env);
return ConvertJavaStringToUTF8(locale);
}
bool IsLayoutRtl() { bool IsLayoutRtl() {
static bool is_layout_rtl_cached = false; static bool is_layout_rtl_cached = false;
static bool layout_rtl_cache; static bool layout_rtl_cache;
......
...@@ -14,9 +14,6 @@ ...@@ -14,9 +14,6 @@
namespace l10n_util { namespace l10n_util {
// Return the current default locale of the device.
UI_BASE_EXPORT std::string GetDefaultLocale();
UI_BASE_EXPORT base::string16 GetDisplayNameForLocale( UI_BASE_EXPORT base::string16 GetDisplayNameForLocale(
const std::string& locale, const std::string& locale,
const std::string& display_locale); const std::string& display_locale);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment