OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 static base::string16 SanitizeString(const base::string16& text); | 161 static base::string16 SanitizeString(const base::string16& text); |
162 | 162 |
163 // Convenience function to check if |type| is a search (as opposed to a URL or | 163 // Convenience function to check if |type| is a search (as opposed to a URL or |
164 // an extension). | 164 // an extension). |
165 static bool IsSearchType(Type type); | 165 static bool IsSearchType(Type type); |
166 | 166 |
167 // Convenience function to check if |type| is a special search suggest type - | 167 // Convenience function to check if |type| is a special search suggest type - |
168 // like entity, personalized, profile or postfix. | 168 // like entity, personalized, profile or postfix. |
169 static bool IsSpecializedSearchType(Type type); | 169 static bool IsSpecializedSearchType(Type type); |
170 | 170 |
171 // Copies the destination_url with "www." stripped off to | 171 // A static version GetTemplateURL() that takes the match's keyword and |
172 // |stripped_destination_url| and also converts https protocol to | 172 // match's hostname as parameters. In short, returns the TemplateURL |
173 // http. These two conversions are merely to allow comparisons to | 173 // associated with |keyword| if it exists; otherwise returns the TemplateURL |
174 // remove likely duplicates; these URLs are not used as actual | 174 // associated with |host| if it exists. |
175 // destination URLs. This method is invoked internally by the | 175 static TemplateURL* GetTemplateURLWithKeyword( |
176 // AutocompleteResult and does not normally need to be invoked. | 176 TemplateURLService* template_url_service, |
177 // If |template_url_service| is not NULL, it is used to get a template URL | 177 const base::string16& keyword, |
178 // corresponding to this match. The template is used to strip off query args | 178 const std::string& host); |
179 // other than the search terms themselves that would otherwise prevent from | 179 |
| 180 // Returns |url| altered by stripping off "www.", converting https protocol |
| 181 // to http, and stripping excess query parameters. These conversions are |
| 182 // merely to allow comparisons to remove likely duplicates; these URLs are |
| 183 // not used as actual destination URLs. If |template_url_service| is not |
| 184 // NULL, it is used to get a template URL corresponding to this match. If |
| 185 // the match's keyword is known, it can be passed in. Otherwise, it can be |
| 186 // left empty and the template URL (if any) is determined from the |
| 187 // destination's hostname. The template URL is used to strip off query args |
| 188 // other than the search terms themselves that would otherwise prevent doing |
180 // proper deduping. | 189 // proper deduping. |
| 190 static GURL GURLToStrippedGURL(const GURL& url, |
| 191 TemplateURLService* template_url_service, |
| 192 const base::string16& keyword); |
| 193 |
| 194 // Computes the stripped destination URL (via GURLToStrippedGURL()) and |
| 195 // stores the result in |stripped_destination_url|. |
181 void ComputeStrippedDestinationURL(TemplateURLService* template_url_service); | 196 void ComputeStrippedDestinationURL(TemplateURLService* template_url_service); |
182 | 197 |
| 198 // Sets |allowed_to_be_default_match| to true if this match is effectively |
| 199 // the URL-what-you-typed match (i.e., would be dupped against the UWYT |
| 200 // match when AutocompleteResult merges matches). |canonical_input_url| is |
| 201 // the AutocompleteInput interpreted as a URL (i.e., |
| 202 // AutocompleteInput::canonicalized_url()). |
| 203 void EnsureUWYTIsAllowedToBeDefault(const GURL& canonical_input_url, |
| 204 TemplateURLService* template_url_service); |
| 205 |
183 // Gets data relevant to whether there should be any special keyword-related | 206 // Gets data relevant to whether there should be any special keyword-related |
184 // UI shown for this match. If this match represents a selected keyword, i.e. | 207 // UI shown for this match. If this match represents a selected keyword, i.e. |
185 // the UI should be "in keyword mode", |keyword| will be set to the keyword | 208 // the UI should be "in keyword mode", |keyword| will be set to the keyword |
186 // and |is_keyword_hint| will be set to false. If this match has a non-NULL | 209 // and |is_keyword_hint| will be set to false. If this match has a non-NULL |
187 // |associated_keyword|, i.e. we should show a "Press [tab] to search ___" | 210 // |associated_keyword|, i.e. we should show a "Press [tab] to search ___" |
188 // hint and allow the user to toggle into keyword mode, |keyword| will be set | 211 // hint and allow the user to toggle into keyword mode, |keyword| will be set |
189 // to the associated keyword and |is_keyword_hint| will be set to true. Note | 212 // to the associated keyword and |is_keyword_hint| will be set to true. Note |
190 // that only one of these states can be in effect at once. In all other | 213 // that only one of these states can be in effect at once. In all other |
191 // cases, |keyword| will be cleared, even when our member variable |keyword| | 214 // cases, |keyword| will be cleared, even when our member variable |keyword| |
192 // is non-empty -- such as with non-substituting keywords or matches that | 215 // is non-empty -- such as with non-substituting keywords or matches that |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 const base::string16& text, | 387 const base::string16& text, |
365 const ACMatchClassifications& classifications) const; | 388 const ACMatchClassifications& classifications) const; |
366 #endif | 389 #endif |
367 }; | 390 }; |
368 | 391 |
369 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 392 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
370 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 393 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
371 typedef std::vector<AutocompleteMatch> ACMatches; | 394 typedef std::vector<AutocompleteMatch> ACMatches; |
372 | 395 |
373 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ | 396 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ |
OLD | NEW |