OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_MATCH_H_ | 5 #ifndef COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_MATCH_H_ |
6 #define COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_MATCH_H_ | 6 #define COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_MATCH_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // NULL, it is used to get a template URL corresponding to this match. If | 198 // NULL, it is used to get a template URL corresponding to this match. If |
199 // the match's keyword is known, it can be passed in. Otherwise, it can be | 199 // the match's keyword is known, it can be passed in. Otherwise, it can be |
200 // left empty and the template URL (if any) is determined from the | 200 // left empty and the template URL (if any) is determined from the |
201 // destination's hostname. The template URL is used to strip off query args | 201 // destination's hostname. The template URL is used to strip off query args |
202 // other than the search terms themselves that would otherwise prevent doing | 202 // other than the search terms themselves that would otherwise prevent doing |
203 // proper deduping. |input| is used to decide if the scheme is allowed to | 203 // proper deduping. |input| is used to decide if the scheme is allowed to |
204 // be altered during stripping. If this URL, minus the scheme and separator, | 204 // be altered during stripping. If this URL, minus the scheme and separator, |
205 // starts with any the terms in input.terms_prefixed_by_http_or_https(), we | 205 // starts with any the terms in input.terms_prefixed_by_http_or_https(), we |
206 // avoid converting an HTTPS scheme to HTTP. This means URLs that differ | 206 // avoid converting an HTTPS scheme to HTTP. This means URLs that differ |
207 // only by these schemes won't be marked as dupes, since the distinction | 207 // only by these schemes won't be marked as dupes, since the distinction |
208 // seems to matter to the user. |languages| is used to format punycoded | 208 // seems to matter to the user. |
209 // domain names to UTF-8 for the aforementioned duplicate detection. | |
210 static GURL GURLToStrippedGURL(const GURL& url, | 209 static GURL GURLToStrippedGURL(const GURL& url, |
211 const AutocompleteInput& input, | 210 const AutocompleteInput& input, |
212 const std::string& languages, | |
213 TemplateURLService* template_url_service, | 211 TemplateURLService* template_url_service, |
214 const base::string16& keyword); | 212 const base::string16& keyword); |
215 | 213 |
216 // Computes the stripped destination URL (via GURLToStrippedGURL()) and | 214 // Computes the stripped destination URL (via GURLToStrippedGURL()) and |
217 // stores the result in |stripped_destination_url|. |input| and |languages| | 215 // stores the result in |stripped_destination_url|. |input| is used for the |
218 // are used for the same purpose as in GURLToStrippedGURL(). | 216 // same purpose as in GURLToStrippedGURL(). |
219 void ComputeStrippedDestinationURL( | 217 void ComputeStrippedDestinationURL(const AutocompleteInput& input, |
220 const AutocompleteInput& input, | 218 TemplateURLService* template_url_service); |
221 const std::string& languages, | |
222 TemplateURLService* template_url_service); | |
223 | 219 |
224 // Sets |allowed_to_be_default_match| to true if this match is effectively | 220 // Sets |allowed_to_be_default_match| to true if this match is effectively |
225 // the URL-what-you-typed match (i.e., would be dupped against the UWYT | 221 // the URL-what-you-typed match (i.e., would be dupped against the UWYT |
226 // match when AutocompleteResult merges matches). |languages| is used | 222 // match when AutocompleteResult merges matches). |
227 // for the same purpose as in GURLToStrippedGURL(). | |
228 void EnsureUWYTIsAllowedToBeDefault( | 223 void EnsureUWYTIsAllowedToBeDefault( |
229 const AutocompleteInput& input, | 224 const AutocompleteInput& input, |
230 const std::string& languages, | |
231 TemplateURLService* template_url_service); | 225 TemplateURLService* template_url_service); |
232 | 226 |
233 // Gets data relevant to whether there should be any special keyword-related | 227 // Gets data relevant to whether there should be any special keyword-related |
234 // UI shown for this match. If this match represents a selected keyword, i.e. | 228 // UI shown for this match. If this match represents a selected keyword, i.e. |
235 // the UI should be "in keyword mode", |keyword| will be set to the keyword | 229 // the UI should be "in keyword mode", |keyword| will be set to the keyword |
236 // and |is_keyword_hint| will be set to false. If this match has a non-NULL | 230 // and |is_keyword_hint| will be set to false. If this match has a non-NULL |
237 // |associated_keyword|, i.e. we should show a "Press [tab] to search ___" | 231 // |associated_keyword|, i.e. we should show a "Press [tab] to search ___" |
238 // hint and allow the user to toggle into keyword mode, |keyword| will be set | 232 // hint and allow the user to toggle into keyword mode, |keyword| will be set |
239 // to the associated keyword and |is_keyword_hint| will be set to true. Note | 233 // to the associated keyword and |is_keyword_hint| will be set to true. Note |
240 // that only one of these states can be in effect at once. In all other | 234 // that only one of these states can be in effect at once. In all other |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 const base::string16& text, | 422 const base::string16& text, |
429 const ACMatchClassifications& classifications) const; | 423 const ACMatchClassifications& classifications) const; |
430 #endif | 424 #endif |
431 }; | 425 }; |
432 | 426 |
433 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 427 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
434 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 428 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
435 typedef std::vector<AutocompleteMatch> ACMatches; | 429 typedef std::vector<AutocompleteMatch> ACMatches; |
436 | 430 |
437 #endif // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_MATCH_H_ | 431 #endif // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_MATCH_H_ |
OLD | NEW |