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

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

Issue 49003011: Handle should_replace_current_entry in prerender. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: content::kAboutBlankURL Created 7 years 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 a49a9323fab50297a8f70f8430c0e942d2e9e42a..39f7e92725e251d8f0eb22cd3414dc2c43215b00 100644
--- a/content/browser/frame_host/navigation_controller_impl.cc
+++ b/content/browser/frame_host/navigation_controller_impl.cc
@@ -1229,7 +1229,8 @@ void NavigationControllerImpl::CopyStateFrom(
}
void NavigationControllerImpl::CopyStateFromAndPrune(
- NavigationController* temp) {
+ NavigationController* temp,
+ bool replace_entry) {
// It is up to callers to check the invariants before calling this.
CHECK(CanPruneAllButLastCommitted());
@@ -1253,7 +1254,8 @@ void NavigationControllerImpl::CopyStateFromAndPrune(
// We now have one entry, possibly with a new pending entry. Ensure that
// adding the entries from source won't put us over the limit.
DCHECK_EQ(1, GetEntryCount());
- source->PruneOldestEntryIfFull();
+ if (!replace_entry)
+ source->PruneOldestEntryIfFull();
// Insert the entries from source. Don't use source->GetCurrentEntryIndex as
// we don't want to copy over the transient entry. Ignore any pending entry,
@@ -1263,6 +1265,13 @@ void NavigationControllerImpl::CopyStateFromAndPrune(
max_source_index = source->GetEntryCount();
else
max_source_index++;
+
+ // Ignore the source's current entry if merging with replacement.
+ // TODO(davidben): This should preserve entries forward of the current
+ // too. http://crbug.com/317872
+ if (replace_entry && max_source_index > 0)
+ max_source_index--;
+
InsertEntriesFrom(*source, max_source_index);
// Adjust indices such that the last entry and pending are at the end now.

Powered by Google App Engine
This is Rietveld 408576698