summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents/navigation_controller.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-03 19:08:48 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-03 19:08:48 +0000
commita0e692672ede62f71cfaa159cfd90990cb3f860a (patch)
tree1993221296b00b18d9c073b4aa5d092d35b7f993 /chrome/browser/tab_contents/navigation_controller.cc
parentc533bb2982bb58ca7cd8d586bc0bc35e2e7f08ed (diff)
downloadchromium_src-a0e692672ede62f71cfaa159cfd90990cb3f860a.zip
chromium_src-a0e692672ede62f71cfaa159cfd90990cb3f860a.tar.gz
chromium_src-a0e692672ede62f71cfaa159cfd90990cb3f860a.tar.bz2
Fix NavigationController::ClassifyNavigation() to treat redirection correctly.
When we enter an address that redirects to some other page to the address box, it should show the address where we are redirected to after navigation completes. Currently, it doesn't when we follow this procedure more than once as described in BUG 5374. After redirection, the renderer says that it navigated to the same page by returning existing page_id in ViewHostMsg_FrameNavigate_Params, but NavigationController::ClassifyNavigation() compares params.url with pending_entry_->url() and says it's not SAME_PAGE. Therefore, the result is not correctly treated and goes into EXISTING_PAGE handler. It compares the existing entry for the page with pending_entry_. It's false, so it doesn't call DiscardNonCommittedEntriesInternal(). pending_entry_ left not released. Toolbar's view uses this pending_entry_'s url for showing address on the address bar. We should not check URL. Just overwrite entry_ with the response from renderer. TEST= Access http://www.google.com , https://www.google.com , and then https://www.google.com . The address bar should show http://www.google.com . Prepare some site http://example.com which redirects to http://example.org , and then access http://example.com , and then change the redirection to http://example.net . Retry accessing http://example.com . The address bar should show http://example.net . BUG=5374 Original review: http://codereview.chromium.org/115916 Patch by tyoshino@google.com git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17511 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents/navigation_controller.cc')
-rw-r--r--chrome/browser/tab_contents/navigation_controller.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc
index 4a19e58..e33898d 100644
--- a/chrome/browser/tab_contents/navigation_controller.cc
+++ b/chrome/browser/tab_contents/navigation_controller.cc
@@ -552,10 +552,8 @@ NavigationType::Type NavigationController::ClassifyNavigation(
NavigationEntry* existing_entry = entries_[existing_entry_index].get();
if (pending_entry_ &&
- pending_entry_->url() == params.url &&
existing_entry != pending_entry_ &&
- pending_entry_->page_id() == -1 &&
- pending_entry_->url() == existing_entry->url()) {
+ pending_entry_->page_id() == -1) {
// In this case, we have a pending entry for a URL but WebCore didn't do a
// new navigation. This happens when you press enter in the URL bar to
// reload. We will create a pending entry, but WebKit will convert it to
@@ -668,6 +666,9 @@ void NavigationController::RendererDidNavigateToSamePage(
// a regular user-initiated navigation.
existing_entry->set_unique_id(pending_entry_->unique_id());
+ // The URL may have changed due to redirects.
+ existing_entry->set_url(params.url);
+
DiscardNonCommittedEntries();
}
@@ -961,7 +962,7 @@ void NavigationController::DiscardNonCommittedEntriesInternal() {
void NavigationController::DiscardTransientEntry() {
if (transient_entry_index_ == -1)
return;
- entries_.erase(entries_.begin() + transient_entry_index_ );
+ entries_.erase(entries_.begin() + transient_entry_index_);
transient_entry_index_ = -1;
}