Commit 7cf254c3 authored by Eugene But's avatar Eugene But Committed by Commit Bot

Do not call 'navigation committed' callback if there was no pending item to commit.

GetPendingItem can return null inside webView:didCommitNavigation:
This is due to crbug.com/925304, which allows to discard pending items
by another navigations prematurely.

If pending item is null, it means that Navigation Manager will not commit
that item and WebStateObservers can crash because they expect to have at
least one committed item.

This CL leaves navigation as "uncommitted" if there was no pending item
inside webView:didCommitNavigation:

Bug: 925304
Change-Id: If9bedd0f74a428946a9026d142da7fc360fd7138
Reviewed-on: https://chromium-review.googlesource.com/c/1448683
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Auto-Submit: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#628224}
parent da74a023
......@@ -4939,7 +4939,20 @@ registerLoadRequestForURL:(const GURL&)requestURL
// |context| will be nil if this navigation has been already committed and
// finished.
if (context) {
context->SetHasCommitted(true);
web::NavigationManager* navigationManager =
_webStateImpl->GetNavigationManager();
if ((navigationManager->GetPendingItem()) ||
(!web::GetWebClient()->IsSlimNavigationManagerEnabled() &&
ui::PageTransitionCoreTypeIs(context->GetPageTransition(),
ui::PAGE_TRANSITION_RELOAD) &&
navigationManager->GetLastCommittedItem())) {
// TODO(crbug.com/925304): Pending item should be owned by
// NavigationContext and should never be null.
// TODO(crbug.com/676129): Reload does not create a pending item but
// operates on last committed item instead.
context->SetHasCommitted(true);
}
context->SetResponseHeaders(_webStateImpl->GetHttpResponseHeaders());
}
......
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