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> |
11 | 11 |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "components/omnibox/autocomplete_input.h" | |
13 #include "components/omnibox/autocomplete_match_type.h" | 14 #include "components/omnibox/autocomplete_match_type.h" |
14 #include "components/search_engines/template_url.h" | 15 #include "components/search_engines/template_url.h" |
15 #include "ui/base/page_transition_types.h" | 16 #include "ui/base/page_transition_types.h" |
16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
17 | 18 |
18 class AutocompleteProvider; | 19 class AutocompleteProvider; |
19 class SuggestionAnswer; | 20 class SuggestionAnswer; |
20 class TemplateURL; | 21 class TemplateURL; |
21 class TemplateURLService; | 22 class TemplateURLService; |
22 | 23 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 | 177 |
177 // Returns |url| altered by stripping off "www.", converting https protocol | 178 // Returns |url| altered by stripping off "www.", converting https protocol |
178 // to http, and stripping excess query parameters. These conversions are | 179 // to http, and stripping excess query parameters. These conversions are |
179 // merely to allow comparisons to remove likely duplicates; these URLs are | 180 // merely to allow comparisons to remove likely duplicates; these URLs are |
180 // not used as actual destination URLs. If |template_url_service| is not | 181 // 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 | 182 // 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 | 183 // 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 | 184 // 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 | 185 // 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 | 186 // other than the search terms themselves that would otherwise prevent doing |
186 // proper deduping. | 187 // proper deduping. |input| is used to decide if the scheme is allowed to |
188 // be altered during stripping. If this URL, minus the scheme and separator, | |
189 // starts with any the terms in input.terms_prefixed_by_http_or_https(), we | |
190 // we avoid converting an HTTPS scheme to HTTP. This means URLs that differ | |
Peter Kasting
2015/06/11 05:21:44
Nit: "we we avoid"
Mark P
2015/06/11 22:11:42
Done.
| |
191 // only by these schemes won't be marked as dupes, since the distinction | |
192 // seems to matter to the user. | |
187 static GURL GURLToStrippedGURL(const GURL& url, | 193 static GURL GURLToStrippedGURL(const GURL& url, |
194 const AutocompleteInput& input, | |
188 TemplateURLService* template_url_service, | 195 TemplateURLService* template_url_service, |
189 const base::string16& keyword); | 196 const base::string16& keyword); |
190 | 197 |
191 // Computes the stripped destination URL (via GURLToStrippedGURL()) and | 198 // Computes the stripped destination URL (via GURLToStrippedGURL()) and |
192 // stores the result in |stripped_destination_url|. | 199 // stores the result in |stripped_destination_url|. |
193 void ComputeStrippedDestinationURL(TemplateURLService* template_url_service); | 200 void ComputeStrippedDestinationURL( |
201 const AutocompleteInput& input, | |
202 TemplateURLService* template_url_service); | |
194 | 203 |
195 // Sets |allowed_to_be_default_match| to true if this match is effectively | 204 // 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 | 205 // the URL-what-you-typed match (i.e., would be dupped against the UWYT |
197 // match when AutocompleteResult merges matches). |canonical_input_url| is | 206 // match when AutocompleteResult merges matches). |
198 // the AutocompleteInput interpreted as a URL (i.e., | 207 void EnsureUWYTIsAllowedToBeDefault( |
199 // AutocompleteInput::canonicalized_url()). | 208 const AutocompleteInput& input, |
200 void EnsureUWYTIsAllowedToBeDefault(const GURL& canonical_input_url, | 209 TemplateURLService* template_url_service); |
201 TemplateURLService* template_url_service); | |
202 | 210 |
203 // Gets data relevant to whether there should be any special keyword-related | 211 // 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. | 212 // 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 | 213 // 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 | 214 // 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 ___" | 215 // |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 | 216 // 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 | 217 // 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 | 218 // that only one of these states can be in effect at once. In all other |
211 // cases, |keyword| will be cleared, even when our member variable |keyword| | 219 // cases, |keyword| will be cleared, even when our member variable |keyword| |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 const base::string16& text, | 393 const base::string16& text, |
386 const ACMatchClassifications& classifications) const; | 394 const ACMatchClassifications& classifications) const; |
387 #endif | 395 #endif |
388 }; | 396 }; |
389 | 397 |
390 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 398 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
391 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 399 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
392 typedef std::vector<AutocompleteMatch> ACMatches; | 400 typedef std::vector<AutocompleteMatch> ACMatches; |
393 | 401 |
394 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ | 402 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ |
OLD | NEW |