Chromium Code Reviews| Index: components/omnibox/browser/autocomplete_match.cc |
| diff --git a/components/omnibox/browser/autocomplete_match.cc b/components/omnibox/browser/autocomplete_match.cc |
| index dd0eaf01265b6dce6010bbc47f060bcefefea2a8..3f0e0c8159f897da807777e0f00b563a6add60e3 100644 |
| --- a/components/omnibox/browser/autocomplete_match.cc |
| +++ b/components/omnibox/browser/autocomplete_match.cc |
| @@ -526,11 +526,22 @@ base::string16 AutocompleteMatch::FormatUrlForSuggestionDisplayWithAdjustments( |
| const GURL& url, |
| bool trim_scheme, |
| base::OffsetAdjuster::Adjustments* adjustments) { |
| + GURL trimmed_url = url; |
| + |
| + // Trim off trivial subdomains if experiment is enabled. |
| + if (base::FeatureList::IsEnabled( |
| + omnibox::kUIExperimentHideSuggestionUrlTrivialSubdomains)) { |
| + GURL::Replacements replacements; |
| + replacements.SetHostStr(url_formatter::StripSubdomains( |
| + url, url_formatter::kStripWWW | url_formatter::kStripM)); |
| + trimmed_url = url.ReplaceComponents(replacements); |
| + } |
|
tommycli
2017/06/23 00:10:54
This pattern now makes me feel that the smart thin
Justin Donnelly
2017/06/23 15:12:25
That's both an elegant solution to the code duplic
tommycli
2017/06/23 18:23:05
Gotcha, alright good to hear my first instinct was
|
| + |
| const url_formatter::FormatUrlTypes format_types = |
| url_formatter::kFormatUrlOmitAll & |
| ~(trim_scheme ? 0 : url_formatter::kFormatUrlOmitHTTP); |
| base::string16 result = url_formatter::FormatUrlWithAdjustments( |
| - url, format_types, net::UnescapeRule::SPACES, nullptr, nullptr, |
| + trimmed_url, format_types, net::UnescapeRule::SPACES, nullptr, nullptr, |
| adjustments); |
| // Also trim HTTPS if experiment is enabled. Note this intentionally has |