Commit 69391780 authored by Thomas Nguyen's avatar Thomas Nguyen Committed by Commit Bot

Don't omit file scheme for view-source urls

For view-source file scheme URL, clicking on omnibox will inject back
file:/// in the middle, which is inconsistent with https behavior.

This CL will not elide the file scheme in this case.

Bug: 1096066
Change-Id: I99bde8e868fd3799386da7920c7cf79303b30968
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2323337
Commit-Queue: Eric Lawrence [MSFT] <ericlaw@microsoft.com>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Auto-Submit: Thomas Nguyen <haitung.nguyen@avast.com>
Cr-Commit-Position: refs/heads/master@{#793626}
parent c83a6fa2
...@@ -992,6 +992,7 @@ Thiago Farina <thiago.farina@gmail.com> ...@@ -992,6 +992,7 @@ Thiago Farina <thiago.farina@gmail.com>
Thiago Marcos P. Santos <thiago.santos@intel.com> Thiago Marcos P. Santos <thiago.santos@intel.com>
Thomas Butter <tbutter@gmail.com> Thomas Butter <tbutter@gmail.com>
Thomas Conti <tomc@amazon.com> Thomas Conti <tomc@amazon.com>
Thomas Nguyen <haitung.nguyen@avast.com>
Thomas White <im.toms.inbox@gmail.com> Thomas White <im.toms.inbox@gmail.com>
Tiago Vignatti <tiago.vignatti@intel.com> Tiago Vignatti <tiago.vignatti@intel.com>
Tibor Dusnoki <tibor.dusnoki.91@gmail.com> Tibor Dusnoki <tibor.dusnoki.91@gmail.com>
......
...@@ -200,6 +200,7 @@ base::string16 FormatViewSourceUrl( ...@@ -200,6 +200,7 @@ base::string16 FormatViewSourceUrl(
format_types &= ~kFormatUrlOmitHTTPS; format_types &= ~kFormatUrlOmitHTTPS;
format_types &= ~kFormatUrlOmitTrivialSubdomains; format_types &= ~kFormatUrlOmitTrivialSubdomains;
format_types &= ~kFormatUrlTrimAfterHost; format_types &= ~kFormatUrlTrimAfterHost;
format_types &= ~kFormatUrlOmitFileScheme;
// Format the underlying URL and record adjustments. // Format the underlying URL and record adjustments.
const std::string& url_str(url.possibly_invalid_spec()); const std::string& url_str(url.possibly_invalid_spec());
......
...@@ -247,6 +247,19 @@ TEST(UrlFormatterTest, FormatUrl) { ...@@ -247,6 +247,19 @@ TEST(UrlFormatterTest, FormatUrl) {
kFormatUrlOmitTrivialSubdomains | kFormatUrlTrimAfterHost, kFormatUrlOmitTrivialSubdomains | kFormatUrlTrimAfterHost,
net::UnescapeRule::NORMAL, L"view-source:https://www.google.com/foo", net::UnescapeRule::NORMAL, L"view-source:https://www.google.com/foo",
20}, 20},
#if defined(OS_WIN)
{"view-source should not omit file on Windows",
"view-source:file:///C:/Users/homedirname/folder/file.pdf/",
kFormatUrlOmitDefaults | kFormatUrlOmitFileScheme,
net::UnescapeRule::NORMAL,
L"view-source:file:///C:/Users/homedirname/folder/file.pdf/", 19},
#else
{"view-source should not omit file",
"view-source:file:///Users/homedirname/folder/file.pdf/",
kFormatUrlOmitDefaults | kFormatUrlOmitFileScheme,
net::UnescapeRule::NORMAL,
L"view-source:file:///Users/homedirname/folder/file.pdf/", 19},
#endif
// -------- omit https -------- // -------- omit https --------
{"omit https", "https://www.google.com/", kFormatUrlOmitHTTPS, {"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