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

Unified Diff: chrome/browser/tab_contents/test_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
Index: chrome/browser/tab_contents/test_tab_contents.cc
diff --git a/chrome/browser/tab_contents/test_tab_contents.cc b/chrome/browser/tab_contents/test_tab_contents.cc
index 54a6873277b5042c51c140073b44355a2497ec17..2c1ba39429f8a94e86429c405bccfac162bdd6bf 100644
--- a/chrome/browser/tab_contents/test_tab_contents.cc
+++ b/chrome/browser/tab_contents/test_tab_contents.cc
@@ -45,7 +45,7 @@ void TestTabContents::Observe(NotificationType type,
}
}
-TestRenderViewHost* TestTabContents::pending_rvh() {
+TestRenderViewHost* TestTabContents::pending_rvh() const {
return static_cast<TestRenderViewHost*>(
render_manager_.pending_render_view_host_);
}
@@ -70,7 +70,34 @@ void TestTabContents::NavigateAndCommit(const GURL& url) {
bool reverse_on_redirect = false;
BrowserURLHandler::RewriteURLIfNecessary(
&loaded_url, profile(), &reverse_on_redirect);
- static_cast<TestRenderViewHost*>(render_view_host())->SendNavigate(
- static_cast<MockRenderProcessHost*>(render_view_host()->process())->
- max_page_id() + 1, loaded_url);
+
+ // LoadURL created a navigation entry, now simulate the RenderView sending
+ // a notification that it actually navigated.
+ CommitPendingNavigation();
+}
+
+void TestTabContents::CommitPendingNavigation() {
+ // If we are doing a cross-site navigation, this simulates the current RVH
+ // notifying that it has unloaded so the pending RVH is resumed and can
+ // navigate.
+ ProceedWithCrossSiteNavigation();
+ TestRenderViewHost* rvh = pending_rvh();
+ if (!rvh)
+ rvh = static_cast<TestRenderViewHost*>(render_manager_.current_host());
+
+ const NavigationEntry* entry = controller().pending_entry();
+ DCHECK(entry);
+ int page_id = entry->page_id();
+ if (page_id == -1) {
+ // It's a new navigation, assign a never-seen page id to it.
+ page_id =
+ static_cast<MockRenderProcessHost*>(rvh->process())->max_page_id() + 1;
+ }
+ rvh->SendNavigate(page_id, entry->url());
+}
+
+void TestTabContents::ProceedWithCrossSiteNavigation() {
+ if (!pending_rvh())
+ return;
+ render_manager_.ShouldClosePage(true, true);
}
« no previous file with comments | « chrome/browser/tab_contents/test_tab_contents.h ('k') | chrome/browser/translate/translate_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698