Commit 9c124df5 authored by Eugene But's avatar Eugene But Committed by Commit Bot

Return empty array from GetBackwardItems and GetForwardItems during session restoration.

This will prevent showing Back And Forward items in the app UI.

Bug: 877671
Change-Id: I93f7868847a58e82d70fc01ebfb11a3a7d30399a
Reviewed-on: https://chromium-review.googlesource.com/c/1356982Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613369}
parent 6f01ecff
......@@ -428,6 +428,9 @@ void WKBasedNavigationManagerImpl::GoForward() {
NavigationItemList WKBasedNavigationManagerImpl::GetBackwardItems() const {
NavigationItemList items;
if (is_restore_session_in_progress_)
return items;
// If the current navigation item is a transient item (e.g. SSL
// interstitial), the last committed item should also be considered part of
// the backward history.
......@@ -445,6 +448,10 @@ NavigationItemList WKBasedNavigationManagerImpl::GetBackwardItems() const {
NavigationItemList WKBasedNavigationManagerImpl::GetForwardItems() const {
NavigationItemList items;
if (is_restore_session_in_progress_)
return items;
for (int index = web_view_cache_.GetCurrentItemIndex() + 1;
index < GetItemCount(); index++) {
items.push_back(GetItemAtIndex(index));
......
......@@ -353,11 +353,11 @@ TEST_P(WebStateTest, RestoreLargeSession) {
navigation_manager->CanGoForward();
if (!restored) {
EXPECT_FALSE(navigation_manager->CanGoForward());
EXPECT_TRUE(navigation_manager->GetBackwardItems().empty());
EXPECT_TRUE(navigation_manager->GetForwardItems().empty());
DCHECK_EQ(0.0, web_state_ptr->GetLoadingProgress());
// TODO(crbug.com/877671): Ensure that the following API work correctly:
// - WebState::GetLastCommittedURL
// - NavigationManager::GetBackwardItems
// - NavigationManager::GetForwardItems
// - NavigationManager::GetLastCommittedItem
// - NavigationManager::GetPendingItem
// - NavigationManager::GetLastCommittedItemIndex
......
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