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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 // Returns |url| altered by stripping off "www.", converting https protocol | 177 // Returns |url| altered by stripping off "www.", converting https protocol |
178 // to http, and stripping excess query parameters. These conversions are | 178 // to http, and stripping excess query parameters. These conversions are |
179 // merely to allow comparisons to remove likely duplicates; these URLs are | 179 // merely to allow comparisons to remove likely duplicates; these URLs are |
180 // not used as actual destination URLs. If |template_url_service| is not | 180 // not used as actual destination URLs. If |template_url_service| is not |
181 // NULL, it is used to get a template URL corresponding to this match. If | 181 // NULL, it is used to get a template URL corresponding to this match. If |
182 // the match's keyword is known, it can be passed in. Otherwise, it can be | 182 // the match's keyword is known, it can be passed in. Otherwise, it can be |
183 // left empty and the template URL (if any) is determined from the | 183 // left empty and the template URL (if any) is determined from the |
184 // destination's hostname. The template URL is used to strip off query args | 184 // destination's hostname. The template URL is used to strip off query args |
185 // other than the search terms themselves that would otherwise prevent doing | 185 // other than the search terms themselves that would otherwise prevent doing |
186 // proper deduping. | 186 // proper deduping. |input_words| is used to decide if the scheme is allowed |
187 static GURL GURLToStrippedGURL(const GURL& url, | 187 // to be altered during stripping. (If the user indicated a desired scheme, |
188 TemplateURLService* template_url_service, | 188 // we prevent two URLs with different schemes from having the same stripped |
189 const base::string16& keyword); | 189 // GURL.) |
| 190 static GURL GURLToStrippedGURL( |
| 191 const GURL& url, |
| 192 const std::vector<base::string16>& input_words, |
| 193 TemplateURLService* template_url_service, |
| 194 const base::string16& keyword); |
190 | 195 |
191 // Computes the stripped destination URL (via GURLToStrippedGURL()) and | 196 // Computes the stripped destination URL (via GURLToStrippedGURL()) and |
192 // stores the result in |stripped_destination_url|. | 197 // stores the result in |stripped_destination_url|. |
193 void ComputeStrippedDestinationURL(TemplateURLService* template_url_service); | 198 void ComputeStrippedDestinationURL( |
| 199 const std::vector<base::string16>& input_words, |
| 200 TemplateURLService* template_url_service); |
194 | 201 |
195 // Sets |allowed_to_be_default_match| to true if this match is effectively | 202 // Sets |allowed_to_be_default_match| to true if this match is effectively |
196 // the URL-what-you-typed match (i.e., would be dupped against the UWYT | 203 // the URL-what-you-typed match (i.e., would be dupped against the UWYT |
197 // match when AutocompleteResult merges matches). |canonical_input_url| is | 204 // match when AutocompleteResult merges matches). |canonical_input_url| is |
198 // the AutocompleteInput interpreted as a URL (i.e., | 205 // the AutocompleteInput interpreted as a URL (i.e., |
199 // AutocompleteInput::canonicalized_url()). | 206 // AutocompleteInput::canonicalized_url()). |
200 void EnsureUWYTIsAllowedToBeDefault(const GURL& canonical_input_url, | 207 void EnsureUWYTIsAllowedToBeDefault( |
201 TemplateURLService* template_url_service); | 208 const GURL& canonical_input_url, |
| 209 const std::vector<base::string16>& input_words, |
| 210 TemplateURLService* template_url_service); |
202 | 211 |
203 // Gets data relevant to whether there should be any special keyword-related | 212 // Gets data relevant to whether there should be any special keyword-related |
204 // UI shown for this match. If this match represents a selected keyword, i.e. | 213 // UI shown for this match. If this match represents a selected keyword, i.e. |
205 // the UI should be "in keyword mode", |keyword| will be set to the keyword | 214 // the UI should be "in keyword mode", |keyword| will be set to the keyword |
206 // and |is_keyword_hint| will be set to false. If this match has a non-NULL | 215 // and |is_keyword_hint| will be set to false. If this match has a non-NULL |
207 // |associated_keyword|, i.e. we should show a "Press [tab] to search ___" | 216 // |associated_keyword|, i.e. we should show a "Press [tab] to search ___" |
208 // hint and allow the user to toggle into keyword mode, |keyword| will be set | 217 // hint and allow the user to toggle into keyword mode, |keyword| will be set |
209 // to the associated keyword and |is_keyword_hint| will be set to true. Note | 218 // to the associated keyword and |is_keyword_hint| will be set to true. Note |
210 // that only one of these states can be in effect at once. In all other | 219 // that only one of these states can be in effect at once. In all other |
211 // cases, |keyword| will be cleared, even when our member variable |keyword| | 220 // cases, |keyword| will be cleared, even when our member variable |keyword| |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 const base::string16& text, | 394 const base::string16& text, |
386 const ACMatchClassifications& classifications) const; | 395 const ACMatchClassifications& classifications) const; |
387 #endif | 396 #endif |
388 }; | 397 }; |
389 | 398 |
390 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 399 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
391 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 400 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
392 typedef std::vector<AutocompleteMatch> ACMatches; | 401 typedef std::vector<AutocompleteMatch> ACMatches; |
393 | 402 |
394 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ | 403 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ |
OLD | NEW |