Commit 48511a8d authored by Danyao Wang's avatar Danyao Wang Committed by Commit Bot

[Bug] Switch GetLastCommittedNonAppSpecificItem to use non-virtual URL.

Currently there is an inconsistency between CreateNavigationItem and
GetLastCommittedNonAppSpecificItem. The former sets user agent type of
an item to NONE if URL is app-specific. The latter looks for an item
with user agent type that is not NONE, and uses VirtualURL to find
these. Historically this has not been a problem because app-specific
URLs always had identical VirtualURL.

Offline Reading List navigation items break this assumption. They have
app-specific URLs (e.g. chrome://offline/<blob>) and regular-looking
VirtualURLs.

Bug: 781284
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I45d9afdb854b1d5340f6d4d2bb7ac306f0897662
Reviewed-on: https://chromium-review.googlesource.com/764540
Commit-Queue: Danyao Wang <danyao@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarYuke Liao <liaoyuke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515983}
parent ee05e52e
...@@ -355,7 +355,7 @@ NavigationItem* NavigationManagerImpl::GetLastCommittedNonAppSpecificItem() ...@@ -355,7 +355,7 @@ NavigationItem* NavigationManagerImpl::GetLastCommittedNonAppSpecificItem()
WebClient* client = GetWebClient(); WebClient* client = GetWebClient();
for (int index = GetLastCommittedItemIndex(); index >= 0; index--) { for (int index = GetLastCommittedItemIndex(); index >= 0; index--) {
NavigationItem* item = GetItemAtIndex(index); NavigationItem* item = GetItemAtIndex(index);
if (!client->IsAppSpecificURL(item->GetVirtualURL())) if (!client->IsAppSpecificURL(item->GetURL()))
return item; return item;
} }
return nullptr; return nullptr;
......
...@@ -1363,6 +1363,9 @@ TEST_P(NavigationManagerTest, UserAgentTypePropagationPastNativeItems) { ...@@ -1363,6 +1363,9 @@ TEST_P(NavigationManagerTest, UserAgentTypePropagationPastNativeItems) {
web::NavigationItem* native_item1 = web::NavigationItem* native_item1 =
navigation_manager()->GetLastCommittedItem(); navigation_manager()->GetLastCommittedItem();
// Having a non-app-specific URL should not change the fact that the native
// item should be skipped when determining user agent inheritance.
native_item1->SetVirtualURL(GURL("http://non-app-specific-url"));
ASSERT_EQ(web::UserAgentType::NONE, native_item1->GetUserAgentType()); ASSERT_EQ(web::UserAgentType::NONE, native_item1->GetUserAgentType());
navigation_manager()->AddPendingItem( navigation_manager()->AddPendingItem(
GURL("http://www.2.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, GURL("http://www.2.com"), Referrer(), ui::PAGE_TRANSITION_TYPED,
......
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