| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/search_engines/template_url_prepopulate_data.h" | 5 #include "components/search_engines/template_url_prepopulate_data.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 7 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 8 #include <locale.h> | 8 #include <locale.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 if (default_search_provider_index) | 1035 if (default_search_provider_index) |
| 1036 *default_search_provider_index = 0; | 1036 *default_search_provider_index = 0; |
| 1037 std::vector<std::unique_ptr<TemplateURLData>> t_urls = | 1037 std::vector<std::unique_ptr<TemplateURLData>> t_urls = |
| 1038 GetPrepopulatedTemplateURLData(prefs); | 1038 GetPrepopulatedTemplateURLData(prefs); |
| 1039 if (!t_urls.empty()) | 1039 if (!t_urls.empty()) |
| 1040 return t_urls; | 1040 return t_urls; |
| 1041 | 1041 |
| 1042 return GetPrepopulationSetFromCountryID(GetCountryIDFromPrefs(prefs)); | 1042 return GetPrepopulationSetFromCountryID(GetCountryIDFromPrefs(prefs)); |
| 1043 } | 1043 } |
| 1044 | 1044 |
| 1045 std::unique_ptr<TemplateURLData> GetPrepopulatedEngine(PrefService* prefs, |
| 1046 int prepopulated_id) { |
| 1047 size_t default_index; |
| 1048 auto engines = |
| 1049 TemplateURLPrepopulateData::GetPrepopulatedEngines(prefs, &default_index); |
| 1050 for (auto& engine : engines) { |
| 1051 if (engine->prepopulate_id == prepopulated_id) |
| 1052 return std::move(engine); |
| 1053 } |
| 1054 return nullptr; |
| 1055 } |
| 1056 |
| 1045 #if defined(OS_ANDROID) | 1057 #if defined(OS_ANDROID) |
| 1046 | 1058 |
| 1047 std::vector<std::unique_ptr<TemplateURLData>> GetLocalPrepopulatedEngines( | 1059 std::vector<std::unique_ptr<TemplateURLData>> GetLocalPrepopulatedEngines( |
| 1048 const std::string& locale, | 1060 const std::string& locale, |
| 1049 PrefService* prefs) { | 1061 PrefService* prefs) { |
| 1050 int country_id = CountryStringToCountryID(locale); | 1062 int country_id = CountryStringToCountryID(locale); |
| 1051 if (country_id == kCountryIDUnknown || | 1063 if (country_id == kCountryIDUnknown || |
| 1052 country_id == GetCountryIDFromPrefs(prefs)) { | 1064 country_id == GetCountryIDFromPrefs(prefs)) { |
| 1053 return std::vector<std::unique_ptr<TemplateURLData>>(); | 1065 return std::vector<std::unique_ptr<TemplateURLData>>(); |
| 1054 } | 1066 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 locale_str.erase(0, territory_delim + 1); | 1173 locale_str.erase(0, territory_delim + 1); |
| 1162 | 1174 |
| 1163 // Next remove any codeset/modifier portion and uppercase. | 1175 // Next remove any codeset/modifier portion and uppercase. |
| 1164 return CountryStringToCountryID( | 1176 return CountryStringToCountryID( |
| 1165 base::ToUpperASCII(locale_str.substr(0, locale_str.find_first_of(".@")))); | 1177 base::ToUpperASCII(locale_str.substr(0, locale_str.find_first_of(".@")))); |
| 1166 } | 1178 } |
| 1167 | 1179 |
| 1168 #endif // OS_* | 1180 #endif // OS_* |
| 1169 | 1181 |
| 1170 } // namespace TemplateURLPrepopulateData | 1182 } // namespace TemplateURLPrepopulateData |
| OLD | NEW |