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

Side by Side Diff: content/browser/web_contents/navigation_controller_impl.cc

Issue 11308297: Merge 167856 - Ensure a transient entry is discarded on in-page navigations. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1312/src/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/web_contents/navigation_controller_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/navigation_controller_impl.h" 5 #include "content/browser/web_contents/navigation_controller_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_number_conversions.h" // Temporary 10 #include "base/string_number_conversions.h" // Temporary
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 1015
1016 // The entry we found in the list might be pending if the user hit 1016 // The entry we found in the list might be pending if the user hit
1017 // back/forward/reload. This load should commit it (since it's already in the 1017 // back/forward/reload. This load should commit it (since it's already in the
1018 // list, we can just discard the pending pointer). We should also discard the 1018 // list, we can just discard the pending pointer). We should also discard the
1019 // pending entry if it corresponds to a different navigation, since that one 1019 // pending entry if it corresponds to a different navigation, since that one
1020 // is now likely canceled. If it is not canceled, we will treat it as a new 1020 // is now likely canceled. If it is not canceled, we will treat it as a new
1021 // navigation when it arrives, which is also ok. 1021 // navigation when it arrives, which is also ok.
1022 // 1022 //
1023 // Note that we need to use the "internal" version since we don't want to 1023 // Note that we need to use the "internal" version since we don't want to
1024 // actually change any other state, just kill the pointer. 1024 // actually change any other state, just kill the pointer.
1025 if (pending_entry_) 1025 DiscardNonCommittedEntriesInternal();
1026 DiscardNonCommittedEntriesInternal();
1027 1026
1028 // If a transient entry was removed, the indices might have changed, so we 1027 // If a transient entry was removed, the indices might have changed, so we
1029 // have to query the entry index again. 1028 // have to query the entry index again.
1030 last_committed_entry_index_ = 1029 last_committed_entry_index_ =
1031 GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id); 1030 GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id);
1032 } 1031 }
1033 1032
1034 void NavigationControllerImpl::RendererDidNavigateToSamePage( 1033 void NavigationControllerImpl::RendererDidNavigateToSamePage(
1035 const ViewHostMsg_FrameNavigate_Params& params) { 1034 const ViewHostMsg_FrameNavigate_Params& params) {
1036 // This mode implies we have a pending entry that's the same as an existing 1035 // This mode implies we have a pending entry that's the same as an existing
(...skipping 27 matching lines...) Expand all
1064 // entry and it will be the same page as the new navigation (minus the 1063 // entry and it will be the same page as the new navigation (minus the
1065 // reference fragments, of course). We'll update the URL of the existing 1064 // reference fragments, of course). We'll update the URL of the existing
1066 // entry without pruning the forward history. 1065 // entry without pruning the forward history.
1067 existing_entry->SetURL(params.url); 1066 existing_entry->SetURL(params.url);
1068 if (existing_entry->update_virtual_url_with_url()) 1067 if (existing_entry->update_virtual_url_with_url())
1069 UpdateVirtualURLToURL(existing_entry, params.url); 1068 UpdateVirtualURLToURL(existing_entry, params.url);
1070 1069
1071 // This replaces the existing entry since the page ID didn't change. 1070 // This replaces the existing entry since the page ID didn't change.
1072 *did_replace_entry = true; 1071 *did_replace_entry = true;
1073 1072
1074 if (pending_entry_) 1073 DiscardNonCommittedEntriesInternal();
1075 DiscardNonCommittedEntriesInternal();
1076 1074
1077 // If a transient entry was removed, the indices might have changed, so we 1075 // If a transient entry was removed, the indices might have changed, so we
1078 // have to query the entry index again. 1076 // have to query the entry index again.
1079 last_committed_entry_index_ = 1077 last_committed_entry_index_ =
1080 GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id); 1078 GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id);
1081 } 1079 }
1082 1080
1083 void NavigationControllerImpl::RendererDidNavigateNewSubframe( 1081 void NavigationControllerImpl::RendererDidNavigateNewSubframe(
1084 const ViewHostMsg_FrameNavigate_Params& params) { 1082 const ViewHostMsg_FrameNavigate_Params& params) {
1085 if (PageTransitionStripQualifier(params.transition) == 1083 if (PageTransitionStripQualifier(params.transition) ==
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 } 1607 }
1610 } 1608 }
1611 } 1609 }
1612 1610
1613 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 1611 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1614 const base::Callback<base::Time()>& get_timestamp_callback) { 1612 const base::Callback<base::Time()>& get_timestamp_callback) {
1615 get_timestamp_callback_ = get_timestamp_callback; 1613 get_timestamp_callback_ = get_timestamp_callback;
1616 } 1614 }
1617 1615
1618 } // namespace content 1616 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/web_contents/navigation_controller_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698