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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 // A static version GetTemplateURL() that takes the match's keyword and | 168 // A static version GetTemplateURL() that takes the match's keyword and |
169 // match's hostname as parameters. In short, returns the TemplateURL | 169 // match's hostname as parameters. In short, returns the TemplateURL |
170 // associated with |keyword| if it exists; otherwise returns the TemplateURL | 170 // associated with |keyword| if it exists; otherwise returns the TemplateURL |
171 // associated with |host| if it exists. | 171 // associated with |host| if it exists. |
172 static TemplateURL* GetTemplateURLWithKeyword( | 172 static TemplateURL* GetTemplateURLWithKeyword( |
173 TemplateURLService* template_url_service, | 173 TemplateURLService* template_url_service, |
174 const base::string16& keyword, | 174 const base::string16& keyword, |
175 const std::string& host); | 175 const std::string& host); |
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, making sure the path ends in a "/", and stripping excess query |
179 // merely to allow comparisons to remove likely duplicates; these URLs are | 179 // parameters. These conversions are merely to allow comparisons to remove |
180 // not used as actual destination URLs. If |template_url_service| is not | 180 // likely duplicates; these URLs are not used as actual destination URLs. |
181 // NULL, it is used to get a template URL corresponding to this match. If | 181 // If |template_url_service| is not NULL, it is used to get a template URL |
182 // the match's keyword is known, it can be passed in. Otherwise, it can be | 182 // corresponding to this match. If the match's keyword is known, it can be |
183 // left empty and the template URL (if any) is determined from the | 183 // passed in. Otherwise, it can be left empty and the template URL (if any) |
184 // destination's hostname. The template URL is used to strip off query args | 184 // is determined from the destination's hostname. The template URL is used |
185 // other than the search terms themselves that would otherwise prevent doing | 185 // to strip off query args other than the search terms themselves that would |
186 // proper deduping. | 186 // otherwise prevent doing proper deduping. |
187 static GURL GURLToStrippedGURL(const GURL& url, | 187 static GURL GURLToStrippedGURL(const GURL& url, |
188 TemplateURLService* template_url_service, | 188 TemplateURLService* template_url_service, |
189 const base::string16& keyword); | 189 const base::string16& keyword); |
190 | 190 |
191 // Computes the stripped destination URL (via GURLToStrippedGURL()) and | 191 // Computes the stripped destination URL (via GURLToStrippedGURL()) and |
192 // stores the result in |stripped_destination_url|. | 192 // stores the result in |stripped_destination_url|. |
193 void ComputeStrippedDestinationURL(TemplateURLService* template_url_service); | 193 void ComputeStrippedDestinationURL(TemplateURLService* template_url_service); |
194 | 194 |
195 // Sets |allowed_to_be_default_match| to true if this match is effectively | 195 // 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 | 196 // the URL-what-you-typed match (i.e., would be dupped against the UWYT |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 // should only set this flag if ".com" will be inline autocompleted; | 300 // should only set this flag if ".com" will be inline autocompleted; |
301 // and a navigation to "foo/" (an intranet host) or search for "foo" | 301 // and a navigation to "foo/" (an intranet host) or search for "foo" |
302 // should set this flag. | 302 // should set this flag. |
303 bool allowed_to_be_default_match; | 303 bool allowed_to_be_default_match; |
304 | 304 |
305 // The URL to actually load when the autocomplete item is selected. This URL | 305 // The URL to actually load when the autocomplete item is selected. This URL |
306 // should be canonical so we can compare URLs with strcmp to avoid dupes. | 306 // should be canonical so we can compare URLs with strcmp to avoid dupes. |
307 // It may be empty if there is no possible navigation. | 307 // It may be empty if there is no possible navigation. |
308 GURL destination_url; | 308 GURL destination_url; |
309 | 309 |
310 // The destination URL with "www." stripped off for better dupe finding. | 310 // The destination URL somewhat normalized for better dupe finding. |
Peter Kasting
2015/06/11 23:05:37
Nit: Add comma before "somewhat"
Mark P
2015/06/12 17:25:57
Done.
| |
311 GURL stripped_destination_url; | 311 GURL stripped_destination_url; |
312 | 312 |
313 // The main text displayed in the address bar dropdown. | 313 // The main text displayed in the address bar dropdown. |
314 base::string16 contents; | 314 base::string16 contents; |
315 ACMatchClassifications contents_class; | 315 ACMatchClassifications contents_class; |
316 | 316 |
317 // Additional helper text for each entry, such as a title or description. | 317 // Additional helper text for each entry, such as a title or description. |
318 base::string16 description; | 318 base::string16 description; |
319 ACMatchClassifications description_class; | 319 ACMatchClassifications description_class; |
320 | 320 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 const base::string16& text, | 385 const base::string16& text, |
386 const ACMatchClassifications& classifications) const; | 386 const ACMatchClassifications& classifications) const; |
387 #endif | 387 #endif |
388 }; | 388 }; |
389 | 389 |
390 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 390 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
391 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 391 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
392 typedef std::vector<AutocompleteMatch> ACMatches; | 392 typedef std::vector<AutocompleteMatch> ACMatches; |
393 | 393 |
394 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ | 394 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ |
OLD | NEW |