From bec2e5e8855096a1d3105dc85a696ff6a01afd95 Mon Sep 17 00:00:00 2001 From: avi Date: Tue, 30 Jun 2015 10:26:35 -0700 Subject: [PATCH] Don't use page id in NavigatorImpl::NavigateToEntry. There is a hack in NavigatorImpl::NavigateToEntry to avoid adding javascript: URLs to the session history. It uses page id to detect non-history navigations. This switches in an equivalent use of the pending entry index. BUG=369331 TEST=no change Review URL: https://codereview.chromium.org/1213323002 Cr-Commit-Position: refs/heads/master@{#336805} --- content/browser/frame_host/navigator_impl.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc index dfdfa1adbc3a61..bb005a6840e48d 100644 --- a/content/browser/frame_host/navigator_impl.cc +++ b/content/browser/frame_host/navigator_impl.cc @@ -316,14 +316,17 @@ bool NavigatorImpl::NavigateToEntry( // Make sure no code called via RFH::Navigate clears the pending entry. CHECK_EQ(controller_->GetPendingEntry(), &entry); - if (entry.GetPageID() == -1) { - // HACK!! This code suppresses javascript: URLs from being added to - // session history, which is what we want to do for javascript: URLs that - // do not generate content. What we really need is a message from the - // renderer telling us that a new page was not created. The same message - // could be used for mailto: URLs and the like. - if (frame_entry.url().SchemeIs(url::kJavaScriptScheme)) - return false; + if (controller_->GetPendingEntryIndex() == -1 && + frame_entry.url().SchemeIs(url::kJavaScriptScheme)) { + // If the pending entry index is -1 (which means a new navigation rather + // than a history one), and the user typed in a javascript: URL, don't add + // it to the session history. + // + // This is a hack. What we really want is to avoid adding to the history any + // URL that doesn't generate content, and what would be great would be if we + // had a message from the renderer telling us that a new page was not + // created. The same message could be used for mailto: URLs and the like. + return false; } // Notify observers about navigation.