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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 // Convenience function to check if |type| is a search (as opposed to a URL or | 181 // Convenience function to check if |type| is a search (as opposed to a URL or |
182 // an extension). | 182 // an extension). |
183 static bool IsSearchType(Type type); | 183 static bool IsSearchType(Type type); |
184 | 184 |
185 // Copies the destination_url with "www." stripped off to | 185 // Copies the destination_url with "www." stripped off to |
186 // |stripped_destination_url| and also converts https protocol to | 186 // |stripped_destination_url| and also converts https protocol to |
187 // http. These two conversions are merely to allow comparisons to | 187 // http. These two conversions are merely to allow comparisons to |
188 // remove likely duplicates; these URLs are not used as actual | 188 // remove likely duplicates; these URLs are not used as actual |
189 // destination URLs. This method is invoked internally by the | 189 // destination URLs. This method is invoked internally by the |
190 // AutocompleteResult and does not normally need to be invoked. | 190 // AutocompleteResult and does not normally need to be invoked. |
191 void ComputeStrippedDestinationURL(); | 191 // If |profile| is not NULL, it is used to get a template URL corresponding |
| 192 // to this match. The template is used to strip off query args other than |
| 193 // the search terms themselves that would otherwise prevent from proper |
| 194 // deduping. |
| 195 void ComputeStrippedDestinationURL(Profile* profile); |
192 | 196 |
193 // Gets data relevant to whether there should be any special keyword-related | 197 // Gets data relevant to whether there should be any special keyword-related |
194 // UI shown for this match. If this match represents a selected keyword, i.e. | 198 // UI shown for this match. If this match represents a selected keyword, i.e. |
195 // the UI should be "in keyword mode", |keyword| will be set to the keyword | 199 // the UI should be "in keyword mode", |keyword| will be set to the keyword |
196 // and |is_keyword_hint| will be set to false. If this match has a non-NULL | 200 // and |is_keyword_hint| will be set to false. If this match has a non-NULL |
197 // |associated_keyword|, i.e. we should show a "Press [tab] to search ___" | 201 // |associated_keyword|, i.e. we should show a "Press [tab] to search ___" |
198 // hint and allow the user to toggle into keyword mode, |keyword| will be set | 202 // hint and allow the user to toggle into keyword mode, |keyword| will be set |
199 // to the associated keyword and |is_keyword_hint| will be set to true. Note | 203 // to the associated keyword and |is_keyword_hint| will be set to true. Note |
200 // that only one of these states can be in effect at once. In all other | 204 // that only one of these states can be in effect at once. In all other |
201 // cases, |keyword| will be cleared, even when our member variable |keyword| | 205 // cases, |keyword| will be cleared, even when our member variable |keyword| |
202 // is non-empty -- such as with non-substituting keywords or matches that | 206 // is non-empty -- such as with non-substituting keywords or matches that |
203 // represent searches using the default search engine. See also | 207 // represent searches using the default search engine. See also |
204 // GetSubstitutingExplicitlyInvokedKeyword(). | 208 // GetSubstitutingExplicitlyInvokedKeyword(). |
205 void GetKeywordUIState(Profile* profile, | 209 void GetKeywordUIState(Profile* profile, |
206 string16* keyword, | 210 string16* keyword, |
207 bool* is_keyword_hint) const; | 211 bool* is_keyword_hint) const; |
208 | 212 |
209 // Returns |keyword|, but only if it represents a substituting keyword that | 213 // Returns |keyword|, but only if it represents a substituting keyword that |
210 // the user has explicitly invoked. If for example this match represents a | 214 // the user has explicitly invoked. If for example this match represents a |
211 // search with the default search engine (and the user didn't explicitly | 215 // search with the default search engine (and the user didn't explicitly |
212 // invoke its keyword), this returns the empty string. The result is that | 216 // invoke its keyword), this returns the empty string. The result is that |
213 // this function returns a non-empty string in the same cases as when the UI | 217 // this function returns a non-empty string in the same cases as when the UI |
214 // should show up as being "in keyword mode". | 218 // should show up as being "in keyword mode". |
215 string16 GetSubstitutingExplicitlyInvokedKeyword(Profile* profile) const; | 219 string16 GetSubstitutingExplicitlyInvokedKeyword(Profile* profile) const; |
216 | 220 |
217 // Returns the TemplateURL associated with this match. This may be NULL if | 221 // Returns the TemplateURL associated with this match. This may be NULL if |
218 // the match has no keyword OR if the keyword no longer corresponds to a valid | 222 // the match has no keyword OR if the keyword no longer corresponds to a valid |
219 // TemplateURL. See comments on |keyword| below. | 223 // TemplateURL. See comments on |keyword| below. |
220 TemplateURL* GetTemplateURL(Profile* profile) const; | 224 // If |allow_fallback_to_destination_host| is true and the keyword does |
| 225 // not map to a valid TemplateURL, we'll then check for a TemplateURL that |
| 226 // corresponds to the destination_url's hostname. |
| 227 TemplateURL* GetTemplateURL(Profile* profile, |
| 228 bool allow_fallback_to_destination_host) const; |
221 | 229 |
222 // Adds optional information to the |additional_info| dictionary. | 230 // Adds optional information to the |additional_info| dictionary. |
223 void RecordAdditionalInfo(const std::string& property, | 231 void RecordAdditionalInfo(const std::string& property, |
224 const std::string& value); | 232 const std::string& value); |
225 void RecordAdditionalInfo(const std::string& property, int value); | 233 void RecordAdditionalInfo(const std::string& property, int value); |
226 void RecordAdditionalInfo(const std::string& property, | 234 void RecordAdditionalInfo(const std::string& property, |
227 const base::Time& value); | 235 const base::Time& value); |
228 | 236 |
229 // The provider of this match, used to remember which provider the user had | 237 // The provider of this match, used to remember which provider the user had |
230 // selected when the input changes. This may be NULL, in which case there is | 238 // selected when the input changes. This may be NULL, in which case there is |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 const string16& text, | 341 const string16& text, |
334 const ACMatchClassifications& classifications) const; | 342 const ACMatchClassifications& classifications) const; |
335 #endif | 343 #endif |
336 }; | 344 }; |
337 | 345 |
338 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 346 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
339 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 347 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
340 typedef std::vector<AutocompleteMatch> ACMatches; | 348 typedef std::vector<AutocompleteMatch> ACMatches; |
341 | 349 |
342 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ | 350 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_MATCH_H_ |
OLD | NEW |