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

Unified Diff: components/search_engines/template_url_data.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: Move calculation to TemplateURLData 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_data.h
diff --git a/components/search_engines/template_url_data.h b/components/search_engines/template_url_data.h
index 11943b0ce673eefd744dacf3c8615ff9e5bf9e34..914f191b09c23fa70f607ca211da9861b83be072 100644
--- a/components/search_engines/template_url_data.h
+++ b/components/search_engines/template_url_data.h
@@ -10,9 +10,13 @@
#include "base/strings/string16.h"
#include "base/time/time.h"
+#include "components/search_engines/search_engine_type.h"
#include "components/search_engines/template_url_id.h"
#include "url/gurl.h"
+class SearchTermsData;
+class TemplateURL;
+
// The data for the TemplateURL. Separating this into its own class allows most
// users to do SSA-style usage of TemplateURL: construct a TemplateURLData with
// whatever fields are desired, then create an immutable TemplateURL from it.
@@ -36,6 +40,13 @@ struct TemplateURLData {
void SetURL(const std::string& url);
const std::string& url() const { return url_; }
+ // Returns the type of this search engine, or SEARCH_ENGINE_OTHER if no
+ // engines match. |template_url_hint| is a TemplateURL which owns this
+ // TemplateURLData. If |template_url_hint| is nullptr it's ignored.
+ SearchEngineType GetEngineType(
+ const SearchTermsData& search_terms_data,
+ const TemplateURL* template_url_hint = nullptr) const;
Peter Kasting 2016/06/09 23:00:56 Supplying a null second arg is only used by one te
Vitaly Baranov 2016/06/12 07:29:15 Done.
+
// Optional additional raw URLs.
std::string suggestions_url;
std::string instant_url;
@@ -120,6 +131,9 @@ struct TemplateURLData {
base::string16 short_name_;
base::string16 keyword_;
std::string url_;
+
+ // Mutable to allow GetEngineType() to assign it implicitly.
Peter Kasting 2016/06/09 23:00:56 Nit: This is sort of implied by the mutable keywor
Vitaly Baranov 2016/06/12 07:29:15 Done.
+ mutable SearchEngineType engine_type_;
};
Peter Kasting 2016/06/09 23:00:56 NIt: While here: DISALLOW_COPY_AND_ASSIGN
Vitaly Baranov 2016/06/12 07:29:15 TemplateURLData has a copy constructor.
#endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_

Powered by Google App Engine
This is Rietveld 408576698