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

Unified Diff: components/search_engines/template_url.h

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.h
diff --git a/components/search_engines/template_url.h b/components/search_engines/template_url.h
index 2acb146851887d0f8246dbf56c4b60071374d097..16c79ea9f9d349463e9a4d3a884f6ef0d3a79c20 100644
--- a/components/search_engines/template_url.h
+++ b/components/search_engines/template_url.h
@@ -17,6 +17,7 @@
#include "base/time/time.h"
#include "components/metrics/proto/omnibox_event.pb.h"
#include "components/metrics/proto/omnibox_input_type.pb.h"
+#include "components/search_engines/search_engine_type.h"
#include "components/search_engines/template_url_data.h"
#include "components/search_engines/template_url_id.h"
#include "ui/gfx/geometry/size.h"
@@ -644,6 +645,11 @@ class TemplateURL {
// OMNIBOX_API_EXTENSION.
std::string GetExtensionId() const;
+ // Returns the type of this search engine, or SEARCH_ENGINE_OTHER if no
+ // engines match.
+ SearchEngineType GetEngineType(
+ const SearchTermsData& search_terms_data) const;
+
// Use the alternate URLs and the search URL to match the provided |url|
// and extract |search_terms| from it. Returns false and an empty
// |search_terms| if no search terms can be matched. The order in which the
@@ -749,6 +755,9 @@ class TemplateURL {
TemplateURLRef contextual_search_url_ref_;
std::unique_ptr<AssociatedExtensionInfo> extension_info_;
+ // Caches the computed engine type across successive calls to GetEngineType().
+ mutable SearchEngineType engine_type_;
+
// TODO(sky): Add date last parsed OSD file.
DISALLOW_COPY_AND_ASSIGN(TemplateURL);

Powered by Google App Engine
This is Rietveld 408576698