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

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

Issue 3346005: Don't create pending entries when a navigation is initiated by the page. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 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/tab_contents.h ('k') | chrome/browser/tab_contents/test_tab_contents.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/tab_contents.cc
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 542a567568f4ea64cda963a8ed62ead7d60999e2..fa6230873f22c77aeee1a1be04953645800100de 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -224,12 +224,12 @@ ViewMsg_Navigate_Params::NavigationType GetNavigationType(
return ViewMsg_Navigate_Params::NORMAL;
}
-void MakeNavigateParams(const NavigationController& controller,
+void MakeNavigateParams(const NavigationEntry& entry,
+ const NavigationController& controller,
NavigationController::ReloadType reload_type,
ViewMsg_Navigate_Params* params) {
- const NavigationEntry& entry = *controller.pending_entry();
params->page_id = entry.page_id();
- params->pending_history_list_offset = controller.pending_entry_index();
+ params->pending_history_list_offset = controller.GetIndexOfEntry(&entry);
params->current_history_list_offset = controller.last_committed_entry_index();
params->current_history_list_length = controller.entry_count();
params->url = entry.url();
@@ -844,8 +844,12 @@ void TabContents::OpenURL(const GURL& url, const GURL& referrer,
bool TabContents::NavigateToPendingEntry(
NavigationController::ReloadType reload_type) {
- const NavigationEntry& entry = *controller_.pending_entry();
+ return NavigateToEntry(*controller_.pending_entry(), reload_type);
+}
+bool TabContents::NavigateToEntry(
+ const NavigationEntry& entry,
+ NavigationController::ReloadType reload_type) {
RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry);
if (!dest_render_view_host)
return false; // Unable to create the desired render view host.
@@ -877,7 +881,7 @@ bool TabContents::NavigateToPendingEntry(
// Navigate in the desired RenderViewHost.
ViewMsg_Navigate_Params navigate_params;
- MakeNavigateParams(controller_, reload_type, &navigate_params);
+ MakeNavigateParams(entry, controller_, reload_type, &navigate_params);
dest_render_view_host->Navigate(navigate_params);
if (entry.page_id() == -1) {
@@ -1984,8 +1988,15 @@ void TabContents::OnFindReply(int request_id,
}
void TabContents::GoToEntryAtOffset(int offset) {
- if (!delegate_ || delegate_->OnGoToEntryOffset(offset))
- controller_.GoToOffset(offset);
+ if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) {
+ NavigationEntry* entry = controller_.GetEntryAtOffset(offset);
+ if (!entry)
+ return;
+ // Note that we don't call NavigationController::GotToOffset() as we don't
+ // want to create a pending navigation entry (it might end up lingering
+ // http://crbug.com/51680).
+ NavigateToEntry(*entry, NavigationController::NO_RELOAD);
+ }
}
void TabContents::OnMissingPluginStatus(int status) {
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.h ('k') | chrome/browser/tab_contents/test_tab_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698