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 // Returns |url| altered by stripping off "www.", converting https protocol |
Peter Kasting
2014/06/30 23:02:58
Nit: https protocol to http -> "https" to "http"
Mark P
2014/06/30 23:27:36
Done.
| |
172 // |stripped_destination_url| and also converts https protocol to | 172 // to http, and stripping excess query parameters. These conversions are |
173 // http. These two conversions are merely to allow comparisons to | 173 // merely to allow comparisons to remove likely duplicates; these URLs are |
174 // remove likely duplicates; these URLs are not used as actual | 174 // not used as actual destination URLs. If |profile| is not NULL, it is |
175 // destination URLs. This method is invoked internally by the | 175 // used to get a template URL corresponding to this match. If the match's |
176 // AutocompleteResult and does not normally need to be invoked. | 176 // keyword is known, it can be passed in. Otherwise, it can be left empty |
177 // If |profile| is not NULL, it is used to get a template URL corresponding | 177 // and the template URL (if any) is determined from the |url|'s hostname. |
178 // to this match. The template is used to strip off query args other than | 178 // The template URL is used to strip off query args other than the search |
179 // the search terms themselves that would otherwise prevent from proper | 179 // terms themselves that would otherwise prevent from proper deduping. |
180 // deduping. | 180 static GURL GURLToStrippedGURL(const GURL& url, |
181 Profile* profile, | |
Peter Kasting
2014/06/30 23:02:58
Pass a TemplateURLService* here instead (see https
Mark P
2014/06/30 23:27:36
I will wait for that to land and then make the cor
| |
182 const base::string16& keyword); | |
183 | |
184 // Computes the stripped destination URL (via GURLToStrippedGURL()) and | |
185 // stores the result in |stripped_destination_url|. | |
181 void ComputeStrippedDestinationURL(Profile* profile); | 186 void ComputeStrippedDestinationURL(Profile* profile); |
182 | 187 |
183 // Gets data relevant to whether there should be any special keyword-related | 188 // 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. | 189 // 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 | 190 // 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 | 191 // 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 ___" | 192 // |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 | 193 // 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 | 194 // 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 | 195 // that only one of these states can be in effect at once. In all other |
(...skipping 16 matching lines...) Expand all Loading... | |
207 | 212 |
208 // Returns the TemplateURL associated with this match. This may be NULL if | 213 // Returns the TemplateURL associated with this match. This may be NULL if |
209 // the match has no keyword OR if the keyword no longer corresponds to a valid | 214 // the match has no keyword OR if the keyword no longer corresponds to a valid |
210 // TemplateURL. See comments on |keyword| below. | 215 // TemplateURL. See comments on |keyword| below. |
211 // If |allow_fallback_to_destination_host| is true and the keyword does | 216 // If |allow_fallback_to_destination_host| is true and the keyword does |
212 // not map to a valid TemplateURL, we'll then check for a TemplateURL that | 217 // not map to a valid TemplateURL, we'll then check for a TemplateURL that |
213 // corresponds to the destination_url's hostname. | 218 // corresponds to the destination_url's hostname. |
214 TemplateURL* GetTemplateURL(Profile* profile, | 219 TemplateURL* GetTemplateURL(Profile* profile, |
215 bool allow_fallback_to_destination_host) const; | 220 bool allow_fallback_to_destination_host) const; |
216 | 221 |
222 // A static version GetTemplateURL() that takes the match's keyword and | |
223 // match's hostname as parameters. In short, returns the TemplateURL | |
224 // associated with |keyword| if it exists; otherwise returns the TemplateURL | |
225 // associated with |host| if it exists. | |
226 static TemplateURL* GetTemplateURLWithKeyword( | |
Peter Kasting
2014/06/30 23:02:58
Nit: Put this with the other static functions.
Mark P
2014/06/30 23:27:36
Done.
| |
227 Profile* profile, | |
228 const base::string16& keyword, | |
229 const std::string& host); | |
230 | |
217 // Adds optional information to the |additional_info| dictionary. | 231 // Adds optional information to the |additional_info| dictionary. |
218 void RecordAdditionalInfo(const std::string& property, | 232 void RecordAdditionalInfo(const std::string& property, |
219 const std::string& value); | 233 const std::string& value); |
220 void RecordAdditionalInfo(const std::string& property, int value); | 234 void RecordAdditionalInfo(const std::string& property, int value); |
221 void RecordAdditionalInfo(const std::string& property, | 235 void RecordAdditionalInfo(const std::string& property, |
222 const base::Time& value); | 236 const base::Time& value); |
223 | 237 |
224 // Returns the value recorded for |property| in the |additional_info| | 238 // Returns the value recorded for |property| in the |additional_info| |
225 // dictionary. Returns the empty string if no such value exists. | 239 // dictionary. Returns the empty string if no such value exists. |
226 std::string GetAdditionalInfo(const std::string& property) const; | 240 std::string GetAdditionalInfo(const std::string& property) const; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 const base::string16& text, | 378 const base::string16& text, |
365 const ACMatchClassifications& classifications) const; | 379 const ACMatchClassifications& classifications) const; |
366 #endif | 380 #endif |
367 }; | 381 }; |
368 | 382 |
369 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 383 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
370 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 384 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
371 typedef std::vector<AutocompleteMatch> ACMatches; | 385 typedef std::vector<AutocompleteMatch> ACMatches; |
372 | 386 |
373 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ | 387 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ |
OLD | NEW |