Chromium Code Reviews| Index: components/search_engines/template_url_prepopulate_data.cc |
| diff --git a/components/search_engines/template_url_prepopulate_data.cc b/components/search_engines/template_url_prepopulate_data.cc |
| index e63a58c0cb62097a8d54a21ea9e8078818acac7e..6858b6fdd314960dd9d0710ced262f8ca8331a51 100644 |
| --- a/components/search_engines/template_url_prepopulate_data.cc |
| +++ b/components/search_engines/template_url_prepopulate_data.cc |
| @@ -29,6 +29,10 @@ |
| #include "base/mac/scoped_cftyperef.h" |
| #endif |
| +#if defined(OS_ANDROID) |
| +#include "ui/base/l10n/l10n_util_android.h" |
| +#endif |
| + |
| namespace TemplateURLPrepopulateData { |
| @@ -621,11 +625,14 @@ int GetCurrentCountryID() { |
| #elif defined(OS_ANDROID) |
| -// Initialized by InitCountryCode(). |
| -int g_country_code_at_install = kCountryIDUnknown; |
| - |
| int GetCurrentCountryID() { |
| - return g_country_code_at_install; |
| + const std::string& country_code = l10n_util::GetDefaultCountryCode(); |
|
newt (away)
2014/10/06 18:36:48
Is it worth caching this value?
Peter Kasting
2014/10/06 20:28:27
No. This is called at most once per run, I believ
Yaron
2014/10/08 00:08:54
Agreed. Nobody else is caching these calls either
|
| + if (country_code.size() != 2) { |
| + DLOG(ERROR) << "Invalid country code: " << country_code; |
|
Peter Kasting
2014/10/06 20:28:27
Unless you have a concrete plan to retrieve and ac
Yaron
2014/10/08 00:08:54
it's not new (moved from below) but removed
Peter Kasting
2014/10/08 00:23:08
So is it actually possible for this to return anyt
Yaron
2014/10/17 18:24:00
I think it's possible, especially in the context o
|
| + return kCountryIDUnknown; |
| + } else { |
| + return CountryCharsToCountryIDWithUpdate(country_code[0], country_code[1]); |
| + } |
| } |
| #elif defined(OS_POSIX) |
| @@ -1186,18 +1193,6 @@ bool SameDomain(const GURL& given_url, const GURL& prepopulated_url) { |
| // 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) { |
| registry->RegisterIntegerPref( |
| prefs::kCountryIDAtInstall, |