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 e4b34bd8e6f2d1dc985f9be09264ca60f5e95f94..6e49bb958955bf76ee7e3162874bdf9194250e99 100644 |
| --- a/chrome/browser/search_engines/template_url_prepopulate_data.cc |
| +++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc |
| @@ -15,6 +15,7 @@ |
| #include "base/stl_util.h" |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/prefs/pref_service.h" |
| +#include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/search_engines/search_engine_type.h" |
| #include "chrome/browser/search_engines/search_terms_data.h" |
| #include "chrome/browser/search_engines/template_url.h" |
| @@ -1182,12 +1183,15 @@ const PrepopulatedEngine google = { |
| "http://www.google.com/favicon.ico", |
| L"{google:baseURL}search?{google:RLZ}{google:acceptedSuggestion}" |
| L"{google:originalQueryForSuggestion}{google:searchFieldtrialParameter}" |
| + L"{google:instantFieldTrialGroupParameter}" |
| L"sourceid=chrome&ie={inputEncoding}&q={searchTerms}", |
| "UTF-8", |
| L"{google:baseSuggestURL}search?{google:searchFieldtrialParameter}" |
| + L"{google:instantFieldTrialGroupParameter}" |
| L"client=chrome&hl={language}&q={searchTerms}", |
| - L"{google:baseURL}webhp?{google:RLZ}sourceid=chrome-instant" |
| - L"&ie={inputEncoding}&ion=1{searchTerms}&nord=1", |
| + L"{google:baseURL}webhp?{google:RLZ}sourceid=chrome-instant&" |
| + L"{google:instantFieldTrialGroupParameter}" |
| + L"ie={inputEncoding}&ion=1{searchTerms}&nord=1", |
| SEARCH_ENGINE_GOOGLE, |
| IDR_SEARCH_ENGINE_LOGO_GOOGLE, |
| 1, |
| @@ -3359,7 +3363,7 @@ void RegisterUserPrefs(PrefService* prefs) { |
| int GetDataVersion(PrefService* prefs) { |
| // Increment this if you change the above data in ways that mean users with |
| // existing data should get a new version. |
| - const int kCurrentDataVersion = 35; |
| + const int kCurrentDataVersion = 36; |
| if (!prefs) |
| return kCurrentDataVersion; |
| // If a version number exist in the preferences file, it overrides the |
| @@ -3524,7 +3528,7 @@ static std::string ToUTF8(const wchar_t* str) { |
| } |
| template<typename STR> |
| -static GURL GetOriginForSearchURL(const STR& url_string) { |
| +static GURL GetOriginForSearchURL(Profile* profile, const STR& url_string) { |
| // It is much faster to parse the url without generating the search URL, so |
| // try that first. If it fails, fallback to the slow method. |
| std::string url_utf8_string(ToUTF8(url_string)); |
| @@ -3533,27 +3537,27 @@ static GURL GetOriginForSearchURL(const STR& url_string) { |
| TemplateURL turl; |
| turl.SetURL(url_utf8_string, 0, 0); |
| - UIThreadSearchTermsData search_terms_data; |
| + UIThreadSearchTermsData search_terms_data(profile); |
|
Peter Kasting
2011/08/10 20:54:06
You don't care about anything but the origin, so p
|
| url = TemplateURLService::GenerateSearchURLUsingTermsData( |
| &turl, search_terms_data); |
| } |
| return url.GetOrigin(); |
| } |
| -TemplateURL* GetEngineForOrigin(PrefService* prefs, const GURL& url_to_find) { |
| +TemplateURL* GetEngineForOrigin(Profile* profile, const GURL& url_to_find) { |
| GURL origin_to_find = url_to_find.GetOrigin(); |
| // Let's first try to find the url in the defaults. (In case the name |
| // of logo is different for the current locale versus others.) |
| ScopedVector<TemplateURL> loaded_urls; |
| size_t default_search_index; |
| - GetPrepopulatedEngines(prefs, &loaded_urls.get(), &default_search_index); |
| + GetPrepopulatedEngines(profile->GetPrefs(), &loaded_urls.get(), |
| + &default_search_index); |
| - UIThreadSearchTermsData search_terms_data; |
| for (std::vector<TemplateURL*>::iterator i = loaded_urls->begin(); |
| i != loaded_urls->end(); ++i) { |
| TemplateURL* template_url = *i; |
| - GURL engine_origin(GetOriginForSearchURL((*i)->url()->url())); |
| + GURL engine_origin(GetOriginForSearchURL(profile, (*i)->url()->url())); |
| if (origin_to_find == engine_origin) { |
| loaded_urls.weak_erase(i); |
| return template_url; |
| @@ -3562,7 +3566,8 @@ TemplateURL* GetEngineForOrigin(PrefService* prefs, const GURL& url_to_find) { |
| // Let's try all of known engines now. |
| for (size_t i = 0; i < arraysize(kAllEngines); ++i) { |
| - GURL engine_origin(GetOriginForSearchURL(kAllEngines[i]->search_url)); |
| + GURL engine_origin( |
| + GetOriginForSearchURL(profile, kAllEngines[i]->search_url)); |
| if (origin_to_find == engine_origin) |
| return MakePrepopulateTemplateURLFromPrepopulateEngine(*kAllEngines[i]); |
| } |