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

Unified Diff: chrome/browser/search_engines/template_url_prepopulate_data.cc

Issue 10697087: Remove content->app dependency in template_url_prepopulate_data.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Steve's comment Created 8 years, 5 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
« no previous file with comments | « chrome/browser/search_engines/template_url_prepopulate_data.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search_engines/template_url_prepopulate_data.cc
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.cc b/chrome/browser/search_engines/template_url_prepopulate_data.cc
index 77c4fcd5bc7a6b43b1006fe2970eaeddae70923f..27988bea72207976ddbe03965f38abc15d8ee75c 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc
@@ -9,6 +9,7 @@
#endif
#include "base/command_line.h"
+#include "base/logging.h"
#include "base/memory/scoped_vector.h"
#include "base/string16.h"
#include "base/string_piece.h"
@@ -2722,6 +2723,7 @@ const PrepopulatedEngine* kAllEngines[] =
// value we call the CountryID.
const int kCountryIDUnknown = -1;
+const int kCountryIDNotSet = 0;
inline int CountryCharsToCountryID(char c1, char c2) {
return c1 << 8 | c2;
@@ -2829,12 +2831,12 @@ int GetCurrentCountryID() {
#elif defined(OS_ANDROID)
+// Initialized by InitCountryCode().
+int g_country_code_at_install = kCountryIDNotSet;
+
int GetCurrentCountryID() {
- const std::string country_code_at_install =
- TemplateURLPrepopulateData::GetCountryCodeAtInstall();
- return country_code_at_install.empty() ? kCountryIDUnknown :
- CountryCharsToCountryIDWithUpdate(country_code_at_install[0],
- country_code_at_install[1]);
+ DCHECK(g_country_code_at_install != kCountryIDNotSet);
+ return g_country_code_at_install;
}
#elif defined(OS_POSIX)
@@ -3445,4 +3447,18 @@ SearchEngineType GetEngineType(const std::string& url) {
return SEARCH_ENGINE_OTHER;
}
+#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
+
} // namespace TemplateURLPrepopulateData
« no previous file with comments | « chrome/browser/search_engines/template_url_prepopulate_data.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698