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

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

Issue 2963883002: Omnibox UI Experiments: Refactor HTTPS trimming into UrlFormatter. (Closed)
Patch Set: fix 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/history_url_provider.cc
diff --git a/components/omnibox/browser/history_url_provider.cc b/components/omnibox/browser/history_url_provider.cc
index d9f6b7e887db0827d39ba5cba82a1fbc7e936936..2691564d0d2dd3a9d86a8e7a4273937b5b5cbcf7 100644
--- a/components/omnibox/browser/history_url_provider.cc
+++ b/components/omnibox/browser/history_url_provider.cc
@@ -571,9 +571,10 @@ AutocompleteMatch HistoryURLProvider::SuggestExactInput(
// Trim off "http://" if the user didn't type it.
DCHECK(!trim_http ||
!AutocompleteInput::HasHTTPScheme(input.text()));
- base::string16 display_string(
- AutocompleteMatch::FormatUrlForSuggestionDisplay(
- destination_url, false /* trim_scheme */, nullptr));
+ auto format_types = AutocompleteMatch::GetFormatTypes(false);
+ base::string16 display_string(url_formatter::FormatUrl(
+ destination_url, format_types, net::UnescapeRule::SPACES, nullptr,
+ nullptr, nullptr));
const size_t offset = trim_http ? TrimHttpPrefix(&display_string) : 0;
match.fill_into_edit =
AutocompleteInput::FormattedStringWithEquivalentMeaning(
@@ -1141,15 +1142,16 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch(
DCHECK(match.destination_url.is_valid());
size_t inline_autocomplete_offset =
history_match.input_location + params.input.text().length();
- const url_formatter::FormatUrlTypes format_types =
- url_formatter::kFormatUrlOmitAll &
- ~((params.trim_http && !history_match.match_in_scheme)
- ? 0
- : url_formatter::kFormatUrlOmitHTTP);
+
+ auto format_types = AutocompleteMatch::GetFormatTypes(
+ params.trim_http && !history_match.match_in_scheme);
+ // Never omit HTTPS from fill_into_edit lest it be misinterpreted.
+ auto fill_into_edit_format_types =
+ format_types & ~url_formatter::kFormatUrlExperimentalOmitHTTPS;
match.fill_into_edit =
AutocompleteInput::FormattedStringWithEquivalentMeaning(
info.url(),
- url_formatter::FormatUrl(info.url(), format_types,
+ url_formatter::FormatUrl(info.url(), fill_into_edit_format_types,
net::UnescapeRule::SPACES, nullptr, nullptr,
&inline_autocomplete_offset),
client()->GetSchemeClassifier());
@@ -1173,9 +1175,9 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch(
(inline_autocomplete_offset >= match.fill_into_edit.length()));
size_t match_start = history_match.input_location;
- match.contents = AutocompleteMatch::FormatUrlForSuggestionDisplay(
- info.url(), params.trim_http && !history_match.match_in_scheme,
- &match_start);
+ match.contents = url_formatter::FormatUrl(info.url(), format_types,
+ net::UnescapeRule::SPACES, nullptr,
+ nullptr, &match_start);
if ((match_start != base::string16::npos) && autocomplete_offset_valid &&
(inline_autocomplete_offset != match_start)) {
DCHECK(inline_autocomplete_offset > match_start);
« no previous file with comments | « components/omnibox/browser/history_quick_provider.cc ('k') | components/omnibox/browser/titled_url_match_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698