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