Index: content/browser/tab_contents/navigation_controller.cc |
diff --git a/content/browser/tab_contents/navigation_controller.cc b/content/browser/tab_contents/navigation_controller.cc |
index 0144fef9b691ea047279e75249cd6688102e25f0..8c3949f6503869cb4932c408436d9e0c31f4909a 100644 |
--- a/content/browser/tab_contents/navigation_controller.cc |
+++ b/content/browser/tab_contents/navigation_controller.cc |
@@ -883,6 +883,14 @@ void NavigationController::CopyStateFrom(const NavigationController& source) { |
void NavigationController::CopyStateFromAndPrune(NavigationController* source, |
bool remove_first_entry) { |
+ // The SiteInstance and page_id of the last committed entry needs to be |
+ // remembered at this point, in case there is only one committed entry |
+ // and it is pruned. |
+ NavigationEntry* last_committed = GetLastCommittedEntry(); |
+ SiteInstance* site_instance = |
+ last_committed ? last_committed->site_instance() : NULL; |
+ int32 minimum_page_id = last_committed ? last_committed->page_id() : -1; |
+ |
// This code is intended for use when the last entry is the active entry. |
DCHECK((transient_entry_index_ != -1 && |
transient_entry_index_ == entry_count() - 1) || |
@@ -891,6 +899,11 @@ void NavigationController::CopyStateFromAndPrune(NavigationController* source, |
(!pending_entry_ && last_committed_entry_index_ == entry_count() - 1)); |
if (remove_first_entry && entry_count()) { |
+ // If there is only one committed entry, then it needs to be erased in the |
+ // RenderView, but any newly committed entries will be retained. |
+ DCHECK(minimum_page_id >= 0); |
+ if (entry_count() == 1) |
+ ++minimum_page_id; |
Charlie Reis
2011/08/13 00:29:04
Can you add a comment explaining why this is neces
cbentzel
2011/08/13 02:19:12
Done.
|
// Save then restore the pending entry (RemoveEntryAtIndexInternal chucks |
// the pending entry). |
NavigationEntry* pending_entry = pending_entry_; |
@@ -932,8 +945,9 @@ void NavigationController::CopyStateFromAndPrune(NavigationController* source, |
last_committed_entry_index_--; |
} |
- // Update the history in the RenderView. |
- tab_contents_->SetHistoryLengthAndClear(max_source_index); |
+ tab_contents_->SetHistoryLengthAndPrune(site_instance, |
+ max_source_index, |
+ minimum_page_id); |
} |
void NavigationController::PruneAllButActive() { |