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_AUTOCOMPLETE_MATCH_H_ | 5 #ifndef COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ |
6 #define COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ | 6 #define COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 180 |
181 // Returns |url| altered by stripping off "www.", converting https protocol | 181 // Returns |url| altered by stripping off "www.", converting https protocol |
182 // to http, and stripping excess query parameters. These conversions are | 182 // to http, and stripping excess query parameters. These conversions are |
183 // merely to allow comparisons to remove likely duplicates; these URLs are | 183 // merely to allow comparisons to remove likely duplicates; these URLs are |
184 // not used as actual destination URLs. If |template_url_service| is not | 184 // not used as actual destination URLs. If |template_url_service| is not |
185 // NULL, it is used to get a template URL corresponding to this match. If | 185 // NULL, it is used to get a template URL corresponding to this match. If |
186 // the match's keyword is known, it can be passed in. Otherwise, it can be | 186 // the match's keyword is known, it can be passed in. Otherwise, it can be |
187 // left empty and the template URL (if any) is determined from the | 187 // left empty and the template URL (if any) is determined from the |
188 // destination's hostname. The template URL is used to strip off query args | 188 // destination's hostname. The template URL is used to strip off query args |
189 // other than the search terms themselves that would otherwise prevent doing | 189 // other than the search terms themselves that would otherwise prevent doing |
190 // proper deduping. | 190 // proper deduping. |input| is used to decide if the scheme is allowed to |
| 191 // be altered during stripping. If this URL, minus the scheme and separator, |
| 192 // starts with any the terms in input.terms_prefixed_by_http_or_https(), we |
| 193 // avoid converting an HTTPS scheme to HTTP. This means URLs that differ |
| 194 // only by these schemes won't be marked as dupes, since the distinction |
| 195 // seems to matter to the user. |languages| is used to format punycoded |
| 196 // domain names to UTF-8 for the aforementioned duplicate detection. |
191 static GURL GURLToStrippedGURL(const GURL& url, | 197 static GURL GURLToStrippedGURL(const GURL& url, |
| 198 const AutocompleteInput& input, |
| 199 const std::string& languages, |
192 TemplateURLService* template_url_service, | 200 TemplateURLService* template_url_service, |
193 const base::string16& keyword); | 201 const base::string16& keyword); |
194 | 202 |
195 // Computes the stripped destination URL (via GURLToStrippedGURL()) and | 203 // Computes the stripped destination URL (via GURLToStrippedGURL()) and |
196 // stores the result in |stripped_destination_url|. | 204 // stores the result in |stripped_destination_url|. |input| and |languages| |
197 void ComputeStrippedDestinationURL(TemplateURLService* template_url_service); | 205 // are used for the same purpose as in GURLToStrippedGURL(). |
| 206 void ComputeStrippedDestinationURL( |
| 207 const AutocompleteInput& input, |
| 208 const std::string& languages, |
| 209 TemplateURLService* template_url_service); |
198 | 210 |
199 // Sets |allowed_to_be_default_match| to true if this match is effectively | 211 // Sets |allowed_to_be_default_match| to true if this match is effectively |
200 // the URL-what-you-typed match (i.e., would be dupped against the UWYT | 212 // the URL-what-you-typed match (i.e., would be dupped against the UWYT |
201 // match when AutocompleteResult merges matches). |canonical_input_url| is | 213 // match when AutocompleteResult merges matches). |languages| is used |
202 // the AutocompleteInput interpreted as a URL (i.e., | 214 // for the same purpose as in GURLToStrippedGURL(). |
203 // AutocompleteInput::canonicalized_url()). | 215 void EnsureUWYTIsAllowedToBeDefault( |
204 void EnsureUWYTIsAllowedToBeDefault(const GURL& canonical_input_url, | 216 const AutocompleteInput& input, |
205 TemplateURLService* template_url_service); | 217 const std::string& languages, |
| 218 TemplateURLService* template_url_service); |
206 | 219 |
207 // Gets data relevant to whether there should be any special keyword-related | 220 // Gets data relevant to whether there should be any special keyword-related |
208 // UI shown for this match. If this match represents a selected keyword, i.e. | 221 // UI shown for this match. If this match represents a selected keyword, i.e. |
209 // the UI should be "in keyword mode", |keyword| will be set to the keyword | 222 // the UI should be "in keyword mode", |keyword| will be set to the keyword |
210 // and |is_keyword_hint| will be set to false. If this match has a non-NULL | 223 // and |is_keyword_hint| will be set to false. If this match has a non-NULL |
211 // |associated_keyword|, i.e. we should show a "Press [tab] to search ___" | 224 // |associated_keyword|, i.e. we should show a "Press [tab] to search ___" |
212 // hint and allow the user to toggle into keyword mode, |keyword| will be set | 225 // hint and allow the user to toggle into keyword mode, |keyword| will be set |
213 // to the associated keyword and |is_keyword_hint| will be set to true. Note | 226 // to the associated keyword and |is_keyword_hint| will be set to true. Note |
214 // that only one of these states can be in effect at once. In all other | 227 // that only one of these states can be in effect at once. In all other |
215 // cases, |keyword| will be cleared, even when our member variable |keyword| | 228 // cases, |keyword| will be cleared, even when our member variable |keyword| |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 const base::string16& text, | 415 const base::string16& text, |
403 const ACMatchClassifications& classifications) const; | 416 const ACMatchClassifications& classifications) const; |
404 #endif | 417 #endif |
405 }; | 418 }; |
406 | 419 |
407 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 420 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
408 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 421 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
409 typedef std::vector<AutocompleteMatch> ACMatches; | 422 typedef std::vector<AutocompleteMatch> ACMatches; |
410 | 423 |
411 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ | 424 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ |
OLD | NEW |