Commit 4a5197a6 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Suppress placeholder URLs outside of ios/web.

Don't expose internal placeholder URLs to the UI and to URL-sensing components
outside of //ios/web layer.  Instead, set virtual URL to the placeholder
original URL.

Bug: 1003680
Change-Id: Ibcdc2a88814ea33d985aa6cc269d916e88d59683
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1855299Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Auto-Submit: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705231}
parent d2c567fe
......@@ -1107,6 +1107,16 @@ WKBasedNavigationManagerImpl::WKWebViewCache::GetNavigationItemImplAtIndex(
}
}
// TODO(crbug.com/1003680) This seems to happen if a restored navigation fails
// provisionally before the NavigationContext associates with the original
// navigation. Rather than expose the internal placeholder to the UI and to
// URL-sensing components outside of //ios/web layer, set virtual URL to the
// placeholder original URL here.
if (wk_navigation_util::IsPlaceholderUrl(url)) {
new_item->SetVirtualURL(
wk_navigation_util::ExtractUrlFromPlaceholderUrl(url));
}
SetNavigationItemInWKItem(wk_item, std::move(new_item));
return GetNavigationItemFromWKItem(wk_item);
}
......
......@@ -754,6 +754,19 @@ TEST_F(WKBasedNavigationManagerTest, HideInternalRedirectUrl) {
EXPECT_EQ(url, item->GetURL());
}
// Tests that the virtual URL of a placeholder item is updated to the original
// URL.
TEST_F(WKBasedNavigationManagerTest, HideInternalPlaceholderUrl) {
GURL original_url = GURL("http://www.1.com?query=special%26chars");
GURL url = wk_navigation_util::CreatePlaceholderUrlForUrl(original_url);
NSString* url_spec = base::SysUTF8ToNSString(url.spec());
[mock_wk_list_ setCurrentURL:url_spec];
NavigationItem* item = manager_->GetItemAtIndex(0);
ASSERT_TRUE(item);
EXPECT_EQ(original_url, item->GetVirtualURL());
EXPECT_EQ(url, item->GetURL());
}
// Tests that all NavigationManager APIs return reasonable values in the Empty
// Window Open Navigation edge case. See comments in header file for details.
TEST_F(WKBasedNavigationManagerTest, EmptyWindowOpenNavigation) {
......
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