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

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: 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..35e2fd1fce89326457548319028786905d1c630f 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 "base/android/locale_utils.h"
+#endif
+
namespace TemplateURLPrepopulateData {
@@ -621,11 +625,11 @@ 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 = base::android::GetDefaultCountryCode();
+ return (country_code.size() == 2) ?
+ CountryCharsToCountryIDWithUpdate(country_code[0], country_code[1]) :
+ kCountryIDUnknown;
}
#elif defined(OS_POSIX)
@@ -1186,18 +1190,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