Commit 621ddc37 authored by Eugene But's avatar Eugene But Committed by Commit Bot

Reland: 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:

Original CL: https://chromium-review.googlesource.com/c/1448683

Bug: 925304
Change-Id: I7852da807d183e87d1fd029d75ed63cde2287d7b
Reviewed-on: https://chromium-review.googlesource.com/c/1450300
Commit-Queue: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#628537}
parent fa361ec8
......@@ -4965,7 +4965,24 @@ GURL URLEscapedForHistory(const GURL& url) {
// |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()) ||
(context->IsLoadingHtmlString()) ||
(!web::GetWebClient()->IsSlimNavigationManagerEnabled() &&
ui::PageTransitionCoreTypeIs(context->GetPageTransition(),
ui::PAGE_TRANSITION_RELOAD) &&
navigationManager->GetLastCommittedItem())) {
// Commit navigation if at least one of these is true:
// - Navigation has pending item (this should always be true, but
// pending item may not exist due to crbug.com/925304).
// - Navigation is loadHTMLString:baseURL: navigation, which does not
// create a pending item, but modifies committed item instead.
// - Transition type is reload with Legacy Navigation Manager (Legacy
// Navigation Manager does not create pending item for reload due to
// crbug.com/676129)
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