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_words| is used to decide if the scheme is allowed |
187 static GURL GURLToStrippedGURL(const GURL& url, | 188 // to be altered during stripping. (If the user indicated a desired scheme, |
Peter Kasting
2015/06/06 01:31:24
Nit: Vague; "If the user indicated a desired schem
Mark P
2015/06/09 19:29:38
Done.
| |
188 TemplateURLService* template_url_service, | 189 // we prevent two URLs with different schemes from having the same stripped |
189 const base::string16& keyword); | 190 // GURL.) |
191 static GURL GURLToStrippedGURL( | |
192 const GURL& url, | |
193 const std::vector<base::string16>& input_words, | |
194 TemplateURLService* template_url_service, | |
195 const base::string16& keyword); | |
190 | 196 |
191 // Computes the stripped destination URL (via GURLToStrippedGURL()) and | 197 // Computes the stripped destination URL (via GURLToStrippedGURL()) and |
192 // stores the result in |stripped_destination_url|. | 198 // stores the result in |stripped_destination_url|. |
193 void ComputeStrippedDestinationURL(TemplateURLService* template_url_service); | 199 void ComputeStrippedDestinationURL( |
200 const std::vector<base::string16>& input_words, | |
201 TemplateURLService* template_url_service); | |
194 | 202 |
195 // Sets |allowed_to_be_default_match| to true if this match is effectively | 203 // 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 | 204 // the URL-what-you-typed match (i.e., would be dupped against the UWYT |
197 // match when AutocompleteResult merges matches). |canonical_input_url| is | 205 // match when AutocompleteResult merges matches). |canonical_input_url| is |
198 // the AutocompleteInput interpreted as a URL (i.e., | 206 // the AutocompleteInput interpreted as a URL (i.e., |
199 // AutocompleteInput::canonicalized_url()). | 207 // AutocompleteInput::canonicalized_url()). |inputs_words| is the input |
200 void EnsureUWYTIsAllowedToBeDefault(const GURL& canonical_input_url, | 208 // split based on spaces into words. |
Peter Kasting
2015/06/06 01:31:24
Nit: "...is the original input string, tokenized i
Mark P
2015/06/09 19:29:38
Comment is now obsolete.
| |
201 TemplateURLService* template_url_service); | 209 void EnsureUWYTIsAllowedToBeDefault( |
210 const GURL& canonical_input_url, | |
211 const std::vector<base::string16>& input_words, | |
212 TemplateURLService* template_url_service); | |
213 // The same as above except only takes an AutocompleteInput and does the | |
214 // splitting internally. | |
215 void EnsureUWYTIsAllowedToBeDefault( | |
Peter Kasting
2015/06/06 01:31:24
My one concern with this API is that it will lead
Mark P
2015/06/06 17:10:11
I'm not philosophically keen on the notion of cach
Peter Kasting
2015/06/06 18:38:16
By "only one field needed" do you mean "only one a
Mark P
2015/06/06 20:23:06
Yes.
Peter Kasting
2015/06/08 20:26:59
We don't have any other places that need such a ve
Mark P
2015/06/09 19:29:38
Done.
| |
216 const AutocompleteInput& input, | |
217 TemplateURLService* template_url_service); | |
202 | 218 |
203 // Gets data relevant to whether there should be any special keyword-related | 219 // 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. | 220 // 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 | 221 // 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 | 222 // 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 ___" | 223 // |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 | 224 // 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 | 225 // 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 | 226 // 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| | 227 // 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, | 401 const base::string16& text, |
386 const ACMatchClassifications& classifications) const; | 402 const ACMatchClassifications& classifications) const; |
387 #endif | 403 #endif |
388 }; | 404 }; |
389 | 405 |
390 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 406 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
391 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 407 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
392 typedef std::vector<AutocompleteMatch> ACMatches; | 408 typedef std::vector<AutocompleteMatch> ACMatches; |
393 | 409 |
394 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ | 410 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_MATCH_H_ |
OLD | NEW |