Commit f6af9e1f authored by Livvie Lin's avatar Livvie Lin Committed by Commit Bot

Reinstate check for ShouldPreventElision in GetFormattedURL

This is essentially the same CL as crrev.com/c/2120454 and
crrev.com/c/2122861, but a follow-up CL accidentally deleted this logic,
so reinstate it.

Bug: 1061576
Change-Id: I4a916a27dcebd5825cccdfd6071dd644114cdfa4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2131020
Commit-Queue: Livvie Lin <livvielin@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755402}
parent 1959c2ac
......@@ -57,11 +57,6 @@ base::string16 LocationBarModelImpl::GetURLForDisplay() const {
format_types |= url_formatter::kFormatUrlTrimAfterHost;
}
// Early exit to prevent elision of URLs when relevant extension is enabled.
if (delegate_->ShouldPreventElision()) {
return GetFormattedURL(format_types);
}
#if defined(OS_IOS)
format_types |= url_formatter::kFormatUrlTrimAfterHost;
#endif
......@@ -83,6 +78,13 @@ base::string16 LocationBarModelImpl::GetFormattedURL(
if (!ShouldDisplayURL())
return base::string16{};
// Reset |format_types| to prevent elision of URLs when relevant extension or
// pref is enabled.
if (delegate_->ShouldPreventElision()) {
format_types = url_formatter::kFormatUrlOmitDefaults &
~url_formatter::kFormatUrlOmitHTTP;
}
GURL url(GetURL());
// Special handling for dom-distiller:. Instead of showing internal reader
// mode URLs, show the original article URL without a http or https scheme.
......
......@@ -182,6 +182,12 @@ TEST_F(LocationBarModelImplTest, MAYBE_PreventElisionWorks) {
// Verify that query in omnibox is turned off.
delegate()->SetSecurityLevel(security_state::SecurityLevel::SECURE);
EXPECT_FALSE(model()->GetDisplaySearchTerms(nullptr));
// Also test that HTTP elisions are prevented.
delegate()->SetURL(GURL("http://www.google.com/search?q=foo+query+unelide"));
EXPECT_EQ(base::ASCIIToUTF16(
"http://www.google.com/search?q=foo+query+unelide/TestSuffix"),
model()->GetURLForDisplay());
}
TEST_F(LocationBarModelImplTest, QueryInOmniboxFeatureFlagWorks) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment