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 ccd31a039220858dec9b95c4540a465aae73177c..214cdc442f762e964c9f38a62e377a3193483ce9 100644 |
--- a/ios/web/web_state/ui/crw_web_controller.mm |
+++ b/ios/web/web_state/ui/crw_web_controller.mm |
@@ -1521,11 +1521,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( |
@@ -1988,6 +1995,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) { |
@@ -2029,6 +2041,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 = |
Eugene But (OOO till 7-30)
2017/06/15 00:08:11
Wouldn't |reload| eventually call |registerLoadReq
mrefaat
2017/06/15 18:35:35
This will not happen in every case, only when the
Eugene But (OOO till 7-30)
2017/06/16 03:25:46
Thanks. So this code is needed to cover NativeCont
mrefaat
2017/06/16 19:28:04
This will happen in case the reload is triggered b
Eugene But (OOO till 7-30)
2017/06/17 02:57:14
But reload triggered by renderer calls |reload| as
mrefaat
2017/06/17 11:33:08
I'm not sure, from what i see it seems that goDelt
|
+ self.sessionController.lastCommittedItemIndex; |
if ([self shouldLoadURLInNativeView:url]) { |
std::unique_ptr<web::NavigationContextImpl> navigationContext = [self |
registerLoadRequestForURL:url |