Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Unified Diff: chrome/browser/search_engines/util.cc

Issue 15572002: Implemented 'Reset Search engines' feature. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merge with trunk + Peter's comments Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/search_engines/util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5e7d285297b507cd9fa1cdc4b38c3c190b499be2 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* 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(resource_keyword_version);
+
ScopedVector<TemplateURL> prepopulated_urls;
size_t default_search_index;
TemplateURLPrepopulateData::GetPrepopulatedEngines(profile,
@@ -296,14 +314,16 @@ void GetSearchProvidersUsingKeywordResult(
*default_search_provider, template_urls,
removed_keyword_guids);
- const int resource_keyword_version =
+ const int prepopulate_resource_keyword_version =
TemplateURLPrepopulateData::GetDataVersion(
profile ? profile->GetPrefs() : NULL);
- if (keyword_result.builtin_keyword_version != resource_keyword_version) {
+ if (*resource_keyword_version < prepopulate_resource_keyword_version) {
MergeEnginesFromPrepopulateData(profile, service, &prepopulated_urls,
default_search_index, template_urls, default_search_provider,
removed_keyword_guids);
- *new_resource_keyword_version = resource_keyword_version;
+ *resource_keyword_version = prepopulate_resource_keyword_version;
+ } else {
+ *resource_keyword_version = 0;
}
}
« no previous file with comments | « chrome/browser/search_engines/util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698