Commit 4587f9fb authored by Yi Su's avatar Yi Su Committed by Commit Bot

Revert "Remove legacy check on null NavigationItem in CRWWKNavigationHandler"

This reverts commit 4c3e1c10.

Reason for revert: This CL introduces massive crashes in M78.

Original change's description:
> Remove legacy check on null NavigationItem in CRWWKNavigationHandler
> 
> Now that pending NavigationItem are stored in NavigationContext, it
> will never be null. Remove the legacy code that checks if pending
> NavigationItem exists in CRWWKNavigationHandler.
> 
> Bug: 925304
> Change-Id: I5eb541f068b4a6db1f5322fed2e7318d686a845a
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1730424
> Commit-Queue: Yi Su <mrsuyi@chromium.org>
> Reviewed-by: Eugene But <eugenebut@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#683507}

TBR=eugenebut@chromium.org,mrsuyi@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 925304
Change-Id: I091ae74a41d23454ac1af0ba6c752af9a6d7f41c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1878749Reviewed-by: default avatarYi Su <mrsuyi@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Yi Su <mrsuyi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709080}
parent e6bf641d
...@@ -805,7 +805,35 @@ void ReportOutOfSyncURLInDidStartProvisionalNavigation( ...@@ -805,7 +805,35 @@ void ReportOutOfSyncURLInDidStartProvisionalNavigation(
// |context| will be nil if this navigation has been already committed and // |context| will be nil if this navigation has been already committed and
// finished. // finished.
if (context) { if (context) {
web::NavigationManager* navigationManager =
self.webStateImpl->GetNavigationManager();
GURL pendingURL;
if (navigationManager->GetPendingItemIndex() == -1) {
if (context->GetItem()) {
// Item may not exist if navigation was stopped (see
// crbug.com/969915).
pendingURL = context->GetItem()->GetURL();
}
} else {
if (navigationManager->GetPendingItem()) {
pendingURL = navigationManager->GetPendingItem()->GetURL();
}
}
if ((pendingURL == webViewURL) || (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->SetHasCommitted(true);
}
self.webStateImpl->SetContentsMimeType( self.webStateImpl->SetContentsMimeType(
base::SysNSStringToUTF8(context->GetMimeType())); base::SysNSStringToUTF8(context->GetMimeType()));
} }
...@@ -2178,6 +2206,12 @@ void ReportOutOfSyncURLInDidStartProvisionalNavigation( ...@@ -2178,6 +2206,12 @@ void ReportOutOfSyncURLInDidStartProvisionalNavigation(
// Updates the WKBackForwardListItemHolder navigation item. // Updates the WKBackForwardListItemHolder navigation item.
- (void)updateCurrentBackForwardListItemHolderInWebView:(WKWebView*)webView { - (void)updateCurrentBackForwardListItemHolderInWebView:(WKWebView*)webView {
if (!self.currentNavItem) {
// TODO(crbug.com/925304): Pending item (which stores the holder) should be
// owned by NavigationContext object. Pending item should never be null.
return;
}
web::WKBackForwardListItemHolder* holder = web::WKBackForwardListItemHolder* holder =
self.currentBackForwardListItemHolder; self.currentBackForwardListItemHolder;
...@@ -2319,7 +2353,9 @@ void ReportOutOfSyncURLInDidStartProvisionalNavigation( ...@@ -2319,7 +2353,9 @@ void ReportOutOfSyncURLInDidStartProvisionalNavigation(
// be extracted from the landing page.) // be extracted from the landing page.)
web::NavigationItem* currentItem = self.currentNavItem; web::NavigationItem* currentItem = self.currentNavItem;
if (!currentItem->GetReferrer().url.is_valid()) { // TODO(crbug.com/925304): Pending item (which should be used here) should be
// owned by NavigationContext object. Pending item should never be null.
if (currentItem && !currentItem->GetReferrer().url.is_valid()) {
currentItem->SetReferrer(referrer); currentItem->SetReferrer(referrer);
} }
......
...@@ -316,7 +316,7 @@ ACTION_P5(VerifyDataFinishedContext, ...@@ -316,7 +316,7 @@ ACTION_P5(VerifyDataFinishedContext,
PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED, PageTransitionCoreTypeIs(ui::PageTransition::PAGE_TRANSITION_TYPED,
(*context)->GetPageTransition())); (*context)->GetPageTransition()));
EXPECT_FALSE((*context)->IsSameDocument()); EXPECT_FALSE((*context)->IsSameDocument());
EXPECT_TRUE((*context)->HasCommitted()); EXPECT_FALSE((*context)->HasCommitted());
EXPECT_FALSE((*context)->IsDownload()); EXPECT_FALSE((*context)->IsDownload());
EXPECT_FALSE((*context)->IsPost()); EXPECT_FALSE((*context)->IsPost());
EXPECT_FALSE((*context)->GetError()); EXPECT_FALSE((*context)->GetError());
......
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