Commit 9c5649e1 authored by Tommy Li's avatar Tommy Li Committed by Commit Bot

[omnibox] Steady State Elisions - don't elide anything in view-source.

For view-source URLs, applying steady state elisions is confusing, as
the user lacks the normal lock icon needed to surmise that the scheme
is HTTPS.

Moreover, view-source users are likely developers or Defenders of the
Web that want to see the full URL.

This CL simply turns off elisions for the inner-url portion of
view-source scheme URLs.

Bug: 981490
Change-Id: I64d7e130cf9096f86a3af1215ef30c0abfd96c43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1737366Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#684387}
parent ec854efb
......@@ -50,17 +50,20 @@ struct TestItem {
{
GetViewSourceURL("http://www.google.com"),
"view-source:www.google.com",
"view-source:google.com",
"view-source:www.google.com",
},
{
GURL(chrome::kChromeUINewTabURL), "",
GURL(chrome::kChromeUINewTabURL),
"",
},
{
GetViewSourceURL(chrome::kChromeUINewTabURL),
"view-source:" + content::GetWebUIURLString(chrome::kChromeUINewTabHost)
"view-source:" +
content::GetWebUIURLString(chrome::kChromeUINewTabHost),
},
{
GURL("chrome-search://local-ntp/local-ntp.html"), "",
GURL("chrome-search://local-ntp/local-ntp.html"),
"",
},
{
GURL("view-source:chrome-search://local-ntp/local-ntp.html"),
......@@ -71,7 +74,8 @@ struct TestItem {
"chrome-extension://fooooooooooooooooooooooooooooooo/bar.html",
},
{
GURL(url::kAboutBlankURL), url::kAboutBlankURL,
GURL(url::kAboutBlankURL),
url::kAboutBlankURL,
},
{
GURL("http://searchurl/?q=tractor+supply"),
......
......@@ -195,6 +195,12 @@ base::string16 FormatViewSourceUrl(
const char kViewSource[] = "view-source:";
const size_t kViewSourceLength = base::size(kViewSource) - 1;
// The URL embedded within view-source should never have destructive elisions
// applied to it. Users of view-source likely want to see the full URL.
format_types &= ~kFormatUrlOmitHTTPS;
format_types &= ~kFormatUrlOmitTrivialSubdomains;
format_types &= ~kFormatUrlTrimAfterHost;
// Format the underlying URL and record adjustments.
const std::string& url_str(url.possibly_invalid_spec());
adjustments->clear();
......
......@@ -241,6 +241,12 @@ TEST(UrlFormatterTest, FormatUrl) {
{"view-source omit slash when it's the entire path",
"view-source:http://a.b/", kFormatUrlOmitDefaults,
net::UnescapeRule::NORMAL, L"view-source:a.b", 12},
{"view-source never applies destructive elisions to its inner URL",
"view-source:https://www.google.com/foo",
kFormatUrlOmitDefaults | kFormatUrlOmitHTTPS |
kFormatUrlOmitTrivialSubdomains | kFormatUrlTrimAfterHost,
net::UnescapeRule::NORMAL, L"view-source:https://www.google.com/foo",
20},
// -------- omit https --------
{"omit https", "https://www.google.com/", kFormatUrlOmitHTTPS,
......
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