| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/search_engines/template_url_prepopulate_data.h" | 5 #include "chrome/browser/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 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 IDR_SEARCH_ENGINE_LOGO_GOO, | 1175 IDR_SEARCH_ENGINE_LOGO_GOO, |
| 1176 23, | 1176 23, |
| 1177 }; | 1177 }; |
| 1178 | 1178 |
| 1179 const PrepopulatedEngine google = { | 1179 const PrepopulatedEngine google = { |
| 1180 L"Google", | 1180 L"Google", |
| 1181 NULL, | 1181 NULL, |
| 1182 "http://www.google.com/favicon.ico", | 1182 "http://www.google.com/favicon.ico", |
| 1183 L"{google:baseURL}search?{google:RLZ}{google:acceptedSuggestion}" | 1183 L"{google:baseURL}search?{google:RLZ}{google:acceptedSuggestion}" |
| 1184 L"{google:originalQueryForSuggestion}{google:searchFieldtrialParameter}" | 1184 L"{google:originalQueryForSuggestion}{google:searchFieldtrialParameter}" |
| 1185 L"{instantFieldTrialGroupParameter}" |
| 1185 L"sourceid=chrome&ie={inputEncoding}&q={searchTerms}", | 1186 L"sourceid=chrome&ie={inputEncoding}&q={searchTerms}", |
| 1186 "UTF-8", | 1187 "UTF-8", |
| 1187 L"{google:baseSuggestURL}search?{google:searchFieldtrialParameter}" | 1188 L"{google:baseSuggestURL}search?{google:searchFieldtrialParameter}" |
| 1189 L"{instantFieldTrialGroupParameter}" |
| 1188 L"client=chrome&hl={language}&q={searchTerms}", | 1190 L"client=chrome&hl={language}&q={searchTerms}", |
| 1189 L"{google:baseURL}webhp?{google:RLZ}sourceid=chrome-instant" | 1191 L"{google:baseURL}webhp?{google:RLZ}sourceid=chrome-instant&" |
| 1190 L"&ie={inputEncoding}&ion=1{searchTerms}&nord=1", | 1192 L"{instantFieldTrialGroupParameter}" |
| 1193 L"ie={inputEncoding}&ion=1{searchTerms}&nord=1", |
| 1191 SEARCH_ENGINE_GOOGLE, | 1194 SEARCH_ENGINE_GOOGLE, |
| 1192 IDR_SEARCH_ENGINE_LOGO_GOOGLE, | 1195 IDR_SEARCH_ENGINE_LOGO_GOOGLE, |
| 1193 1, | 1196 1, |
| 1194 }; | 1197 }; |
| 1195 | 1198 |
| 1196 const PrepopulatedEngine guruji = { | 1199 const PrepopulatedEngine guruji = { |
| 1197 L"guruji", | 1200 L"guruji", |
| 1198 L"guruji.com", | 1201 L"guruji.com", |
| 1199 "http://guruji.com/favicon.ico", | 1202 "http://guruji.com/favicon.ico", |
| 1200 L"http://guruji.com/search?q={searchTerms}", | 1203 L"http://guruji.com/search?q={searchTerms}", |
| (...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3352 PrefService::UNSYNCABLE_PREF); | 3355 PrefService::UNSYNCABLE_PREF); |
| 3353 // Obsolete pref, for migration. | 3356 // Obsolete pref, for migration. |
| 3354 prefs->RegisterIntegerPref(prefs::kGeoIDAtInstall, | 3357 prefs->RegisterIntegerPref(prefs::kGeoIDAtInstall, |
| 3355 -1, | 3358 -1, |
| 3356 PrefService::UNSYNCABLE_PREF); | 3359 PrefService::UNSYNCABLE_PREF); |
| 3357 } | 3360 } |
| 3358 | 3361 |
| 3359 int GetDataVersion(PrefService* prefs) { | 3362 int GetDataVersion(PrefService* prefs) { |
| 3360 // Increment this if you change the above data in ways that mean users with | 3363 // Increment this if you change the above data in ways that mean users with |
| 3361 // existing data should get a new version. | 3364 // existing data should get a new version. |
| 3362 const int kCurrentDataVersion = 35; | 3365 const int kCurrentDataVersion = 36; |
| 3363 if (!prefs) | 3366 if (!prefs) |
| 3364 return kCurrentDataVersion; | 3367 return kCurrentDataVersion; |
| 3365 // If a version number exist in the preferences file, it overrides the | 3368 // If a version number exist in the preferences file, it overrides the |
| 3366 // version of the built-in data. | 3369 // version of the built-in data. |
| 3367 int version = | 3370 int version = |
| 3368 prefs->GetInteger(prefs::kSearchProviderOverridesVersion); | 3371 prefs->GetInteger(prefs::kSearchProviderOverridesVersion); |
| 3369 return (version >= 0) ? version : kCurrentDataVersion; | 3372 return (version >= 0) ? version : kCurrentDataVersion; |
| 3370 } | 3373 } |
| 3371 | 3374 |
| 3372 TemplateURL* MakePrepopulatedTemplateURL(const wchar_t* name, | 3375 TemplateURL* MakePrepopulatedTemplateURL(const wchar_t* name, |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3528 // It is much faster to parse the url without generating the search URL, so | 3531 // It is much faster to parse the url without generating the search URL, so |
| 3529 // try that first. If it fails, fallback to the slow method. | 3532 // try that first. If it fails, fallback to the slow method. |
| 3530 std::string url_utf8_string(ToUTF8(url_string)); | 3533 std::string url_utf8_string(ToUTF8(url_string)); |
| 3531 GURL url(url_utf8_string); | 3534 GURL url(url_utf8_string); |
| 3532 if (!url.is_valid()) { | 3535 if (!url.is_valid()) { |
| 3533 TemplateURL turl; | 3536 TemplateURL turl; |
| 3534 turl.SetURL(url_utf8_string, 0, 0); | 3537 turl.SetURL(url_utf8_string, 0, 0); |
| 3535 | 3538 |
| 3536 UIThreadSearchTermsData search_terms_data; | 3539 UIThreadSearchTermsData search_terms_data; |
| 3537 url = TemplateURLService::GenerateSearchURLUsingTermsData( | 3540 url = TemplateURLService::GenerateSearchURLUsingTermsData( |
| 3538 &turl, search_terms_data); | 3541 NULL, &turl, search_terms_data); |
| 3539 } | 3542 } |
| 3540 return url.GetOrigin(); | 3543 return url.GetOrigin(); |
| 3541 } | 3544 } |
| 3542 | 3545 |
| 3543 TemplateURL* GetEngineForOrigin(PrefService* prefs, const GURL& url_to_find) { | 3546 TemplateURL* GetEngineForOrigin(PrefService* prefs, const GURL& url_to_find) { |
| 3544 GURL origin_to_find = url_to_find.GetOrigin(); | 3547 GURL origin_to_find = url_to_find.GetOrigin(); |
| 3545 | 3548 |
| 3546 // Let's first try to find the url in the defaults. (In case the name | 3549 // Let's first try to find the url in the defaults. (In case the name |
| 3547 // of logo is different for the current locale versus others.) | 3550 // of logo is different for the current locale versus others.) |
| 3548 ScopedVector<TemplateURL> loaded_urls; | 3551 ScopedVector<TemplateURL> loaded_urls; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3574 for (size_t i = 0; i < arraysize(kAllEngines); ++i) { | 3577 for (size_t i = 0; i < arraysize(kAllEngines); ++i) { |
| 3575 std::string url_utf8_string(ToUTF8(kAllEngines[i]->search_url)); | 3578 std::string url_utf8_string(ToUTF8(kAllEngines[i]->search_url)); |
| 3576 GURL url(url_utf8_string); | 3579 GURL url(url_utf8_string); |
| 3577 if (origin_to_find == url.GetOrigin()) | 3580 if (origin_to_find == url.GetOrigin()) |
| 3578 return kAllEngines[i]->logo_id; | 3581 return kAllEngines[i]->logo_id; |
| 3579 } | 3582 } |
| 3580 return kNoSearchEngineLogo; | 3583 return kNoSearchEngineLogo; |
| 3581 } | 3584 } |
| 3582 | 3585 |
| 3583 } // namespace TemplateURLPrepopulateData | 3586 } // namespace TemplateURLPrepopulateData |
| OLD | NEW |