Chromium Code Reviews| Index: chrome/browser/search_engines/util.cc |
| diff --git a/chrome/browser/search_engines/util.cc b/chrome/browser/search_engines/util.cc |
| index 581f513bdbcd982643fe70115425340afacae179..aa7a98b94ab00c24d6eaf32c2dc1cebc441b6a5b 100644 |
| --- a/chrome/browser/search_engines/util.cc |
| +++ b/chrome/browser/search_engines/util.cc |
| @@ -149,8 +149,8 @@ void MergeIntoPrepopulatedEngineData(TemplateURLData* prepopulated_url, |
| prepopulated_url->last_modified = original_turl->last_modified(); |
| } |
| -// Loads engines from prepopulate data and merges them in with the existing |
| -// engines. This is invoked when the version of the prepopulate data changes. |
| +// Merges the provided prepopulated engines with the provided existing engines. |
| +// This is invoked when the version of the prepopulate data changes. |
| // If |removed_keyword_guids| is not NULL, the Sync GUID of each item removed |
| // from the DB will be added to it. Note that this function will take |
| // ownership of |prepopulated_urls| and will clear the vector. |
| @@ -262,7 +262,6 @@ void GetSearchProvidersUsingKeywordResult( |
| DCHECK_EQ(KEYWORDS_RESULT, result.GetType()); |
| DCHECK(new_resource_keyword_version); |
| - *new_resource_keyword_version = 0; |
| WDKeywordsResult keyword_result = reinterpret_cast< |
| const WDResult<WDKeywordsResult>*>(&result)->GetValue(); |
| @@ -288,6 +287,25 @@ void GetSearchProvidersUsingKeywordResult( |
| GetTemplateURLByID(*template_urls, default_search_provider_id); |
| } |
| + *new_resource_keyword_version = keyword_result.builtin_keyword_version; |
| + GetSearchProvidersUsingLoadedEngines(service, profile, template_urls, |
| + default_search_provider, |
| + new_resource_keyword_version, |
| + removed_keyword_guids); |
| +} |
| + |
| +void GetSearchProvidersUsingLoadedEngines( |
| + WebDataService* service, |
| + Profile* profile, |
| + TemplateURLService::TemplateURLVector* template_urls, |
| + TemplateURL** default_search_provider, |
| + int* new_resource_keyword_version, |
| + std::set<std::string>* removed_keyword_guids) { |
| + DCHECK(service == NULL || BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + DCHECK(template_urls); |
| + DCHECK(default_search_provider); |
| + DCHECK(new_resource_keyword_version); |
| + |
| ScopedVector<TemplateURL> prepopulated_urls; |
| size_t default_search_index; |
| TemplateURLPrepopulateData::GetPrepopulatedEngines(profile, |
| @@ -299,11 +317,13 @@ void GetSearchProvidersUsingKeywordResult( |
| const int resource_keyword_version = |
| TemplateURLPrepopulateData::GetDataVersion( |
| profile ? profile->GetPrefs() : NULL); |
| - if (keyword_result.builtin_keyword_version != resource_keyword_version) { |
| + if (*new_resource_keyword_version != resource_keyword_version) { |
|
Peter Kasting
2013/05/29 04:04:41
Nit: Really, this should use < instead of !=. Thi
vasilii
2013/05/29 08:30:18
Done.
|
| MergeEnginesFromPrepopulateData(profile, service, &prepopulated_urls, |
| default_search_index, template_urls, default_search_provider, |
| removed_keyword_guids); |
| *new_resource_keyword_version = resource_keyword_version; |
| + } else { |
| + *new_resource_keyword_version = 0; |
| } |
| } |