Chromium Code Reviews| 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..31cbfce9410c3f2c61ab525a03d7e16d9ea6e58d 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) { |
| + LOG(ERROR) << "Invalid country code: " << country_code; |
|
SteveT
2012/07/05 13:38:28
nit: Can we DVLOG instead? Or is this useful in re
Philippe
2012/07/05 14:27:40
We don't need that in release builds indeed. I mad
|
| + g_country_code_at_install = kCountryIDUnknown; |
| + } else { |
| + g_country_code_at_install = |
| + CountryCharsToCountryIDWithUpdate(country_code[0], country_code[1]); |
| + } |
| +} |
| + |
| +#endif |
| + |
| } // namespace TemplateURLPrepopulateData |