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

Unified Diff: components/search_engines/template_url_prepopulate_data.cc

Issue 1983773002: Cache SearchEngineType of TemplateURL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor-extracting-terms-from-template-url
Patch Set: Fix typo Created 4 years, 6 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
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 33a72bbb0ab76f9258a47657267250e161dd1b6f..114757dd66df633534d981f056c7c073e35a1049 100644
--- a/components/search_engines/template_url_prepopulate_data.cc
+++ b/components/search_engines/template_url_prepopulate_data.cc
@@ -21,7 +21,7 @@
#include "components/prefs/pref_service.h"
#include "components/search_engines/prepopulated_engines.h"
#include "components/search_engines/search_engines_pref_names.h"
-#include "components/search_engines/template_url.h"
+#include "components/search_engines/template_url_data.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "url/gurl.h"
@@ -1125,6 +1125,11 @@ ScopedVector<TemplateURLData> GetPrepopulatedEngines(
return t_urls;
}
+std::vector<const PrepopulatedEngine*> GetAllPrepopulatedEngines() {
+ return std::vector<const PrepopulatedEngine*>(std::begin(kAllEngines),
+ std::end(kAllEngines));
+}
+
std::unique_ptr<TemplateURLData> MakeTemplateURLDataFromPrepopulatedEngine(
const PrepopulatedEngine& engine) {
base::ListValue alternate_urls;
@@ -1166,16 +1171,6 @@ std::unique_ptr<TemplateURLData> GetPrepopulatedDefaultSearch(
return default_search_provider;
}
-SearchEngineType GetEngineType(const TemplateURL& url,
- const SearchTermsData& search_terms_data) {
- // By calling ReplaceSearchTerms, we ensure that even TemplateURLs whose URLs
- // can't be directly inspected (e.g. due to containing {google:baseURL}) can
- // be converted to GURLs we can look at.
- GURL gurl(url.url_ref().ReplaceSearchTerms(TemplateURLRef::SearchTermsArgs(
- base::ASCIIToUTF16("x")), search_terms_data));
- return gurl.is_valid() ? GetEngineType(gurl) : SEARCH_ENGINE_OTHER;
-}
-
SearchEngineType GetEngineType(const GURL& url) {
DCHECK(url.is_valid());

Powered by Google App Engine
This is Rietveld 408576698