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_BROWSER_AUTOCOMPLETE_MATCH_H_ | 5 #ifndef COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_MATCH_H_ |
6 #define COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_MATCH_H_ | 6 #define COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_MATCH_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
| 15 #include "base/strings/utf_offset_string_conversions.h" |
15 #include "components/omnibox/browser/autocomplete_input.h" | 16 #include "components/omnibox/browser/autocomplete_input.h" |
16 #include "components/omnibox/browser/autocomplete_match_type.h" | 17 #include "components/omnibox/browser/autocomplete_match_type.h" |
17 #include "components/search_engines/template_url.h" | 18 #include "components/search_engines/template_url.h" |
18 #include "ui/base/page_transition_types.h" | 19 #include "ui/base/page_transition_types.h" |
19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
20 | 21 |
21 class AutocompleteProvider; | 22 class AutocompleteProvider; |
22 class SuggestionAnswer; | 23 class SuggestionAnswer; |
23 class TemplateURL; | 24 class TemplateURL; |
24 class TemplateURLService; | 25 class TemplateURLService; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // be altered during stripping. If this URL, minus the scheme and separator, | 201 // be altered during stripping. If this URL, minus the scheme and separator, |
201 // starts with any the terms in input.terms_prefixed_by_http_or_https(), we | 202 // starts with any the terms in input.terms_prefixed_by_http_or_https(), we |
202 // avoid converting an HTTPS scheme to HTTP. This means URLs that differ | 203 // avoid converting an HTTPS scheme to HTTP. This means URLs that differ |
203 // only by these schemes won't be marked as dupes, since the distinction | 204 // only by these schemes won't be marked as dupes, since the distinction |
204 // seems to matter to the user. | 205 // seems to matter to the user. |
205 static GURL GURLToStrippedGURL(const GURL& url, | 206 static GURL GURLToStrippedGURL(const GURL& url, |
206 const AutocompleteInput& input, | 207 const AutocompleteInput& input, |
207 TemplateURLService* template_url_service, | 208 TemplateURLService* template_url_service, |
208 const base::string16& keyword); | 209 const base::string16& keyword); |
209 | 210 |
| 211 // These are convenience functions for formatting a URL into an abridged form |
| 212 // for display within the Omnibox suggestions dropdown. |
| 213 // |
| 214 // The results are explicitly for non-security surfaces. Do not use the |
| 215 // results for anything other than the Omnibox dropdown. |
| 216 static base::string16 FormatUrlForSuggestionDisplay( |
| 217 const GURL& url, |
| 218 bool trim_scheme, |
| 219 size_t* offset_for_adjustment); |
| 220 static base::string16 FormatUrlForSuggestionDisplayWithOffsets( |
| 221 const GURL& url, |
| 222 bool trim_scheme, |
| 223 std::vector<size_t>* offsets_for_adjustment); |
| 224 static base::string16 FormatUrlForSuggestionDisplayWithAdjustments( |
| 225 const GURL& url, |
| 226 bool trim_scheme, |
| 227 base::OffsetAdjuster::Adjustments* adjustments); |
| 228 |
210 // Computes the stripped destination URL (via GURLToStrippedGURL()) and | 229 // Computes the stripped destination URL (via GURLToStrippedGURL()) and |
211 // stores the result in |stripped_destination_url|. |input| is used for the | 230 // stores the result in |stripped_destination_url|. |input| is used for the |
212 // same purpose as in GURLToStrippedGURL(). | 231 // same purpose as in GURLToStrippedGURL(). |
213 void ComputeStrippedDestinationURL(const AutocompleteInput& input, | 232 void ComputeStrippedDestinationURL(const AutocompleteInput& input, |
214 TemplateURLService* template_url_service); | 233 TemplateURLService* template_url_service); |
215 | 234 |
216 // Sets |allowed_to_be_default_match| to true if this match is effectively | 235 // Sets |allowed_to_be_default_match| to true if this match is effectively |
217 // the URL-what-you-typed match (i.e., would be dupped against the UWYT | 236 // the URL-what-you-typed match (i.e., would be dupped against the UWYT |
218 // match when AutocompleteResult merges matches). | 237 // match when AutocompleteResult merges matches). |
219 void EnsureUWYTIsAllowedToBeDefault( | 238 void EnsureUWYTIsAllowedToBeDefault( |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 const base::string16& text, | 444 const base::string16& text, |
426 const ACMatchClassifications& classifications) const; | 445 const ACMatchClassifications& classifications) const; |
427 #endif | 446 #endif |
428 }; | 447 }; |
429 | 448 |
430 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; | 449 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; |
431 typedef std::vector<ACMatchClassification> ACMatchClassifications; | 450 typedef std::vector<ACMatchClassification> ACMatchClassifications; |
432 typedef std::vector<AutocompleteMatch> ACMatches; | 451 typedef std::vector<AutocompleteMatch> ACMatches; |
433 | 452 |
434 #endif // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_MATCH_H_ | 453 #endif // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_MATCH_H_ |
OLD | NEW |