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

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

Issue 2931833004: Always set the navigation pending item for page reload. (Closed)
Patch Set: move transietItem to different CL Created 3 years, 5 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_callbacks_inttest.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 b08853eabb5849c1b0d164fb126dd5db04d28b66..22cf74091cb87c39d1f71c1955b0a191eea77c05 100644
--- a/ios/web/web_state/ui/crw_web_controller.mm
+++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -1520,11 +1520,18 @@ registerLoadRequestForURL:(const GURL&)requestURL
// Typically on PAGE_TRANSITION_CLIENT_REDIRECT.
[[self sessionController] updatePendingItem:requestURL];
} else {
- // A new session history entry needs to be created.
- self.navigationManagerImpl->AddPendingItem(
- requestURL, referrer, transition,
- web::NavigationInitiationType::RENDERER_INITIATED,
- web::NavigationManager::UserAgentOverrideOption::INHERIT);
+ // If this is a reload then there no need to create a new pending item,
+ // instead update the pending item to the last committed item.
+ if (PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD)) {
+ self.sessionController.pendingItemIndex =
+ self.sessionController.lastCommittedItemIndex;
+ } else {
+ // A new session history entry needs to be created.
+ self.navigationManagerImpl->AddPendingItem(
+ requestURL, referrer, transition,
+ web::NavigationInitiationType::RENDERER_INITIATED,
+ web::NavigationManager::UserAgentOverrideOption::INHERIT);
+ }
}
std::unique_ptr<web::NavigationContextImpl> context =
web::NavigationContextImpl::CreateNavigationContext(
@@ -1979,6 +1986,11 @@ registerLoadRequestForURL:(const GURL&)requestURL
BOOL isChromeScheme =
web::GetWebClient()->IsAppSpecificURL(currentNavigationURL);
+ // Since this is implicit reload, no new pending item should be created, set
+ // the pending item index to the last committed item.
+ self.sessionController.pendingItemIndex =
+ self.sessionController.lastCommittedItemIndex;
+
// Don't immediately load the web page if in overlay mode. Always load if
// native.
if (isChromeScheme || !_overlayPreviewMode) {
@@ -2020,6 +2032,10 @@ registerLoadRequestForURL:(const GURL&)requestURL
_lastUserInteraction.reset();
base::RecordAction(UserMetricsAction("Reload"));
GURL url = self.currentNavItem->GetURL();
+ // Reloading shouldn't create create a new pending item, instead set the
+ // pending item index to the last committed item.
+ self.sessionController.pendingItemIndex =
+ self.sessionController.lastCommittedItemIndex;
if ([self shouldLoadURLInNativeView:url]) {
std::unique_ptr<web::NavigationContextImpl> navigationContext = [self
registerLoadRequestForURL:url
« no previous file with comments | « ios/web/web_state/navigation_callbacks_inttest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698