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

Unified Diff: components/omnibox/browser/autocomplete_match.cc

Issue 2945173007: Omnibox UI Experiments: Enable trimming of trivial subdomains. (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698