blob: 4fa09c5ef8d671533b6d636072bbf3c119c5c8ff [file] [log] [blame]
[email protected]d550cb02014-06-25 06:48:111// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]d82443b2009-01-15 19:54:562// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]d550cb02014-06-25 06:48:115#ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_
6#define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_
[email protected]d82443b2009-01-15 19:54:567
Denis Yaroshevskiy361a59322018-02-12 20:16:128#include <cstddef>
dchengd967d9502016-04-21 22:36:519#include <memory>
[email protected]81c6ef62010-01-21 09:58:4710#include <string>
[email protected]93b29062013-07-12 03:09:0911#include <utility>
[email protected]d82443b2009-01-15 19:54:5612#include <vector>
13
[email protected]a918f872010-06-01 14:30:5114#include "base/gtest_prod_util.h"
avif57136c12015-12-25 23:27:4515#include "base/macros.h"
[email protected]cc86ccfe2013-06-28 00:10:5016#include "base/time/time.h"
vitbarda6a50182016-06-14 18:20:3217#include "components/search_engines/search_engine_type.h"
[email protected]fa817b12014-06-11 06:25:2518#include "components/search_engines/template_url_data.h"
19#include "components/search_engines/template_url_id.h"
Steven Holtef9d5ed62017-10-21 02:02:3020#include "third_party/metrics_proto/omnibox_event.pb.h"
21#include "third_party/metrics_proto/omnibox_input_type.pb.h"
[email protected]d550cb02014-06-25 06:48:1122#include "ui/gfx/geometry/size.h"
[email protected]761fa4702013-07-02 15:25:1523#include "url/gurl.h"
tfarina018de6e2015-05-26 17:41:2024#include "url/third_party/mozilla/url_parse.h"
[email protected]d82443b2009-01-15 19:54:5625
[email protected]375bd7312010-08-30 22:18:1326class SearchTermsData;
[email protected]d82443b2009-01-15 19:54:5627class TemplateURL;
28
[email protected]573889f22012-04-07 01:31:5429
30// TemplateURLRef -------------------------------------------------------------
31
32// A TemplateURLRef represents a single URL within the larger TemplateURL class
33// (which represents an entire "search engine", see below). If
34// SupportsReplacement() is true, this URL has placeholders in it, for which
35// callers can substitute values to get a "real" URL using ReplaceSearchTerms().
[email protected]d82443b2009-01-15 19:54:5636//
[email protected]573889f22012-04-07 01:31:5437// TemplateURLRefs always have a non-NULL |owner_| TemplateURL, which they
[email protected]16fca9b82012-04-23 18:40:2638// access in order to get at important data like the underlying URL string or
39// the associated Profile.
[email protected]d82443b2009-01-15 19:54:5640class TemplateURLRef {
41 public:
42 // Magic numbers to pass to ReplaceSearchTerms() for the |accepted_suggestion|
43 // parameter. Most callers aren't using Suggest capabilities and should just
44 // pass NO_SUGGESTIONS_AVAILABLE.
45 // NOTE: Because positive values are meaningful, make sure these are negative!
46 enum AcceptedSuggestion {
47 NO_SUGGESTION_CHOSEN = -1,
48 NO_SUGGESTIONS_AVAILABLE = -2,
49 };
50
[email protected]360ba052012-04-04 17:26:1351 // Which kind of URL within our owner we are. This allows us to get at the
[email protected]5b3078752012-10-09 18:54:1652 // correct string field. Use |INDEXED| to indicate that the numerical
53 // |index_in_owner_| should be used instead.
[email protected]360ba052012-04-04 17:26:1354 enum Type {
55 SEARCH,
56 SUGGEST,
[email protected]93b29062013-07-12 03:09:0957 IMAGE,
[email protected]2767c0fd2013-08-16 17:44:1658 NEW_TAB,
[email protected]448b17f52014-06-13 01:08:0359 CONTEXTUAL_SEARCH,
[email protected]5b3078752012-10-09 18:54:1660 INDEXED
[email protected]360ba052012-04-04 17:26:1361 };
62
[email protected]7c2bcc42013-08-01 04:03:4863 // Type to store <content_type, post_data> pair for POST URLs.
64 // The |content_type|(first part of the pair) is the content-type of
65 // the |post_data|(second part of the pair) which is encoded in
66 // "multipart/form-data" format, it also contains the MIME boundary used in
67 // the |post_data|. See http://tools.ietf.org/html/rfc2046 for the details.
68 typedef std::pair<std::string, std::string> PostContent;
69
[email protected]bca359b2012-06-24 07:53:0470 // This struct encapsulates arguments passed to
71 // TemplateURLRef::ReplaceSearchTerms methods. By default, only search_terms
72 // is required and is passed in the constructor.
73 struct SearchTermsArgs {
[email protected]0085863a2013-12-06 21:19:0374 explicit SearchTermsArgs(const base::string16& search_terms);
vmpstrb6449d512016-02-25 23:55:4075 SearchTermsArgs(const SearchTermsArgs& other);
[email protected]800569d2013-05-06 07:38:4876 ~SearchTermsArgs();
[email protected]bca359b2012-06-24 07:53:0477
[email protected]448b17f52014-06-13 01:08:0378 struct ContextualSearchParams {
79 ContextualSearchParams();
donnd0bc73292017-01-17 22:07:5680 // Modern constructor, used when the content is sent in the HTTP header
81 // instead of as CGI parameters.
82 // The |home_country| is an ISO country code for the country that the user
83 // considers their permanent home (which may be different from the country
84 // they are currently visiting). Pass an empty string if none available.
donndd9fc4d92016-09-16 00:30:4985 ContextualSearchParams(int version,
donnd0bc73292017-01-17 22:07:5686 int contextual_cards_version,
87 const std::string& home_country);
vmpstrb6449d512016-02-25 23:55:4088 ContextualSearchParams(const ContextualSearchParams& other);
[email protected]448b17f52014-06-13 01:08:0389 ~ContextualSearchParams();
90
Denis Yaroshevskiy361a59322018-02-12 20:16:1291 // Estimates dynamic memory usage.
92 // See base/trace_event/memory_usage_estimator.h for more info.
93 size_t EstimateMemoryUsage() const;
94
[email protected]448b17f52014-06-13 01:08:0395 // The version of contextual search.
96 int version;
97
twellingtonc0947da2016-09-26 16:09:4498 // The version of Contextual Cards data to request.
donndd9fc4d92016-09-16 00:30:4999 // A value of 0 indicates no data needed.
twellingtonc0947da2016-09-26 16:09:44100 int contextual_cards_version;
donnd0bc73292017-01-17 22:07:56101
102 // The locale of the user's home country in an ISO country code format,
103 // or an empty string if not available. This indicates where the user
104 // resides, not where they currently are.
105 std::string home_country;
[email protected]448b17f52014-06-13 01:08:03106 };
107
Denis Yaroshevskiy361a59322018-02-12 20:16:12108 // Estimates dynamic memory usage.
109 // See base/trace_event/memory_usage_estimator.h for more info.
110 size_t EstimateMemoryUsage() const;
111
[email protected]bca359b2012-06-24 07:53:04112 // The search terms (query).
[email protected]0085863a2013-12-06 21:19:03113 base::string16 search_terms;
[email protected]bba9e632013-06-28 22:52:19114
[email protected]bca359b2012-06-24 07:53:04115 // The original (input) query.
[email protected]0085863a2013-12-06 21:19:03116 base::string16 original_query;
[email protected]bba9e632013-06-28 22:52:19117
[email protected]420472b22014-06-10 13:34:43118 // The type the original input query was identified as.
Steven Holte3696c9412017-08-24 18:38:03119 metrics::OmniboxInputType input_type;
[email protected]420472b22014-06-10 13:34:43120
[email protected]bca359b2012-06-24 07:53:04121 // The optional assisted query stats, aka AQS, used for logging purposes.
122 // This string contains impressions of all autocomplete matches shown
123 // at the query submission time. For privacy reasons, we require the
124 // search provider to support HTTPS protocol in order to receive the AQS
125 // param.
126 // For more details, see http://goto.google.com/binary-clients-logging .
127 std::string assisted_query_stats;
128
129 // TODO: Remove along with "aq" CGI param.
130 int accepted_suggestion;
[email protected]00790562012-12-14 09:57:16131
132 // The 0-based position of the cursor within the query string at the time
[email protected]0085863a2013-12-06 21:19:03133 // the request was issued. Set to base::string16::npos if not used.
[email protected]00790562012-12-14 09:57:16134 size_t cursor_position;
[email protected]c55364c2013-03-06 00:24:43135
[email protected]800569d2013-05-06 07:38:48136 // The URL of the current webpage to be used for experimental zero-prefix
137 // suggestions.
[email protected]9b9fa672013-11-07 06:04:52138 std::string current_page_url;
[email protected]56fa29592013-07-02 20:25:53139
[email protected]d5015ca2013-08-08 22:04:18140 // Which omnibox the user used to type the prefix.
[email protected]332d17d22014-06-20 16:56:03141 metrics::OmniboxEventProto::PageClassification page_classification;
[email protected]d5015ca2013-08-08 22:04:18142
[email protected]20184242014-05-14 02:57:42143 // Optional session token.
144 std::string session_token;
145
[email protected]9e9130ce2014-06-23 23:20:51146 // Prefetch query and type.
147 std::string prefetch_query;
148 std::string prefetch_query_type;
149
[email protected]621ade062013-10-28 06:27:43150 // Additional query params provided by the suggest server.
151 std::string suggest_query_params;
152
[email protected]56fa29592013-07-02 20:25:53153 // If set, ReplaceSearchTerms() will automatically append any extra query
154 // params specified via the --extra-search-query-params command-line
Marc Treibec42aaaf2017-09-21 15:15:27155 // argument. Generally, this should be set when dealing with the search
156 // TemplateURLRefs of the default search engine and the caller cares
[email protected]56fa29592013-07-02 20:25:53157 // about the query portion of the URL. Since neither TemplateURLRef nor
158 // indeed TemplateURL know whether a TemplateURL is the default search
159 // engine, callers instead must set this manually.
160 bool append_extra_query_params;
[email protected]93b29062013-07-12 03:09:09161
162 // The raw content of an image thumbnail that will be used as a query for
163 // search-by-image frontend.
164 std::string image_thumbnail_content;
165
166 // When searching for an image, the URL of the original image. Callers
167 // should leave this empty for images specified via data: URLs.
168 GURL image_url;
[email protected]2f3bc6512013-08-28 03:56:27169
170 // When searching for an image, the original size of the image.
171 gfx::Size image_original_size;
[email protected]d5ebcf42013-10-30 00:48:18172
[email protected]c8ccc41d2014-04-10 04:42:12173 // True if the search was made using the app list search box. Otherwise, the
174 // search was made using the omnibox.
175 bool from_app_list;
[email protected]448b17f52014-06-13 01:08:03176
177 ContextualSearchParams contextual_search_params;
[email protected]bca359b2012-06-24 07:53:04178 };
179
blundelld130d592015-06-21 19:29:13180 TemplateURLRef(const TemplateURL* owner, Type type);
181 TemplateURLRef(const TemplateURL* owner, size_t index_in_owner);
[email protected]dcd869c2010-08-30 20:15:25182 ~TemplateURLRef();
[email protected]d82443b2009-01-15 19:54:56183
vitbar5bd8c252016-01-29 18:44:51184 TemplateURLRef(const TemplateURLRef& source);
185 TemplateURLRef& operator=(const TemplateURLRef& source);
186
[email protected]360ba052012-04-04 17:26:13187 // Returns the raw URL. None of the parameters will have been replaced.
188 std::string GetURL() const;
189
[email protected]93b29062013-07-12 03:09:09190 // Returns the raw string of the post params. Please see comments in
191 // prepopulated_engines_schema.json for the format.
192 std::string GetPostParamsString() const;
193
194 // Returns true if this URL supports search term replacement.
[email protected]ce7ee5f2014-06-16 23:41:19195 bool SupportsReplacement(const SearchTermsData& search_terms_data) const;
[email protected]923d733d12010-09-03 00:53:31196
[email protected]d82443b2009-01-15 19:54:56197 // Returns a string that is the result of replacing the search terms in
[email protected]bca359b2012-06-24 07:53:04198 // the url with the specified arguments. We use our owner's input encoding.
[email protected]d82443b2009-01-15 19:54:56199 //
200 // If this TemplateURLRef does not support replacement (SupportsReplacement
201 // returns false), an empty string is returned.
[email protected]7c2bcc42013-08-01 04:03:48202 // If this TemplateURLRef uses POST, and |post_content| is not NULL, the
[email protected]93b29062013-07-12 03:09:09203 // |post_params_| will be replaced, encoded in "multipart/form-data" format
[email protected]7c2bcc42013-08-01 04:03:48204 // and stored into |post_content|.
[email protected]ce7ee5f2014-06-16 23:41:19205 std::string ReplaceSearchTerms(const SearchTermsArgs& search_terms_args,
206 const SearchTermsData& search_terms_data,
207 PostContent* post_content) const;
208
[email protected]93b29062013-07-12 03:09:09209 // TODO(jnd): remove the following ReplaceSearchTerms definition which does
[email protected]7c2bcc42013-08-01 04:03:48210 // not have |post_content| parameter once all reference callers pass
211 // |post_content| parameter.
[email protected]93b29062013-07-12 03:09:09212 std::string ReplaceSearchTerms(
[email protected]bca359b2012-06-24 07:53:04213 const SearchTermsArgs& search_terms_args,
[email protected]ce7ee5f2014-06-16 23:41:19214 const SearchTermsData& search_terms_data) const {
215 return ReplaceSearchTerms(search_terms_args, search_terms_data, NULL);
216 }
[email protected]375bd7312010-08-30 22:18:13217
[email protected]d82443b2009-01-15 19:54:56218 // Returns true if the TemplateURLRef is valid. An invalid TemplateURLRef is
219 // one that contains unknown terms, or invalid characters.
[email protected]ce7ee5f2014-06-16 23:41:19220 bool IsValid(const SearchTermsData& search_terms_data) const;
[email protected]923d733d12010-09-03 00:53:31221
[email protected]d82443b2009-01-15 19:54:56222 // Returns a string representation of this TemplateURLRef suitable for
223 // display. The display format is the same as the format used by Firefox.
[email protected]ce7ee5f2014-06-16 23:41:19224 base::string16 DisplayURL(const SearchTermsData& search_terms_data) const;
[email protected]d82443b2009-01-15 19:54:56225
226 // Converts a string as returned by DisplayURL back into a string as
227 // understood by TemplateURLRef.
[email protected]0085863a2013-12-06 21:19:03228 static std::string DisplayURLToURLRef(const base::string16& display_url);
[email protected]d82443b2009-01-15 19:54:56229
230 // If this TemplateURLRef is valid and contains one search term, this returns
[email protected]7c60f5042013-02-14 03:39:32231 // the host/path of the URL, otherwise this returns an empty string.
[email protected]ce7ee5f2014-06-16 23:41:19232 const std::string& GetHost(const SearchTermsData& search_terms_data) const;
233 const std::string& GetPath(const SearchTermsData& search_terms_data) const;
[email protected]d82443b2009-01-15 19:54:56234
alexmos294849f2015-03-14 00:55:06235 // If this TemplateURLRef is valid and contains one search term
236 // in its query or ref, this returns the key of the search term,
237 // otherwise this returns an empty string.
[email protected]ce7ee5f2014-06-16 23:41:19238 const std::string& GetSearchTermKey(
239 const SearchTermsData& search_terms_data) const;
[email protected]d82443b2009-01-15 19:54:56240
alexmos294849f2015-03-14 00:55:06241 // If this TemplateURLRef is valid and contains one search term,
242 // this returns the location of the search term,
243 // otherwise this returns url::Parsed::QUERY.
244 url::Parsed::ComponentType GetSearchTermKeyLocation(
245 const SearchTermsData& search_terms_data) const;
246
vitbarf2a11562017-05-15 14:09:50247 // If this TemplateURLRef is valid and contains one search term,
248 // this returns the fixed prefix before the search term,
249 // otherwise this returns an empty string.
250 const std::string& GetSearchTermValuePrefix(
251 const SearchTermsData& search_terms_data) const;
252
253 // If this TemplateURLRef is valid and contains one search term,
254 // this returns the fixed suffix after the search term,
255 // otherwise this returns an empty string.
256 const std::string& GetSearchTermValueSuffix(
257 const SearchTermsData& search_terms_data) const;
258
[email protected]0085863a2013-12-06 21:19:03259 // Converts the specified term in our owner's encoding to a base::string16.
vitbarf2a11562017-05-15 14:09:50260 base::string16 SearchTermToString16(const base::StringPiece& term) const;
[email protected]d82443b2009-01-15 19:54:56261
262 // Returns true if this TemplateURLRef has a replacement term of
263 // {google:baseURL} or {google:baseSuggestURL}.
[email protected]ce7ee5f2014-06-16 23:41:19264 bool HasGoogleBaseURLs(const SearchTermsData& search_terms_data) const;
[email protected]d82443b2009-01-15 19:54:56265
[email protected]5b3078752012-10-09 18:54:16266 // Use the pattern referred to by this TemplateURLRef to match the provided
267 // |url| and extract |search_terms| from it. Returns true if the pattern
[email protected]f62e30f52013-03-23 03:45:15268 // matches, even if |search_terms| is empty. In this case
269 // |search_term_component|, if not NULL, indicates whether the search terms
270 // were found in the query or the ref parameters; and |search_terms_position|,
271 // if not NULL, contains the position of the search terms in the query or the
272 // ref parameters. Returns false and an empty |search_terms| if the pattern
273 // does not match.
[email protected]1ff6ce42013-03-05 00:54:34274 bool ExtractSearchTermsFromURL(
275 const GURL& url,
[email protected]0085863a2013-12-06 21:19:03276 base::string16* search_terms,
[email protected]f62e30f52013-03-23 03:45:15277 const SearchTermsData& search_terms_data,
[email protected]b45334502014-04-30 19:44:05278 url::Parsed::ComponentType* search_term_component,
279 url::Component* search_terms_position) const;
[email protected]5b3078752012-10-09 18:54:16280
[email protected]93b29062013-07-12 03:09:09281 // Whether the URL uses POST (as opposed to GET).
[email protected]ce7ee5f2014-06-16 23:41:19282 bool UsesPOSTMethod(const SearchTermsData& search_terms_data) const;
[email protected]93b29062013-07-12 03:09:09283
Denis Yaroshevskiy361a59322018-02-12 20:16:12284 // Estimates dynamic memory usage.
285 // See base/trace_event/memory_usage_estimator.h for more info.
286 size_t EstimateMemoryUsage() const;
287
[email protected]d82443b2009-01-15 19:54:56288 private:
289 friend class TemplateURL;
vitbardeb285392015-02-20 14:02:55290 friend class TemplateURLTest;
[email protected]1a257262011-06-28 22:15:44291 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, SetPrepopulatedAndParse);
[email protected]a918f872010-06-01 14:30:51292 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseParameterKnown);
293 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseParameterUnknown);
294 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLEmpty);
295 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNoTemplateEnd);
296 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNoKnownParameters);
297 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLTwoParameters);
298 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ParseURLNestedParameter);
[email protected]93b29062013-07-12 03:09:09299 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, URLRefTestImageURLWithPOST);
[email protected]d82443b2009-01-15 19:54:56300
301 // Enumeration of the known types.
302 enum ReplacementType {
303 ENCODING,
[email protected]bca359b2012-06-24 07:53:04304 GOOGLE_ASSISTED_QUERY_STATS,
[email protected]d82443b2009-01-15 19:54:56305 GOOGLE_BASE_URL,
306 GOOGLE_BASE_SUGGEST_URL,
[email protected]9b9fa672013-11-07 06:04:52307 GOOGLE_CURRENT_PAGE_URL,
[email protected]00790562012-12-14 09:57:16308 GOOGLE_CURSOR_POSITION,
[email protected]2f3bc6512013-08-28 03:56:27309 GOOGLE_IMAGE_ORIGINAL_HEIGHT,
310 GOOGLE_IMAGE_ORIGINAL_WIDTH,
[email protected]93b29062013-07-12 03:09:09311 GOOGLE_IMAGE_SEARCH_SOURCE,
312 GOOGLE_IMAGE_THUMBNAIL,
313 GOOGLE_IMAGE_URL,
[email protected]420472b22014-06-10 13:34:43314 GOOGLE_INPUT_TYPE,
blundella796b3c2016-01-22 15:15:26315 GOOGLE_IOS_SEARCH_LANGUAGE,
[email protected]7fe24d32013-03-19 21:27:20316 GOOGLE_NTP_IS_THEMED,
[email protected]448b17f52014-06-13 01:08:03317 GOOGLE_CONTEXTUAL_SEARCH_VERSION,
318 GOOGLE_CONTEXTUAL_SEARCH_CONTEXT_DATA,
[email protected]d82443b2009-01-15 19:54:56319 GOOGLE_ORIGINAL_QUERY_FOR_SUGGESTION,
[email protected]d5015ca2013-08-08 22:04:18320 GOOGLE_PAGE_CLASSIFICATION,
[email protected]9e9130ce2014-06-23 23:20:51321 GOOGLE_PREFETCH_QUERY,
[email protected]d82443b2009-01-15 19:54:56322 GOOGLE_RLZ,
[email protected]fd6d8822012-12-08 06:56:11323 GOOGLE_SEARCH_CLIENT,
[email protected]6930c522011-07-28 22:15:19324 GOOGLE_SEARCH_FIELDTRIAL_GROUP,
[email protected]5c3c6e482014-06-23 09:47:18325 GOOGLE_SEARCH_VERSION,
[email protected]20184242014-05-14 02:57:42326 GOOGLE_SESSION_TOKEN,
[email protected]6b808af2013-06-25 04:31:55327 GOOGLE_SUGGEST_CLIENT,
[email protected]b2cefdba2013-12-16 20:02:09328 GOOGLE_SUGGEST_REQUEST_ID,
[email protected]d82443b2009-01-15 19:54:56329 GOOGLE_UNESCAPED_SEARCH_TERMS,
330 LANGUAGE,
Yusuf Ozuysal82ed511e2017-08-29 23:24:52331 MAIL_RU_REFERRAL_ID,
[email protected]d82443b2009-01-15 19:54:56332 SEARCH_TERMS,
tedchoc2928c632017-05-11 18:31:28333 YANDEX_REFERRAL_ID,
[email protected]d82443b2009-01-15 19:54:56334 };
335
336 // Used to identify an element of the raw url that can be replaced.
337 struct Replacement {
[email protected]4c66d2a2010-05-11 04:36:05338 Replacement(ReplacementType type, size_t index)
[email protected]93b29062013-07-12 03:09:09339 : type(type), index(index), is_post_param(false) {}
[email protected]d82443b2009-01-15 19:54:56340 ReplacementType type;
[email protected]4c66d2a2010-05-11 04:36:05341 size_t index;
[email protected]93b29062013-07-12 03:09:09342 // Indicates the location in where the replacement is replaced. If
343 // |is_post_param| is false, |index| indicates the byte position in
344 // |parsed_url_|. Otherwise, |index| is the index of |post_params_|.
345 bool is_post_param;
[email protected]d82443b2009-01-15 19:54:56346 };
347
vitbardeb285392015-02-20 14:02:55348 // Stores a single parameter for a POST.
349 struct PostParam {
350 std::string name;
351 std::string value;
352 std::string content_type;
Denis Yaroshevskiy361a59322018-02-12 20:16:12353
354 // Estimates dynamic memory usage.
355 // See base/trace_event/memory_usage_estimator.h for more info.
356 size_t EstimateMemoryUsage() const;
vitbardeb285392015-02-20 14:02:55357 };
358
[email protected]d82443b2009-01-15 19:54:56359 // The list of elements to replace.
360 typedef std::vector<struct Replacement> Replacements;
[email protected]93b29062013-07-12 03:09:09361 typedef std::vector<PostParam> PostParams;
[email protected]d82443b2009-01-15 19:54:56362
363 // TemplateURLRef internally caches values to make replacement quick. This
364 // method invalidates any cached values.
365 void InvalidateCachedValues() const;
366
[email protected]d82443b2009-01-15 19:54:56367 // Parses the parameter in url at the specified offset. start/end specify the
368 // range of the parameter in the url, including the braces. If the parameter
369 // is valid, url is updated to reflect the appropriate parameter. If
370 // the parameter is one of the known parameters an element is added to
[email protected]81c6ef62010-01-21 09:58:47371 // replacements indicating the type and range of the element. The original
372 // parameter is erased from the url.
[email protected]d82443b2009-01-15 19:54:56373 //
[email protected]1a257262011-06-28 22:15:44374 // If the parameter is not a known parameter, false is returned. If this is a
375 // prepopulated URL, the parameter is erased, otherwise it is left alone.
[email protected]d82443b2009-01-15 19:54:56376 bool ParseParameter(size_t start,
377 size_t end,
[email protected]ddd231e2010-06-29 20:35:19378 std::string* url,
[email protected]d82443b2009-01-15 19:54:56379 Replacements* replacements) const;
380
381 // Parses the specified url, replacing parameters as necessary. If
382 // successful, valid is set to true, and the parsed url is returned. For all
383 // known parameters that are encountered an entry is added to replacements.
[email protected]81c6ef62010-01-21 09:58:47384 // If there is an error parsing the url, valid is set to false, and an empty
[email protected]93b29062013-07-12 03:09:09385 // string is returned. If the URL has the POST parameters, they will be
386 // parsed into |post_params| which will be further replaced with real search
387 // terms data and encoded in "multipart/form-data" format to generate the
388 // POST data.
[email protected]ddd231e2010-06-29 20:35:19389 std::string ParseURL(const std::string& url,
390 Replacements* replacements,
[email protected]93b29062013-07-12 03:09:09391 PostParams* post_params,
[email protected]ddd231e2010-06-29 20:35:19392 bool* valid) const;
[email protected]d82443b2009-01-15 19:54:56393
394 // If the url has not yet been parsed, ParseURL is invoked.
395 // NOTE: While this is const, it modifies parsed_, valid_, parsed_url_ and
396 // search_offset_.
[email protected]ce7ee5f2014-06-16 23:41:19397 void ParseIfNecessary(const SearchTermsData& search_terms_data) const;
[email protected]923d733d12010-09-03 00:53:31398
[email protected]d82443b2009-01-15 19:54:56399 // Extracts the query key and host from the url.
[email protected]923d733d12010-09-03 00:53:31400 void ParseHostAndSearchTermKey(
401 const SearchTermsData& search_terms_data) const;
[email protected]d82443b2009-01-15 19:54:56402
[email protected]93b29062013-07-12 03:09:09403 // Encode post parameters in "multipart/form-data" format and store it
[email protected]7c2bcc42013-08-01 04:03:48404 // inside |post_content|. Returns false if errors are encountered during
[email protected]93b29062013-07-12 03:09:09405 // encoding. This method is called each time ReplaceSearchTerms gets called.
406 bool EncodeFormData(const PostParams& post_params,
[email protected]7c2bcc42013-08-01 04:03:48407 PostContent* post_content) const;
[email protected]93b29062013-07-12 03:09:09408
409 // Handles a replacement by using real term data. If the replacement
410 // belongs to a PostParam, the PostParam will be replaced by the term data.
411 // Otherwise, the term data will be inserted at the place that the
412 // replacement points to.
413 void HandleReplacement(const std::string& name,
414 const std::string& value,
415 const Replacement& replacement,
416 std::string* url) const;
417
[email protected]56fa29592013-07-02 20:25:53418 // Replaces all replacements in |parsed_url_| with their actual values and
419 // returns the result. This is the main functionality of
[email protected]ce7ee5f2014-06-16 23:41:19420 // ReplaceSearchTerms().
[email protected]56fa29592013-07-02 20:25:53421 std::string HandleReplacements(
422 const SearchTermsArgs& search_terms_args,
[email protected]93b29062013-07-12 03:09:09423 const SearchTermsData& search_terms_data,
[email protected]7c2bcc42013-08-01 04:03:48424 PostContent* post_content) const;
[email protected]56fa29592013-07-02 20:25:53425
[email protected]9b74ab52012-03-30 16:08:07426 // The TemplateURL that contains us. This should outlive us.
vitbar5bd8c252016-01-29 18:44:51427 const TemplateURL* owner_;
[email protected]9b74ab52012-03-30 16:08:07428
[email protected]360ba052012-04-04 17:26:13429 // What kind of URL we are.
vitbar5bd8c252016-01-29 18:44:51430 Type type_;
[email protected]d82443b2009-01-15 19:54:56431
[email protected]5b3078752012-10-09 18:54:16432 // If |type_| is |INDEXED|, this |index_in_owner_| is used instead to refer to
433 // a url within our owner.
vitbar5bd8c252016-01-29 18:44:51434 size_t index_in_owner_;
[email protected]5b3078752012-10-09 18:54:16435
[email protected]d82443b2009-01-15 19:54:56436 // Whether the URL has been parsed.
437 mutable bool parsed_;
438
439 // Whether the url was successfully parsed.
440 mutable bool valid_;
441
442 // The parsed URL. All terms have been stripped out of this with
443 // replacements_ giving the index of the terms to replace.
[email protected]ddd231e2010-06-29 20:35:19444 mutable std::string parsed_url_;
[email protected]d82443b2009-01-15 19:54:56445
[email protected]93b29062013-07-12 03:09:09446 // Do we support search term replacement?
[email protected]d82443b2009-01-15 19:54:56447 mutable bool supports_replacements_;
448
449 // The replaceable parts of url (parsed_url_). These are ordered by index
450 // into the string, and may be empty.
451 mutable Replacements replacements_;
452
mpearson93e29f7d2016-01-27 20:09:28453 // Host, port, path, key and location of the search term. These are only set
454 // if the url contains one search term.
[email protected]d82443b2009-01-15 19:54:56455 mutable std::string host_;
mpearson93e29f7d2016-01-27 20:09:28456 mutable std::string port_;
[email protected]d82443b2009-01-15 19:54:56457 mutable std::string path_;
458 mutable std::string search_term_key_;
[email protected]b45334502014-04-30 19:44:05459 mutable url::Parsed::ComponentType search_term_key_location_;
jbroman50832022016-04-21 23:53:00460 mutable std::string search_term_value_prefix_;
461 mutable std::string search_term_value_suffix_;
[email protected]1a257262011-06-28 22:15:44462
[email protected]93b29062013-07-12 03:09:09463 mutable PostParams post_params_;
464
[email protected]1a257262011-06-28 22:15:44465 // Whether the contained URL is a pre-populated URL.
466 bool prepopulated_;
[email protected]d82443b2009-01-15 19:54:56467};
468
[email protected]573889f22012-04-07 01:31:54469
[email protected]573889f22012-04-07 01:31:54470// TemplateURL ----------------------------------------------------------------
471
472// A TemplateURL represents a single "search engine", defined primarily as a
473// subset of the Open Search Description Document
474// (http://www.opensearch.org/Specifications/OpenSearch) plus some extensions.
475// One TemplateURL contains several TemplateURLRefs, which correspond to various
476// different capabilities (e.g. doing searches or getting suggestions), as well
477// as a TemplateURLData containing other details like the name, keyword, etc.
478//
[email protected]168d08722014-06-18 07:13:28479// TemplateURLs are intended to be read-only for most users.
[email protected]573889f22012-04-07 01:31:54480// The TemplateURLService, which handles storing and manipulating TemplateURLs,
481// is made a friend so that it can be the exception to this pattern.
[email protected]d82443b2009-01-15 19:54:56482class TemplateURL {
483 public:
[email protected]bdcbcd82013-10-28 13:40:25484 enum Type {
485 // Regular search engine.
486 NORMAL,
487 // Installed by extension through Override Settings API.
488 NORMAL_CONTROLLED_BY_EXTENSION,
489 // The keyword associated with an extension that uses the Omnibox API.
490 OMNIBOX_API_EXTENSION,
ianwena27b1df2016-09-23 23:08:23491 // Installed only on this device. Should not be synced.
492 LOCAL,
[email protected]bdcbcd82013-10-28 13:40:25493 };
[email protected]c73b2b52014-06-27 09:42:33494
495 // An AssociatedExtensionInfo represents information about the extension that
496 // added the search engine.
497 struct AssociatedExtensionInfo {
a-v-yc134e762017-04-18 15:31:31498 AssociatedExtensionInfo(const std::string& extension_id,
499 base::Time install_time,
500 bool wants_to_be_default_engine);
[email protected]c73b2b52014-06-27 09:42:33501 ~AssociatedExtensionInfo();
502
Denis Yaroshevskiy361a59322018-02-12 20:16:12503 // Estimates dynamic memory usage.
504 // See base/trace_event/memory_usage_estimator.h for more info.
505 size_t EstimateMemoryUsage() const;
506
[email protected]c73b2b52014-06-27 09:42:33507 std::string extension_id;
508
foolip8534d162017-01-10 16:51:03509 // Used to resolve conflicts when there are multiple extensions specifying
510 // the default search engine. The most recently-installed wins.
511 base::Time install_time;
a-v-yc134e762017-04-18 15:31:31512
513 // Whether the search engine is supposed to be default.
514 bool wants_to_be_default_engine;
[email protected]c73b2b52014-06-27 09:42:33515 };
516
ianwena27b1df2016-09-23 23:08:23517 explicit TemplateURL(const TemplateURLData& data, Type type = NORMAL);
a-v-yc134e762017-04-18 15:31:31518
519 // Constructor for extension controlled engine. |type| must be
520 // NORMAL_CONTROLLED_BY_EXTENSION or OMNIBOX_API_EXTENSION.
521 TemplateURL(const TemplateURLData& data,
522 Type type,
523 std::string extension_id,
524 base::Time install_time,
525 bool wants_to_be_default_engine);
526
[email protected]dcd869c2010-08-30 20:15:25527 ~TemplateURL();
[email protected]d82443b2009-01-15 19:54:56528
[email protected]44ccc9f2014-06-20 17:36:21529 // Generates a suitable keyword for the specified url, which must be valid.
530 // This is guaranteed not to return an empty string, since TemplateURLs should
531 // never have an empty keyword.
jshin1fb76462016-04-05 22:13:03532 static base::string16 GenerateKeyword(const GURL& url);
[email protected]44ccc9f2014-06-20 17:36:21533
[email protected]9b74ab52012-03-30 16:08:07534 // Generates a favicon URL from the specified url.
535 static GURL GenerateFaviconURL(const GURL& url);
536
[email protected]c4b2af22014-05-11 19:48:53537 // Returns true if |t_url| and |data| are equal in all meaningful respects.
538 // Static to allow either or both params to be NULL.
539 static bool MatchesData(const TemplateURL* t_url,
[email protected]ce7ee5f2014-06-16 23:41:19540 const TemplateURLData* data,
541 const SearchTermsData& search_terms_data);
[email protected]c4b2af22014-05-11 19:48:53542
[email protected]573889f22012-04-07 01:31:54543 const TemplateURLData& data() const { return data_; }
544
mpearson3c6d7af2015-05-13 23:59:53545 const base::string16& short_name() const { return data_.short_name(); }
[email protected]4973efc2009-06-05 23:16:29546 // An accessor for the short_name, but adjusted so it can be appropriately
547 // displayed even if it is LTR and the UI is RTL.
[email protected]0085863a2013-12-06 21:19:03548 base::string16 AdjustedShortNameForLocaleDirection() const;
[email protected]bed9bd6c2009-04-21 17:27:47549
[email protected]0085863a2013-12-06 21:19:03550 const base::string16& keyword() const { return data_.keyword(); }
[email protected]c8085932012-04-05 22:08:16551
[email protected]573889f22012-04-07 01:31:54552 const std::string& url() const { return data_.url(); }
553 const std::string& suggestions_url() const { return data_.suggestions_url; }
[email protected]93b29062013-07-12 03:09:09554 const std::string& image_url() const { return data_.image_url; }
[email protected]2767c0fd2013-08-16 17:44:16555 const std::string& new_tab_url() const { return data_.new_tab_url; }
[email protected]448b17f52014-06-13 01:08:03556 const std::string& contextual_search_url() const {
557 return data_.contextual_search_url;
558 }
[email protected]93b29062013-07-12 03:09:09559 const std::string& search_url_post_params() const {
560 return data_.search_url_post_params;
561 }
562 const std::string& suggestions_url_post_params() const {
563 return data_.suggestions_url_post_params;
564 }
[email protected]93b29062013-07-12 03:09:09565 const std::string& image_url_post_params() const {
566 return data_.image_url_post_params;
567 }
[email protected]5b3078752012-10-09 18:54:16568 const std::vector<std::string>& alternate_urls() const {
569 return data_.alternate_urls;
570 }
[email protected]573889f22012-04-07 01:31:54571 const GURL& favicon_url() const { return data_.favicon_url; }
[email protected]9e0ef8582012-04-06 18:53:28572
Bernhard Bauer41c477c12017-06-22 09:24:48573 const GURL& logo_url() const { return data_.logo_url; }
574
Marc Treib41ed19d2017-08-22 09:17:13575 const GURL& doodle_url() const { return data_.doodle_url; }
576
[email protected]573889f22012-04-07 01:31:54577 const GURL& originating_url() const { return data_.originating_url; }
578
[email protected]573889f22012-04-07 01:31:54579 bool safe_for_autoreplace() const { return data_.safe_for_autoreplace; }
[email protected]d82443b2009-01-15 19:54:56580
[email protected]d82443b2009-01-15 19:54:56581 const std::vector<std::string>& input_encodings() const {
[email protected]573889f22012-04-07 01:31:54582 return data_.input_encodings;
[email protected]d82443b2009-01-15 19:54:56583 }
584
[email protected]573889f22012-04-07 01:31:54585 TemplateURLID id() const { return data_.id; }
[email protected]d82443b2009-01-15 19:54:56586
[email protected]573889f22012-04-07 01:31:54587 base::Time date_created() const { return data_.date_created; }
588 base::Time last_modified() const { return data_.last_modified; }
ltian8b5fc832016-12-02 23:43:35589 base::Time last_visited() const { return data_.last_visited; }
[email protected]b37bdfe2012-03-16 20:53:27590
[email protected]573889f22012-04-07 01:31:54591 bool created_by_policy() const { return data_.created_by_policy; }
[email protected]d82443b2009-01-15 19:54:56592
[email protected]573889f22012-04-07 01:31:54593 int usage_count() const { return data_.usage_count; }
594
595 int prepopulate_id() const { return data_.prepopulate_id; }
596
597 const std::string& sync_guid() const { return data_.sync_guid; }
[email protected]528539d2011-07-19 16:36:55598
vitbar5bd8c252016-01-29 18:44:51599 const std::vector<TemplateURLRef>& url_refs() const { return url_refs_; }
Tommy C. Li65437802018-03-07 02:58:48600 const TemplateURLRef& url_ref() const {
601 // Sanity check for https://crbug.com/781703.
602 CHECK(!url_refs_.empty());
603 return url_refs_.back();
604 }
[email protected]360ba052012-04-04 17:26:13605 const TemplateURLRef& suggestions_url_ref() const {
606 return suggestions_url_ref_;
607 }
[email protected]93b29062013-07-12 03:09:09608 const TemplateURLRef& image_url_ref() const { return image_url_ref_; }
[email protected]2767c0fd2013-08-16 17:44:16609 const TemplateURLRef& new_tab_url_ref() const { return new_tab_url_ref_; }
[email protected]448b17f52014-06-13 01:08:03610 const TemplateURLRef& contextual_search_url_ref() const {
611 return contextual_search_url_ref_;
612 }
[email protected]360ba052012-04-04 17:26:13613
ianwena27b1df2016-09-23 23:08:23614 Type type() const { return type_; }
ianwena27b1df2016-09-23 23:08:23615
a-v-y858416e2017-03-01 16:42:45616 const AssociatedExtensionInfo* GetExtensionInfoForTesting() const {
617 return extension_info_.get();
[email protected]e7f47c62014-07-24 13:23:19618 }
619
[email protected]9b74ab52012-03-30 16:08:07620 // Returns true if |url| supports replacement.
[email protected]ce7ee5f2014-06-16 23:41:19621 bool SupportsReplacement(const SearchTermsData& search_terms_data) const;
[email protected]9b74ab52012-03-30 16:08:07622
[email protected]c4b2af22014-05-11 19:48:53623 // Returns true if any URLRefs use Googe base URLs.
[email protected]ce7ee5f2014-06-16 23:41:19624 bool HasGoogleBaseURLs(const SearchTermsData& search_terms_data) const;
[email protected]c4b2af22014-05-11 19:48:53625
[email protected]7b596f62012-05-08 01:34:25626 // Returns true if this TemplateURL uses Google base URLs and has a keyword
627 // of "google.TLD". We use this to decide whether we can automatically
628 // update the keyword to reflect the current Google base URL TLD.
[email protected]ce7ee5f2014-06-16 23:41:19629 bool IsGoogleSearchURLWithReplaceableKeyword(
630 const SearchTermsData& search_terms_data) const;
[email protected]7b596f62012-05-08 01:34:25631
632 // Returns true if the keywords match or if
[email protected]c6dea6b2014-04-30 18:06:04633 // IsGoogleSearchURLWithReplaceableKeyword() is true for both |this| and
634 // |other|.
[email protected]ce7ee5f2014-06-16 23:41:19635 bool HasSameKeywordAs(const TemplateURLData& other,
636 const SearchTermsData& search_terms_data) const;
[email protected]7b596f62012-05-08 01:34:25637
[email protected]bdcbcd82013-10-28 13:40:25638 // Returns the id of the extension that added this search engine. Only call
639 // this for TemplateURLs of type NORMAL_CONTROLLED_BY_EXTENSION or
640 // OMNIBOX_API_EXTENSION.
[email protected]9b74ab52012-03-30 16:08:07641 std::string GetExtensionId() const;
[email protected]9b74ab52012-03-30 16:08:07642
vitbarda6a50182016-06-14 18:20:32643 // Returns the type of this search engine, or SEARCH_ENGINE_OTHER if no
644 // engines match.
645 SearchEngineType GetEngineType(
646 const SearchTermsData& search_terms_data) const;
647
[email protected]5b3078752012-10-09 18:54:16648 // Use the alternate URLs and the search URL to match the provided |url|
649 // and extract |search_terms| from it. Returns false and an empty
Peter Kastingd03254082017-12-01 03:46:09650 // |search_terms| if no search terms can be matched. The URLs are matched in
651 // the order listed in |url_refs_| (see comment there).
[email protected]ce7ee5f2014-06-16 23:41:19652 bool ExtractSearchTermsFromURL(const GURL& url,
653 const SearchTermsData& search_terms_data,
blundelld130d592015-06-21 19:29:13654 base::string16* search_terms) const;
[email protected]1ff6ce42013-03-05 00:54:34655
656 // Returns true if non-empty search terms could be extracted from |url| using
657 // ExtractSearchTermsFromURL(). In other words, this returns whether |url|
658 // could be the result of performing a search with |this|.
blundelld130d592015-06-21 19:29:13659 bool IsSearchURL(const GURL& url,
660 const SearchTermsData& search_terms_data) const;
[email protected]1ff6ce42013-03-05 00:54:34661
[email protected]f62e30f52013-03-23 03:45:15662 // Given a |url| corresponding to this TemplateURL, identifies the search
663 // terms and replaces them with the ones in |search_terms_args|, leaving the
664 // other parameters untouched. If the replacement fails, returns false and
665 // leaves |result| untouched. This is used by mobile ports to perform query
666 // refinement.
667 bool ReplaceSearchTermsInURL(
668 const GURL& url,
669 const TemplateURLRef::SearchTermsArgs& search_terms_args,
[email protected]ce7ee5f2014-06-16 23:41:19670 const SearchTermsData& search_terms_data,
jeffschiller8aa7a4e2017-04-23 02:22:10671 GURL* result) const;
[email protected]f62e30f52013-03-23 03:45:15672
673 // Encodes the search terms from |search_terms_args| so that we know the
674 // |input_encoding|. Returns the |encoded_terms| and the
675 // |encoded_original_query|. |encoded_terms| may be escaped as path or query
676 // depending on |is_in_query|; |encoded_original_query| is always escaped as
677 // query.
678 void EncodeSearchTerms(
679 const TemplateURLRef::SearchTermsArgs& search_terms_args,
680 bool is_in_query,
681 std::string* input_encoding,
[email protected]0085863a2013-12-06 21:19:03682 base::string16* encoded_terms,
683 base::string16* encoded_original_query) const;
[email protected]f62e30f52013-03-23 03:45:15684
[email protected]44ccc9f2014-06-20 17:36:21685 // Returns the search url for this template URL.
686 // Returns an empty GURL if this template URL has no url().
687 GURL GenerateSearchURL(const SearchTermsData& search_terms_data) const;
688
vitbar5bd8c252016-01-29 18:44:51689 // TemplateURL internally caches values derived from a passed SearchTermsData
690 // to make its functions quick. This method invalidates any cached values and
691 // it should be called after SearchTermsData has been changed.
692 void InvalidateCachedValues() const;
693
Denis Yaroshevskiy361a59322018-02-12 20:16:12694 // Estimates dynamic memory usage.
695 // See base/trace_event/memory_usage_estimator.h for more info.
696 size_t EstimateMemoryUsage() const;
697
[email protected]d82443b2009-01-15 19:54:56698 private:
[email protected]8e5c89a2011-06-07 18:13:33699 friend class TemplateURLService;
[email protected]573889f22012-04-07 01:31:54700
[email protected]6b564782012-05-08 21:52:42701 void CopyFrom(const TemplateURL& other);
702
[email protected]573889f22012-04-07 01:31:54703 void SetURL(const std::string& url);
704 void SetPrepopulateId(int id);
[email protected]d82443b2009-01-15 19:54:56705
[email protected]7b596f62012-05-08 01:34:25706 // Resets the keyword if IsGoogleSearchURLWithReplaceableKeyword() or |force|.
707 // The |force| parameter is useful when the existing keyword is known to be
708 // a placeholder. The resulting keyword is generated using
[email protected]44ccc9f2014-06-20 17:36:21709 // GenerateSearchURL() and GenerateKeyword().
[email protected]ce7ee5f2014-06-16 23:41:19710 void ResetKeywordIfNecessary(const SearchTermsData& search_terms_data,
711 bool force);
[email protected]7b596f62012-05-08 01:34:25712
Peter Kastingd03254082017-12-01 03:46:09713 // Resizes the |url_refs_| vector, which always holds the search URL as the
714 // last item.
vitbar5bd8c252016-01-29 18:44:51715 void ResizeURLRefVector();
716
[email protected]f62e30f52013-03-23 03:45:15717 // Uses the alternate URLs and the search URL to match the provided |url|
718 // and extract |search_terms| from it as well as the |search_terms_component|
719 // (either REF or QUERY) and |search_terms_component| at which the
720 // |search_terms| are found in |url|. See also ExtractSearchTermsFromURL().
[email protected]b45334502014-04-30 19:44:05721 bool FindSearchTermsInURL(const GURL& url,
722 const SearchTermsData& search_terms_data,
723 base::string16* search_terms,
724 url::Parsed::ComponentType* search_terms_component,
blundelld130d592015-06-21 19:29:13725 url::Component* search_terms_position) const;
[email protected]f62e30f52013-03-23 03:45:15726
[email protected]573889f22012-04-07 01:31:54727 TemplateURLData data_;
vitbar5bd8c252016-01-29 18:44:51728
729 // Contains TemplateURLRefs corresponding to the alternate URLs and the search
Peter Kastingd03254082017-12-01 03:46:09730 // URL, in priority order: the URL at index 0 is treated as the highest
731 // priority and the primary search URL is treated as the lowest priority. For
732 // example, if a TemplateURL has alternate URL "http://foo/#q={searchTerms}"
733 // and search URL "http://foo/?q={searchTerms}", and the URL to be decoded is
734 // "http://foo/?q=a#q=b", the alternate URL will match first and the decoded
735 // search term will be "b". Note that since every TemplateURLRef has a
736 // primary search URL, this vector is never empty.
vitbar5bd8c252016-01-29 18:44:51737 std::vector<TemplateURLRef> url_refs_;
738
[email protected]360ba052012-04-04 17:26:13739 TemplateURLRef suggestions_url_ref_;
[email protected]93b29062013-07-12 03:09:09740 TemplateURLRef image_url_ref_;
[email protected]2767c0fd2013-08-16 17:44:16741 TemplateURLRef new_tab_url_ref_;
[email protected]448b17f52014-06-13 01:08:03742 TemplateURLRef contextual_search_url_ref_;
dchengd967d9502016-04-21 22:36:51743 std::unique_ptr<AssociatedExtensionInfo> extension_info_;
[email protected]360ba052012-04-04 17:26:13744
vasilii20991192016-10-06 09:37:50745 const Type type_;
ianwena27b1df2016-09-23 23:08:23746
vitbarda6a50182016-06-14 18:20:32747 // Caches the computed engine type across successive calls to GetEngineType().
748 mutable SearchEngineType engine_type_;
749
[email protected]d82443b2009-01-15 19:54:56750 // TODO(sky): Add date last parsed OSD file.
[email protected]6b564782012-05-08 21:52:42751
752 DISALLOW_COPY_AND_ASSIGN(TemplateURL);
[email protected]d82443b2009-01-15 19:54:56753};
754
[email protected]d550cb02014-06-25 06:48:11755#endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_H_