Commit 5466161b authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Do not store file:// URL in history

From my tests, it seems that the file:// URL can only access files that
are stored in the app folder. For now the only folder we have is emptied
every time the app is launched, so storing the URL in the history don't
make sense as the user won't be able to revisit them.

Bug: 1003234
Change-Id: I7b5795009b0f5ddb2fb68f4eb4df476ddfe89b8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1803148
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699279}
parent 6d334301
......@@ -202,3 +202,23 @@ TEST_F(HistoryTabHelperTest, TestNTPNotAdded) {
QueryURL(ntp_url);
EXPECT_NE(ntp_url, latest_row_result_.url());
}
// Tests that a file:// URL isn't added to history.
TEST_F(HistoryTabHelperTest, TestFileNotAdded) {
HistoryTabHelper* helper = HistoryTabHelper::FromWebState(&web_state_);
ASSERT_TRUE(helper);
std::unique_ptr<web::NavigationItem> item = web::NavigationItem::Create();
GURL test_url("https://www.google.com/");
item->SetVirtualURL(test_url);
AddVisitForURL(test_url);
QueryURL(test_url);
EXPECT_EQ(test_url, latest_row_result_.url());
item = web::NavigationItem::Create();
GURL file_url("file://path/to/file");
item->SetVirtualURL(file_url);
AddVisitForURL(file_url);
QueryURL(file_url);
EXPECT_NE(file_url, latest_row_result_.url());
}
......@@ -17,16 +17,17 @@ bool CanAddURLToHistory(const GURL& url) {
if (!url.is_valid())
return false;
// TODO(crbug.com/1007192): Don't store the URL as we aren't persiting the
// files. Maybe we should start persisting the files and store the URL.
// TODO: We should allow ChromeUIScheme URLs if they have been explicitly
// typed. Right now, however, these are marked as typed even when triggered
// by a shortcut or menu action.
if (url.SchemeIs(url::kJavaScriptScheme) ||
url.SchemeIs(dom_distiller::kDomDistillerScheme) ||
url.SchemeIs(kChromeUIScheme))
url.SchemeIs(kChromeUIScheme) || url.SchemeIs(url::kFileScheme))
return false;
// Allow all about: and chrome: URLs except about:blank|newtab, since the user
// may like to see "chrome://version", etc. in their history and autocomplete.
// Allow all about: URLs except about:blank|newtab.
if (url == url::kAboutBlankURL || url == kChromeUIAboutNewTabURL)
return false;
......
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