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

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

Issue 2963883002: Omnibox UI Experiments: Refactor HTTPS trimming into UrlFormatter. (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
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..31047eec36686a215a8aceefb743dc7a888cc3b0 100644
--- a/components/omnibox/browser/autocomplete_match.cc
+++ b/components/omnibox/browser/autocomplete_match.cc
@@ -526,29 +526,17 @@ base::string16 AutocompleteMatch::FormatUrlForSuggestionDisplayWithAdjustments(
const GURL& url,
bool trim_scheme,
base::OffsetAdjuster::Adjustments* adjustments) {
- 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,
- adjustments);
-
- // Also trim HTTPS if experiment is enabled. Note this intentionally has
- // no effect on view-source URLs.
- if (trim_scheme && base::FeatureList::IsEnabled(
- omnibox::kUIExperimentHideSuggestionUrlScheme)) {
- // TODO(tommycli): If this becomes enabled by default, investigate
- // folding this logic into url_formatter::FormatUrlWithAdjustments.
- if (url.SchemeIs(url::kHttpsScheme)) {
- const size_t kHTTPSSize =
- strlen(url::kHttpsScheme) + strlen(url::kStandardSchemeSeparator);
- result = result.substr(kHTTPSSize);
- adjustments->insert(adjustments->begin(),
- base::OffsetAdjuster::Adjustment(0, kHTTPSSize, 0));
- }
+ auto format_types = url_formatter::kFormatUrlOmitAll;
+ if (!trim_scheme) {
+ format_types &= ~url_formatter::kFormatUrlOmitHTTP;
+ } else if (base::FeatureList::IsEnabled(
+ omnibox::kUIExperimentHideSuggestionUrlScheme)) {
+ format_types |= url_formatter::kFormatUrlExperimentalOmitHTTPS;
}
- return result;
+ return url_formatter::FormatUrlWithAdjustments(url, format_types,
+ net::UnescapeRule::SPACES,
+ nullptr, nullptr, adjustments);
}
void AutocompleteMatch::ComputeStrippedDestinationURL(

Powered by Google App Engine
This is Rietveld 408576698