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

Unified Diff: components/search_engines/template_url_prepopulate_data.cc

Issue 2479113002: Make extensions DSE persistent in browser prefs (Closed)
Patch Set: Updated after review, round 6 Created 4 years 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
Index: components/search_engines/template_url_prepopulate_data.cc
diff --git a/components/search_engines/template_url_prepopulate_data.cc b/components/search_engines/template_url_prepopulate_data.cc
index 56d76a6829ab2a3e72169fe828020b6626cd5cb1..44ad522fdb2df6e248d059d9823fffe8a4f70a88 100644
--- a/components/search_engines/template_url_prepopulate_data.cc
+++ b/components/search_engines/template_url_prepopulate_data.cc
@@ -1041,6 +1041,19 @@ std::vector<std::unique_ptr<TemplateURLData>> GetPrepopulatedEngines(
return GetPrepopulationSetFromCountryID(GetCountryIDFromPrefs(prefs));
}
+// Find the prepopulated search engine with the given id.
+std::unique_ptr<TemplateURLData> GetPrepopulatedEngine(PrefService* prefs,
+ int prepopulated_id) {
+ size_t default_index;
Peter Kasting 2016/12/22 20:49:04 Nit: Probably should be done in a separate CL, but
Alexander Yashkin 2016/12/23 19:44:09 Agree, it should be done, but in separate CL.
+ std::vector<std::unique_ptr<TemplateURLData>> engines =
Peter Kasting 2016/12/22 20:49:04 Nit: Use auto
Alexander Yashkin 2016/12/23 19:44:09 Done
+ TemplateURLPrepopulateData::GetPrepopulatedEngines(prefs, &default_index);
+ for (auto& engine : engines) {
+ if (engine->prepopulate_id == prepopulated_id)
+ return std::move(engine);
+ }
Peter Kasting 2016/12/22 20:49:04 I tried writing this out with find_if(), but I don
Alexander Yashkin 2016/12/23 19:44:09 Old style is more clear here, IMHO.
+ return nullptr;
+}
+
#if defined(OS_ANDROID)
std::vector<std::unique_ptr<TemplateURLData>> GetLocalPrepopulatedEngines(

Powered by Google App Engine
This is Rietveld 408576698