Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: components/omnibox/browser/autocomplete_match.h

Issue 2963883002: Omnibox UI Experiments: Refactor HTTPS trimming into UrlFormatter. (Closed)
Patch Set: update comment Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/strings/utf_offset_string_conversions.h"
16 #include "components/omnibox/browser/autocomplete_input.h" 16 #include "components/omnibox/browser/autocomplete_input.h"
17 #include "components/omnibox/browser/autocomplete_match_type.h" 17 #include "components/omnibox/browser/autocomplete_match_type.h"
18 #include "components/search_engines/template_url.h" 18 #include "components/search_engines/template_url.h"
19 #include "components/url_formatter/url_formatter.h"
19 #include "ui/base/page_transition_types.h" 20 #include "ui/base/page_transition_types.h"
20 #include "url/gurl.h" 21 #include "url/gurl.h"
21 22
22 class AutocompleteProvider; 23 class AutocompleteProvider;
23 class SuggestionAnswer; 24 class SuggestionAnswer;
24 class TemplateURL; 25 class TemplateURL;
25 class TemplateURLService; 26 class TemplateURLService;
26 27
27 namespace base { 28 namespace base {
28 class Time; 29 class Time;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // be altered during stripping. If this URL, minus the scheme and separator, 202 // be altered during stripping. If this URL, minus the scheme and separator,
202 // starts with any the terms in input.terms_prefixed_by_http_or_https(), we 203 // starts with any the terms in input.terms_prefixed_by_http_or_https(), we
203 // avoid converting an HTTPS scheme to HTTP. This means URLs that differ 204 // avoid converting an HTTPS scheme to HTTP. This means URLs that differ
204 // only by these schemes won't be marked as dupes, since the distinction 205 // only by these schemes won't be marked as dupes, since the distinction
205 // seems to matter to the user. 206 // seems to matter to the user.
206 static GURL GURLToStrippedGURL(const GURL& url, 207 static GURL GURLToStrippedGURL(const GURL& url,
207 const AutocompleteInput& input, 208 const AutocompleteInput& input,
208 TemplateURLService* template_url_service, 209 TemplateURLService* template_url_service,
209 const base::string16& keyword); 210 const base::string16& keyword);
210 211
211 // These are convenience functions for formatting a URL into an abridged form 212 // Gets the formatting flags used for display of suggestions. This method
212 // for display within the Omnibox suggestions dropdown. 213 // encapsulates the return of experimental flags too, so any URLs displayed
213 // 214 // as an Omnibox suggestion should use this method.
214 // The results are explicitly for non-security surfaces. Do not use the 215 static url_formatter::FormatUrlTypes GetFormatForSuggestionDisplay(
Peter Kasting 2017/06/29 01:05:44 Nit: GetFormatTypesForSuggestionDisplay()? Or may
tommycli 2017/06/29 16:46:46 Done. GetFormatTypes -- love the brevity. Indeed i
215 // results for anything other than the Omnibox dropdown. 216 bool trim_scheme);
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 217
229 // Computes the stripped destination URL (via GURLToStrippedGURL()) and 218 // Computes the stripped destination URL (via GURLToStrippedGURL()) and
230 // stores the result in |stripped_destination_url|. |input| is used for the 219 // stores the result in |stripped_destination_url|. |input| is used for the
231 // same purpose as in GURLToStrippedGURL(). 220 // same purpose as in GURLToStrippedGURL().
232 void ComputeStrippedDestinationURL(const AutocompleteInput& input, 221 void ComputeStrippedDestinationURL(const AutocompleteInput& input,
233 TemplateURLService* template_url_service); 222 TemplateURLService* template_url_service);
234 223
235 // Sets |allowed_to_be_default_match| to true if this match is effectively 224 // Sets |allowed_to_be_default_match| to true if this match is effectively
236 // the URL-what-you-typed match (i.e., would be dupped against the UWYT 225 // the URL-what-you-typed match (i.e., would be dupped against the UWYT
237 // match when AutocompleteResult merges matches). 226 // match when AutocompleteResult merges matches).
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 const base::string16& text, 433 const base::string16& text,
445 const ACMatchClassifications& classifications) const; 434 const ACMatchClassifications& classifications) const;
446 #endif 435 #endif
447 }; 436 };
448 437
449 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification; 438 typedef AutocompleteMatch::ACMatchClassification ACMatchClassification;
450 typedef std::vector<ACMatchClassification> ACMatchClassifications; 439 typedef std::vector<ACMatchClassification> ACMatchClassifications;
451 typedef std::vector<AutocompleteMatch> ACMatches; 440 typedef std::vector<AutocompleteMatch> ACMatches;
452 441
453 #endif // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_MATCH_H_ 442 #endif // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_MATCH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698