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

Unified Diff: content/browser/frame_host/navigation_controller_impl.cc

Issue 1245433002: Don't clear the forward history when replacing entries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test Created 5 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
Index: content/browser/frame_host/navigation_controller_impl.cc
diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc
index 2229ff0952c79f9f8b9d32bb552f026c7c78cb48..267b10e34f709ffaac70b2e947417ab4b6134478 100644
--- a/content/browser/frame_host/navigation_controller_impl.cc
+++ b/content/browser/frame_host/navigation_controller_impl.cc
@@ -1651,17 +1651,23 @@ void NavigationControllerImpl::InsertOrReplaceEntry(
DiscardNonCommittedEntriesInternal();
int current_size = static_cast<int>(entries_.size());
- DCHECK_IMPLIES(replace, current_size > 0);
+
+ // When replacing, don't prune the forward history.
+ if (replace) {
+ DCHECK_GT(current_size, 0);
+ int32 page_id = entry->GetPageID();
+ entries_[last_committed_entry_index_] = entry.release();
+
+ // This is a new page ID, so we need everybody to know about it.
+ delegate_->UpdateMaxPageID(page_id);
+ return;
+ }
if (current_size > 0) {
// Prune any entries which are in front of the current entry.
- // Also prune the current entry if we are to replace the current entry.
// last_committed_entry_index_ must be updated here since calls to
// NotifyPrunedEntries() below may re-enter and we must make sure
// last_committed_entry_index_ is not left in an invalid state.
- if (replace)
- --last_committed_entry_index_;
-
int num_pruned = 0;
while (last_committed_entry_index_ < (current_size - 1)) {
num_pruned++;

Powered by Google App Engine
This is Rietveld 408576698