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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 | 167 |
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 |
Peter Kasting
2015/04/25 00:03:12
It strikes me that there's probably a similar issu
Mark P
2015/04/27 22:26:05
I admit this is a distinction. However, I know fr
| |
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. If |scheme_explicitly_entered| then the scheme is not |
187 // allowed to be altered during stripping, thus preventing two URLs with | |
188 // different schemes from having the same stripped GURL. | |
Peter Kasting
2015/04/25 00:03:12
Hmm, this doesn't seem quite right.
Consider user
Mark P
2015/04/27 22:26:05
Astute analysis.
Here's a follow-up question: if
| |
187 static GURL GURLToStrippedGURL(const GURL& url, | 189 static GURL GURLToStrippedGURL(const GURL& url, |
190 const bool scheme_explicitly_entered, | |
188 TemplateURLService* template_url_service, | 191 TemplateURLService* template_url_service, |
189 const base::string16& keyword); | 192 const base::string16& keyword); |
190 | 193 |
191 // Computes the stripped destination URL (via GURLToStrippedGURL()) and | 194 // Computes the stripped destination URL (via GURLToStrippedGURL()) and |
192 // stores the result in |stripped_destination_url|. | 195 // stores the result in |stripped_destination_url|. |
193 void ComputeStrippedDestinationURL(TemplateURLService* template_url_service); | 196 void ComputeStrippedDestinationURL(const bool scheme_explicitly_entered, |
197 TemplateURLService* template_url_service); | |
194 | 198 |
195 // Sets |allowed_to_be_default_match| to true if this match is effectively | 199 // 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 | 200 // the URL-what-you-typed match (i.e., would be dupped against the UWYT |
197 // match when AutocompleteResult merges matches). |canonical_input_url| is | 201 // match when AutocompleteResult merges matches). |canonical_input_url| is |
198 // the AutocompleteInput interpreted as a URL (i.e., | 202 // the AutocompleteInput interpreted as a URL (i.e., |
199 // AutocompleteInput::canonicalized_url()). | 203 // AutocompleteInput::canonicalized_url()). |
200 void EnsureUWYTIsAllowedToBeDefault(const GURL& canonical_input_url, | 204 void EnsureUWYTIsAllowedToBeDefault(const GURL& canonical_input_url, |
205 const bool scheme_explicitly_entered, | |
201 TemplateURLService* template_url_service); | 206 TemplateURLService* template_url_service); |
202 | 207 |
203 // Gets data relevant to whether there should be any special keyword-related | 208 // 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. | 209 // 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 | 210 // 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 | 211 // 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 ___" | 212 // |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 | 213 // 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 | 214 // 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 | 215 // that only one of these states can be in effect at once. In all other |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 const base::string16& text, | 394 const base::string16& text, |
390 const ACMatchClassifications& classifications) const; | 395 const ACMatchClassifications& classifications) const; |
391 #endif | 396 #endif |
392 }; | 397 }; |
393 | 398 |
394 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 399 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
395 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 400 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
396 typedef std::vector<AutocompleteMatch> ACMatches; | 401 typedef std::vector<AutocompleteMatch> ACMatches; |
397 | 402 |
398 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ | 403 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ |
OLD | NEW |