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

Unified Diff: chrome/browser/tab_contents/navigation_controller.cc

Issue 67150: Make the Go Back navigation work even when redirection is involved.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 8 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
« no previous file with comments | « chrome/browser/tab_contents/navigation_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/navigation_controller.cc
===================================================================
--- chrome/browser/tab_contents/navigation_controller.cc (revision 14058)
+++ chrome/browser/tab_contents/navigation_controller.cc (working copy)
@@ -605,7 +605,14 @@
new_entry->set_site_instance(tab_contents_->GetSiteInstance());
new_entry->set_has_post_data(params.is_post);
- InsertEntry(new_entry);
+ if (PageTransition::IsRedirect(new_entry->transition_type())) {
+ // The current entry is a redirection source. It needs to be replaced with
+ // the new entry to avoid unwanted redirections in navigating backward /
+ // forward.
+ ReplaceCurrentEntry(new_entry);
+ } else {
+ InsertEntry(new_entry);
+ }
}
void NavigationController::RendererDidNavigateToExistingPage(
@@ -808,6 +815,15 @@
}
void NavigationController::InsertEntry(NavigationEntry* entry) {
+ InsertOrReplaceEntry(entry, false);
+}
+
+void NavigationController::ReplaceCurrentEntry(NavigationEntry* entry) {
+ InsertOrReplaceEntry(entry, true);
+}
+
+void NavigationController::InsertOrReplaceEntry(
brettw 2009/04/24 20:57:59 When all the args fit, we usually like to wrap the
+ NavigationEntry* entry, bool replace) {
DCHECK(entry->transition_type() != PageTransition::AUTO_SUBFRAME);
// Copy the pending entry's unique ID to the committed entry.
@@ -821,10 +837,13 @@
int current_size = static_cast<int>(entries_.size());
- // Prune any entries which are in front of the current entry.
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.
+ int prune_up_to = replace ? last_committed_entry_index_ - 1
+ : last_committed_entry_index_;
int num_pruned = 0;
- while (last_committed_entry_index_ < (current_size - 1)) {
+ while (prune_up_to < (current_size - 1)) {
num_pruned++;
entries_.pop_back();
current_size--;
« no previous file with comments | « chrome/browser/tab_contents/navigation_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698