Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Unified Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2881933003: Store NavigationItem's unique ID in navigation context. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/web_state/navigation_context_impl.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/crw_web_controller.mm
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm
index ef9d4bd1dcc9b4acf23e91bbe6b490f279f3ff7c..0d25bc4a92d2e4165b7bd017f5120b7e444794eb 100644
--- a/ios/web/web_state/ui/crw_web_controller.mm
+++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -1532,6 +1532,14 @@ registerLoadRequestForURL:(const GURL&)requestURL
std::unique_ptr<web::NavigationContextImpl> context =
web::NavigationContextImpl::CreateNavigationContext(_webStateImpl,
requestURL);
+
+ web::NavigationItem* item = self.navigationManagerImpl->GetPendingItem();
+ // TODO(crbug.com/676129): AddPendingItem does not always create a pending
+ // item. Remove this workaround once the bug is fixed.
+ if (!item) {
+ item = self.navigationManagerImpl->GetLastCommittedItem();
+ }
+ context->SetNavigationItemUniqueID(item->GetUniqueID());
_webStateImpl->SetIsLoading(true);
// TODO(crbug.com/713836): pass context to |OnProvisionalNavigationStarted|.
_webStateImpl->OnProvisionalNavigationStarted(requestURL);
@@ -4552,16 +4560,17 @@ registerLoadRequestForURL:(const GURL&)requestURL
[self webPageChanged];
} else {
// WKWebView has more than one in progress navigation, and committed
- // navigation was not the latest. It is critical to keep last committed
- // URL the same as actual document URL, so try guessing which navigation
- // item should be set to current.
- // TODO(crbug.com/712269):
+ // navigation was not the latest. Change last committed item to one that
+ // corresponds to committed navigation.
+ web::NavigationContextImpl* context =
+ [_navigationStates contextForNavigation:navigation];
for (int i = 0; i < self.navigationManagerImpl->GetItemCount(); i++) {
- web::NavigationItem* item = self.navigationManagerImpl->GetItemAtIndex(i);
- if (item->GetURL() == _documentURL) {
+ if (self.navigationManagerImpl->GetItemAtIndex(i)->GetUniqueID() ==
+ context->GetNavigationItemUniqueID()) {
// Do not discard pending entry, because another pending navigation is
// still in progress and will commit or fail soon.
[self.sessionController goToItemAtIndex:i discardNonCommittedItems:NO];
+ break;
}
}
}
« no previous file with comments | « ios/web/web_state/navigation_context_impl.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698