Skip to content

Commit

Permalink
Don't use page id in NavigatorImpl::NavigateToEntry.
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
avi authored and Commit bot committed Jun 30, 2015
1 parent 2e72faf commit bec2e5e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions content/browser/frame_host/navigator_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit bec2e5e

Please sign in to comment.