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

Unified Diff: components/search_engines/template_url_prepopulate_data.cc

Issue 628263004: [Android] Simplify logic for grabbing initial country-code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
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,

Powered by Google App Engine
This is Rietveld 408576698