summaryrefslogtreecommitdiffstats
path: root/content/browser/frame_host
diff options
context:
space:
mode:
authornasko@chromium.org <nasko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-06 22:10:53 +0000
committernasko@chromium.org <nasko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-06 22:10:53 +0000
commitade94b3ec1d1edfd5c527e7a33bab543d0bef04f (patch)
treed83db6bfb1433bf80d5c7e95e4fe81928af9bbb8 /content/browser/frame_host
parentd1ddf8c5d6e674664c91d8d557231e91ed7b3832 (diff)
downloadchromium_src-ade94b3ec1d1edfd5c527e7a33bab543d0bef04f.zip
chromium_src-ade94b3ec1d1edfd5c527e7a33bab543d0bef04f.tar.gz
chromium_src-ade94b3ec1d1edfd5c527e7a33bab543d0bef04f.tar.bz2
Move DidCommitProvisionalLoad code from RenderView to RenderFrame.
BUG=304341 R=creis@chromium.org Review URL: https://codereview.chromium.org/135723003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249516 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/frame_host')
-rw-r--r--content/browser/frame_host/interstitial_page_impl.cc3
-rw-r--r--content/browser/frame_host/interstitial_page_impl.h9
-rw-r--r--content/browser/frame_host/interstitial_page_navigator_impl.cc12
-rw-r--r--content/browser/frame_host/interstitial_page_navigator_impl.h9
-rw-r--r--content/browser/frame_host/navigation_controller_impl.cc17
-rw-r--r--content/browser/frame_host/navigation_controller_impl.h23
-rw-r--r--content/browser/frame_host/navigation_controller_impl_unittest.cc245
-rw-r--r--content/browser/frame_host/navigator.h6
-rw-r--r--content/browser/frame_host/navigator_delegate.cc13
-rw-r--r--content/browser/frame_host/navigator_delegate.h35
-rw-r--r--content/browser/frame_host/navigator_impl.cc167
-rw-r--r--content/browser/frame_host/navigator_impl.h7
-rw-r--r--content/browser/frame_host/render_frame_host_impl.cc109
-rw-r--r--content/browser/frame_host/render_frame_host_impl.h7
-rw-r--r--content/browser/frame_host/render_frame_host_manager_unittest.cc10
15 files changed, 522 insertions, 150 deletions
diff --git a/content/browser/frame_host/interstitial_page_impl.cc b/content/browser/frame_host/interstitial_page_impl.cc
index 090ac12..41470a4 100644
--- a/content/browser/frame_host/interstitial_page_impl.cc
+++ b/content/browser/frame_host/interstitial_page_impl.cc
@@ -23,6 +23,7 @@
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/site_instance_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
+#include "content/common/frame_messages.h"
#include "content/common/view_messages.h"
#include "content/port/browser/render_view_host_delegate_view.h"
#include "content/port/browser/render_widget_host_view_port.h"
@@ -396,7 +397,7 @@ void InterstitialPageImpl::RenderViewTerminated(
void InterstitialPageImpl::DidNavigate(
RenderViewHost* render_view_host,
- const ViewHostMsg_FrameNavigate_Params& params) {
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
// A fast user could have navigated away from the page that triggered the
// interstitial while the interstitial was loading, that would have disabled
// us. In that case we can dismiss ourselves.
diff --git a/content/browser/frame_host/interstitial_page_impl.h b/content/browser/frame_host/interstitial_page_impl.h
index 36e0807..5415fc9 100644
--- a/content/browser/frame_host/interstitial_page_impl.h
+++ b/content/browser/frame_host/interstitial_page_impl.h
@@ -91,6 +91,12 @@ class CONTENT_EXPORT InterstitialPageImpl
RenderViewHost* GetRenderViewHost() const;
#endif
+ // TODO(nasko): This should move to InterstitialPageNavigatorImpl, but in
+ // the meantime make it public, so it can be called directly.
+ void DidNavigate(
+ RenderViewHost* render_view_host,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params);
+
protected:
// NotificationObserver method:
virtual void Observe(int type,
@@ -111,9 +117,6 @@ class CONTENT_EXPORT InterstitialPageImpl
virtual void RenderViewTerminated(RenderViewHost* render_view_host,
base::TerminationStatus status,
int error_code) OVERRIDE;
- virtual void DidNavigate(
- RenderViewHost* render_view_host,
- const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
virtual void UpdateTitle(RenderViewHost* render_view_host,
int32 page_id,
const base::string16& title,
diff --git a/content/browser/frame_host/interstitial_page_navigator_impl.cc b/content/browser/frame_host/interstitial_page_navigator_impl.cc
index 830e1bf..82f40af 100644
--- a/content/browser/frame_host/interstitial_page_navigator_impl.cc
+++ b/content/browser/frame_host/interstitial_page_navigator_impl.cc
@@ -6,12 +6,22 @@
#include "content/browser/frame_host/interstitial_page_impl.h"
#include "content/browser/frame_host/navigator_delegate.h"
+#include "content/browser/renderer_host/render_view_host_impl.h"
namespace content {
InterstitialPageNavigatorImpl::InterstitialPageNavigatorImpl(
InterstitialPageImpl* interstitial,
- NavigationControllerImpl* navigation_controller) {
+ NavigationControllerImpl* navigation_controller)
+ : interstitial_(interstitial) {}
+
+void InterstitialPageNavigatorImpl::DidNavigate(
+ RenderFrameHostImpl* render_frame_host,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params) {
+ // TODO(nasko): Move implementation here, but for the time being call out
+ // to the interstitial page code.
+ interstitial_->DidNavigate(
+ render_frame_host->render_view_host(), input_params);
}
} // namespace content
diff --git a/content/browser/frame_host/interstitial_page_navigator_impl.h b/content/browser/frame_host/interstitial_page_navigator_impl.h
index 1b55fd2..2b57f7a 100644
--- a/content/browser/frame_host/interstitial_page_navigator_impl.h
+++ b/content/browser/frame_host/interstitial_page_navigator_impl.h
@@ -22,9 +22,18 @@ class CONTENT_EXPORT InterstitialPageNavigatorImpl : public Navigator {
InterstitialPageImpl* interstitial,
NavigationControllerImpl* navigation_controller);
+ virtual void DidNavigate(
+ RenderFrameHostImpl* render_frame_host,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params&
+ input_params) OVERRIDE;
+
private:
virtual ~InterstitialPageNavigatorImpl() {}
+ // The InterstitialPage with which this navigator object is associated.
+ // Non owned pointer.
+ InterstitialPageImpl* interstitial_;
+
DISALLOW_COPY_AND_ASSIGN(InterstitialPageNavigatorImpl);
};
diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc
index fff4c63..57a92f5 100644
--- a/content/browser/frame_host/navigation_controller_impl.cc
+++ b/content/browser/frame_host/navigation_controller_impl.cc
@@ -20,6 +20,7 @@
#include "content/browser/frame_host/navigation_entry_screenshot_manager.h"
#include "content/browser/renderer_host/render_view_host_impl.h" // Temporary
#include "content/browser/site_instance_impl.h"
+#include "content/common/frame_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/content_browser_client.h"
@@ -736,7 +737,7 @@ void NavigationControllerImpl::LoadURLWithParams(const LoadURLParams& params) {
bool NavigationControllerImpl::RendererDidNavigate(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
LoadCommittedDetails* details) {
is_initial_navigation_ = false;
@@ -853,7 +854,7 @@ bool NavigationControllerImpl::RendererDidNavigate(
NavigationType NavigationControllerImpl::ClassifyNavigation(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params) const {
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const {
if (params.page_id == -1) {
// The renderer generates the page IDs, and so if it gives us the invalid
// page ID (-1) we know it didn't actually navigate. This happens in a few
@@ -988,7 +989,7 @@ NavigationType NavigationControllerImpl::ClassifyNavigation(
void NavigationControllerImpl::RendererDidNavigateToNewPage(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
bool replace_entry) {
NavigationEntryImpl* new_entry;
bool update_virtual_url;
@@ -1052,7 +1053,7 @@ void NavigationControllerImpl::RendererDidNavigateToNewPage(
void NavigationControllerImpl::RendererDidNavigateToExistingPage(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params) {
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
// We should only get here for main frame navigations.
DCHECK(PageTransitionIsMainFrame(params.transition));
@@ -1105,7 +1106,7 @@ void NavigationControllerImpl::RendererDidNavigateToExistingPage(
void NavigationControllerImpl::RendererDidNavigateToSamePage(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params) {
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
// This mode implies we have a pending entry that's the same as an existing
// entry for this page ID. This entry is guaranteed to exist by
// ClassifyNavigation. All we need to do is update the existing entry.
@@ -1132,7 +1133,7 @@ void NavigationControllerImpl::RendererDidNavigateToSamePage(
void NavigationControllerImpl::RendererDidNavigateInPage(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
bool* did_replace_entry) {
DCHECK(PageTransitionIsMainFrame(params.transition)) <<
"WebKit should only tell us about in-page navs for the main frame.";
@@ -1161,7 +1162,7 @@ void NavigationControllerImpl::RendererDidNavigateInPage(
void NavigationControllerImpl::RendererDidNavigateNewSubframe(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params) {
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
if (PageTransitionCoreTypeIs(params.transition,
PAGE_TRANSITION_AUTO_SUBFRAME)) {
// This is not user-initiated. Ignore.
@@ -1183,7 +1184,7 @@ void NavigationControllerImpl::RendererDidNavigateNewSubframe(
bool NavigationControllerImpl::RendererDidNavigateAutoSubframe(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params) {
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
// We're guaranteed to have a previously committed entry, and we now need to
// handle navigation inside of a subframe in it without creating a new entry.
DCHECK(GetLastCommittedEntry());
diff --git a/content/browser/frame_host/navigation_controller_impl.h b/content/browser/frame_host/navigation_controller_impl.h
index e9206b4..a33f5bc 100644
--- a/content/browser/frame_host/navigation_controller_impl.h
+++ b/content/browser/frame_host/navigation_controller_impl.h
@@ -16,7 +16,7 @@
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_type.h"
-struct ViewHostMsg_FrameNavigate_Params;
+struct FrameHostMsg_DidCommitProvisionalLoad_Params;
namespace content {
class NavigationEntryImpl;
@@ -136,9 +136,10 @@ class CONTENT_EXPORT NavigationControllerImpl
// and it will return false.
//
// TODO(creis): Change RenderViewHost to RenderFrameHost.
- bool RendererDidNavigate(RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params,
- LoadCommittedDetails* details);
+ bool RendererDidNavigate(
+ RenderViewHost* rvh,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
+ LoadCommittedDetails* details);
// Notifies us that we just became active. This is used by the WebContentsImpl
// so that we know to load URLs that were pending as "lazy" loads.
@@ -235,7 +236,7 @@ class CONTENT_EXPORT NavigationControllerImpl
// Classifies the given renderer navigation (see the NavigationType enum).
NavigationType ClassifyNavigation(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params) const;
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const;
// Causes the controller to load the specified entry. The function assumes
// ownership of the pointer since it is put in the navigation list.
@@ -258,24 +259,24 @@ class CONTENT_EXPORT NavigationControllerImpl
// TODO(creis): Change RenderViewHost to RenderFrameHost.
void RendererDidNavigateToNewPage(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
bool replace_entry);
void RendererDidNavigateToExistingPage(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params);
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params);
void RendererDidNavigateToSamePage(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params);
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params);
void RendererDidNavigateInPage(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
bool* did_replace_entry);
void RendererDidNavigateNewSubframe(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params);
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params);
bool RendererDidNavigateAutoSubframe(
RenderViewHost* rvh,
- const ViewHostMsg_FrameNavigate_Params& params);
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params);
// Helper function for code shared between Reload() and ReloadIgnoringCache().
void ReloadInternal(bool check_for_repost, ReloadType reload_type);
diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc
index 318fb62..7b07331 100644
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
@@ -277,7 +277,7 @@ TEST_F(NavigationControllerTest, GoToOffset) {
urls[i] = GURL(base::StringPrintf("http://www.a.com/%d", i));
}
- test_rvh()->SendNavigate(0, urls[0]);
+ main_test_rfh()->SendNavigate(0, urls[0]);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_EQ(urls[0], controller.GetVisibleEntry()->GetVirtualURL());
@@ -286,7 +286,7 @@ TEST_F(NavigationControllerTest, GoToOffset) {
EXPECT_FALSE(controller.CanGoToOffset(1));
for (int i = 1; i <= 4; ++i) {
- test_rvh()->SendNavigate(i, urls[i]);
+ main_test_rfh()->SendNavigate(i, urls[i]);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_EQ(urls[i], controller.GetVisibleEntry()->GetVirtualURL());
@@ -321,7 +321,7 @@ TEST_F(NavigationControllerTest, GoToOffset) {
url_index += offset;
// Check that the GoToOffset will land on the expected page.
EXPECT_EQ(urls[url_index], controller.GetPendingEntry()->GetVirtualURL());
- test_rvh()->SendNavigate(url_index, urls[url_index]);
+ main_test_rfh()->SendNavigate(url_index, urls[url_index]);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// Check that we can go to any valid offset into the history.
@@ -364,7 +364,7 @@ TEST_F(NavigationControllerTest, LoadURL) {
// We should have gotten no notifications from the preceeding checks.
EXPECT_EQ(0U, notifications.size());
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -445,7 +445,7 @@ TEST_F(NavigationControllerTest, LoadURLSameTime) {
controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -455,7 +455,7 @@ TEST_F(NavigationControllerTest, LoadURLSameTime) {
// Simulate the beforeunload ack for the cross-site transition, and then the
// commit.
test_rvh()->SendShouldCloseACK(true);
- test_rvh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -578,7 +578,7 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage) {
controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(0U, notifications.size());
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -588,7 +588,7 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage) {
controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(0U, notifications.size());
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -619,14 +619,14 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage_DifferentMethod) {
const GURL url1("http://foo1");
controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
params.url = url1;
params.transition = PAGE_TRANSITION_TYPED;
params.is_post = true;
params.post_id = 123;
params.page_state = PageState::CreateForTesting(url1, false, 0, 0);
- test_rvh()->SendNavigateWithParams(&params);
+ main_test_rfh()->SendNavigateWithParams(&params);
// The post data should be visible.
NavigationEntry* entry = controller.GetVisibleEntry();
@@ -635,7 +635,7 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage_DifferentMethod) {
EXPECT_EQ(entry->GetPostID(), 123);
controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
// We should not have produced a new session history entry.
ASSERT_EQ(controller.GetVisibleEntry(), entry);
@@ -656,7 +656,7 @@ TEST_F(NavigationControllerTest, LoadURL_Discarded) {
controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(0U, notifications.size());
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -693,13 +693,13 @@ TEST_F(NavigationControllerTest, LoadURL_NoPending) {
const GURL kExistingURL1("http://eh");
controller.LoadURL(
kExistingURL1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// Do a new navigation without making a pending one.
const GURL kNewURL("http://see");
- test_rvh()->SendNavigate(99, kNewURL);
+ main_test_rfh()->SendNavigate(99, kNewURL);
// There should no longer be any pending entry, and the third navigation we
// just made should be committed.
@@ -723,7 +723,7 @@ TEST_F(NavigationControllerTest, LoadURL_NewPending) {
const GURL kExistingURL1("http://eh");
controller.LoadURL(
kExistingURL1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -760,14 +760,14 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) {
const GURL kExistingURL1("http://foo/eh");
controller.LoadURL(
kExistingURL1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
const GURL kExistingURL2("http://foo/bee");
controller.LoadURL(
kExistingURL2, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(1, kExistingURL2);
+ main_test_rfh()->SendNavigate(1, kExistingURL2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -781,7 +781,7 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) {
// Before that commits, do a new navigation.
const GURL kNewURL("http://foo/see");
LoadCommittedDetails details;
- test_rvh()->SendNavigate(3, kNewURL);
+ main_test_rfh()->SendNavigate(3, kNewURL);
// There should no longer be any pending entry, and the third navigation we
// just made should be committed.
@@ -806,7 +806,7 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) {
kExistingURL1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
// Pretend it has bindings so we can tell if we incorrectly copy it.
test_rvh()->AllowBindings(2);
- test_rvh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -859,14 +859,14 @@ TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) {
const GURL kExistingURL1("http://foo/eh");
controller.LoadURL(
kExistingURL1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
const GURL kExistingURL2("http://foo/bee");
controller.LoadURL(
kExistingURL2, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(1, kExistingURL2);
+ main_test_rfh()->SendNavigate(1, kExistingURL2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -879,7 +879,7 @@ TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) {
EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
// Before that commits, a back navigation from the renderer commits.
- test_rvh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, kExistingURL1);
// There should no longer be any pending entry, and the back navigation we
// just made should be committed.
@@ -918,7 +918,7 @@ TEST_F(NavigationControllerTest, LoadURL_IgnorePreemptsPending) {
// Before that commits, a document.write and location.reload can cause the
// renderer to send a FrameNavigate with page_id -1.
- test_rvh()->SendNavigate(-1, kExistingURL);
+ main_test_rfh()->SendNavigate(-1, kExistingURL);
// This should clear the pending entry and notify of a navigation state
// change, so that we do not keep displaying kNewURL.
@@ -995,7 +995,7 @@ TEST_F(NavigationControllerTest, LoadURL_RedirectAbortDoesntShowPendingURL) {
const GURL kExistingURL("http://foo/eh");
controller.LoadURL(kExistingURL, content::Referrer(),
content::PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(0, kExistingURL);
+ main_test_rfh()->SendNavigate(0, kExistingURL);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1122,7 +1122,7 @@ TEST_F(NavigationControllerTest, Reload) {
controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(0U, notifications.size());
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
ASSERT_TRUE(controller.GetVisibleEntry());
@@ -1146,7 +1146,7 @@ TEST_F(NavigationControllerTest, Reload) {
// See http://crbug.com/96041.
EXPECT_TRUE(controller.GetVisibleEntry()->GetTitle().empty());
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1174,14 +1174,14 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) {
const GURL url2("http://foo2");
controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
controller.Reload(true);
EXPECT_EQ(0U, notifications.size());
- test_rvh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1203,7 +1203,7 @@ TEST_F(NavigationControllerTest, ReloadWithGuest) {
const GURL url1("http://foo1");
controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
ASSERT_TRUE(controller.GetVisibleEntry());
// Make the entry believe its RenderProcessHost is a guest.
@@ -1239,7 +1239,8 @@ TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
controller.LoadURL(
original_url, Referrer(), PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(0U, notifications.size());
- test_rvh()->SendNavigateWithOriginalRequestURL(0, final_url, original_url);
+ main_test_rfh()->SendNavigateWithOriginalRequestURL(
+ 0, final_url, original_url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1270,7 +1271,7 @@ TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
EXPECT_TRUE(controller.GetVisibleEntry()->GetTitle().empty());
// Send that the navigation has proceeded; say it got redirected again.
- test_rvh()->SendNavigate(0, final_url);
+ main_test_rfh()->SendNavigate(0, final_url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1320,7 +1321,7 @@ TEST_F(NavigationControllerTest, ResetEntryValuesAfterCommit) {
EXPECT_EQ(1U, pending_entry->redirect_chain().size());
EXPECT_TRUE(pending_entry->should_clear_history_list());
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
// Certain values that are only used for pending entries get reset after
// commit.
@@ -1343,12 +1344,12 @@ TEST_F(NavigationControllerTest, Back) {
RegisterForAllNavNotifications(&notifications, &controller);
const GURL url1("http://foo1");
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
const GURL url2("http://foo2");
- test_rvh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1372,7 +1373,7 @@ TEST_F(NavigationControllerTest, Back) {
EXPECT_GE(controller.GetEntryAtIndex(1)->GetTimestamp(),
controller.GetEntryAtIndex(0)->GetTimestamp());
- test_rvh()->SendNavigate(0, url2);
+ main_test_rfh()->SendNavigate(0, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1406,12 +1407,12 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) {
controller.LoadURL(
url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
controller.LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1427,7 +1428,7 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) {
EXPECT_FALSE(controller.CanGoBack());
EXPECT_TRUE(controller.CanGoForward());
- test_rvh()->SendNavigate(2, url3);
+ main_test_rfh()->SendNavigate(2, url3);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1453,12 +1454,12 @@ TEST_F(NavigationControllerTest, Back_NewPending) {
const GURL kUrl3("http://foo3");
// First navigate two places so we have some back history.
- test_rvh()->SendNavigate(0, kUrl1);
+ main_test_rfh()->SendNavigate(0, kUrl1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// controller.LoadURL(kUrl2, PAGE_TRANSITION_TYPED);
- test_rvh()->SendNavigate(1, kUrl2);
+ main_test_rfh()->SendNavigate(1, kUrl2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1483,12 +1484,12 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) {
const GURL kUrl3("http://foo/3");
// First navigate three places so we have some back history.
- test_rvh()->SendNavigate(0, kUrl1);
- test_rvh()->SendNavigate(1, kUrl2);
- test_rvh()->SendNavigate(2, kUrl3);
+ main_test_rfh()->SendNavigate(0, kUrl1);
+ main_test_rfh()->SendNavigate(1, kUrl2);
+ main_test_rfh()->SendNavigate(2, kUrl3);
// With nothing pending, say we get a navigation to the second entry.
- test_rvh()->SendNavigate(1, kUrl2);
+ main_test_rfh()->SendNavigate(1, kUrl2);
// We know all the entries have the same site instance, so we can just grab
// a random one for looking up other entries.
@@ -1504,7 +1505,7 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) {
// Now go forward to the last item again and say it was committed.
controller.GoForward();
- test_rvh()->SendNavigate(2, kUrl3);
+ main_test_rfh()->SendNavigate(2, kUrl3);
// Now start going back one to the second page. It will be pending.
controller.GoBack();
@@ -1513,7 +1514,7 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) {
// Not synthesize a totally new back event to the first page. This will not
// match the pending one.
- test_rvh()->SendNavigate(0, kUrl1);
+ main_test_rfh()->SendNavigate(0, kUrl1);
// The committed navigation should clear the pending entry.
EXPECT_EQ(-1, controller.GetPendingEntryIndex());
@@ -1532,16 +1533,16 @@ TEST_F(NavigationControllerTest, Forward) {
const GURL url1("http://foo1");
const GURL url2("http://foo2");
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
- test_rvh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
controller.GoBack();
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1565,7 +1566,7 @@ TEST_F(NavigationControllerTest, Forward) {
EXPECT_GE(controller.GetEntryAtIndex(0)->GetTimestamp(),
controller.GetEntryAtIndex(1)->GetTimestamp());
- test_rvh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1597,15 +1598,15 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) {
const GURL url2("http://foo2");
const GURL url3("http://foo3");
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
- test_rvh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
controller.GoBack();
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1621,7 +1622,7 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) {
EXPECT_TRUE(controller.CanGoBack());
EXPECT_FALSE(controller.CanGoForward());
- test_rvh()->SendNavigate(2, url3);
+ main_test_rfh()->SendNavigate(2, url3);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_LIST_PRUNED));
@@ -1649,7 +1650,7 @@ TEST_F(NavigationControllerTest, Redirect) {
controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(0U, notifications.size());
- test_rvh()->SendNavigate(0, url2);
+ main_test_rfh()->SendNavigate(0, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1660,7 +1661,7 @@ TEST_F(NavigationControllerTest, Redirect) {
EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
params.url = url2;
params.transition = PAGE_TRANSITION_SERVER_REDIRECT;
@@ -1706,7 +1707,7 @@ TEST_F(NavigationControllerTest, PostThenRedirect) {
controller.GetVisibleEntry()->SetHasPostData(true);
EXPECT_EQ(0U, notifications.size());
- test_rvh()->SendNavigate(0, url2);
+ main_test_rfh()->SendNavigate(0, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1717,7 +1718,7 @@ TEST_F(NavigationControllerTest, PostThenRedirect) {
EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
params.url = url2;
params.transition = PAGE_TRANSITION_SERVER_REDIRECT;
@@ -1764,7 +1765,7 @@ TEST_F(NavigationControllerTest, ImmediateRedirect) {
EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
params.url = url2;
params.transition = PAGE_TRANSITION_SERVER_REDIRECT;
@@ -1802,12 +1803,12 @@ TEST_F(NavigationControllerTest, NewSubframe) {
RegisterForAllNavNotifications(&notifications, &controller);
const GURL url1("http://foo1");
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
const GURL url2("http://foo2");
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
params.url = url2;
params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME;
@@ -1843,7 +1844,7 @@ TEST_F(NavigationControllerTest, SubframeOnEmptyPage) {
// Navigation controller currently has no entries.
const GURL url("http://foo2");
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
params.url = url;
params.transition = PAGE_TRANSITION_AUTO_SUBFRAME;
@@ -1865,12 +1866,12 @@ TEST_F(NavigationControllerTest, AutoSubframe) {
RegisterForAllNavNotifications(&notifications, &controller);
const GURL url1("http://foo1");
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
const GURL url2("http://foo2");
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
params.url = url2;
params.transition = PAGE_TRANSITION_AUTO_SUBFRAME;
@@ -1896,13 +1897,13 @@ TEST_F(NavigationControllerTest, BackSubframe) {
// Main page.
const GURL url1("http://foo1");
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// First manual subframe navigation.
const GURL url2("http://foo2");
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
params.url = url2;
params.transition = PAGE_TRANSITION_MANUAL_SUBFRAME;
@@ -1961,11 +1962,11 @@ TEST_F(NavigationControllerTest, LinkClick) {
const GURL url1("http://foo1");
const GURL url2("http://foo2");
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
- test_rvh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1986,13 +1987,13 @@ TEST_F(NavigationControllerTest, InPage) {
// Main page.
const GURL url1("http://foo");
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// Ensure main page navigation to same url respects the was_within_same_page
// hint provided in the params.
- ViewHostMsg_FrameNavigate_Params self_params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params self_params;
self_params.page_id = 0;
self_params.url = url1;
self_params.transition = PAGE_TRANSITION_LINK;
@@ -2013,7 +2014,7 @@ TEST_F(NavigationControllerTest, InPage) {
// Fragment navigation to a new page_id.
const GURL url2("http://foo#a");
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
params.url = url2;
params.transition = PAGE_TRANSITION_LINK;
@@ -2032,7 +2033,7 @@ TEST_F(NavigationControllerTest, InPage) {
EXPECT_EQ(2, controller.GetEntryCount());
// Go back one.
- ViewHostMsg_FrameNavigate_Params back_params(params);
+ FrameHostMsg_DidCommitProvisionalLoad_Params back_params(params);
controller.GoBack();
back_params.url = url1;
back_params.page_id = 0;
@@ -2046,7 +2047,7 @@ TEST_F(NavigationControllerTest, InPage) {
EXPECT_EQ(back_params.url, controller.GetVisibleEntry()->GetURL());
// Go forward
- ViewHostMsg_FrameNavigate_Params forward_params(params);
+ FrameHostMsg_DidCommitProvisionalLoad_Params forward_params(params);
controller.GoForward();
forward_params.url = url2;
forward_params.page_id = 1;
@@ -2093,13 +2094,13 @@ TEST_F(NavigationControllerTest, InPage_Replace) {
// Main page.
const GURL url1("http://foo");
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// First navigation.
const GURL url2("http://foo#a");
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0; // Same page_id
params.url = url2;
params.transition = PAGE_TRANSITION_LINK;
@@ -2132,7 +2133,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
// Load an initial page.
{
const GURL url("http://foo/");
- test_rvh()->SendNavigate(0, url);
+ main_test_rfh()->SendNavigate(0, url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
}
@@ -2140,7 +2141,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
// Navigate to a new page.
{
const GURL url("http://foo2/");
- test_rvh()->SendNavigate(1, url);
+ main_test_rfh()->SendNavigate(1, url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
}
@@ -2148,7 +2149,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
// Navigate within the page.
{
const GURL url("http://foo2/#a");
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1; // Same page_id
params.url = url;
params.transition = PAGE_TRANSITION_LINK;
@@ -2171,7 +2172,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
// Perform a client redirect to a new page.
{
const GURL url("http://foo3/");
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 2; // New page_id
params.url = url;
params.transition = PAGE_TRANSITION_CLIENT_REDIRECT;
@@ -2195,7 +2196,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
{
const GURL url("http://foo2/");
controller.GoBack();
- test_rvh()->SendNavigate(1, url);
+ main_test_rfh()->SendNavigate(1, url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_EQ(url, controller.GetVisibleEntry()->GetURL());
@@ -2247,7 +2248,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) {
GURL url(base::StringPrintf("http://www.a.com/%d", url_index));
controller.LoadURL(
url, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(url_index, url);
+ main_test_rfh()->SendNavigate(url_index, url);
}
EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount);
@@ -2259,7 +2260,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) {
GURL url(base::StringPrintf("http://www.a.com/%d", url_index));
controller.LoadURL(
url, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(url_index, url);
+ main_test_rfh()->SendNavigate(url_index, url);
url_index++;
// We should have got a pruned navigation.
@@ -2277,7 +2278,7 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) {
url = GURL(base::StringPrintf("http:////www.a.com/%d", url_index));
controller.LoadURL(
url, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(url_index, url);
+ main_test_rfh()->SendNavigate(url_index, url);
url_index++;
}
EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount);
@@ -2338,7 +2339,7 @@ TEST_F(NavigationControllerTest, RestoreNavigate) {
EXPECT_EQ(timestamp, our_controller.GetEntryAtIndex(0)->GetTimestamp());
// Say we navigated to that entry.
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
params.url = url;
params.transition = PAGE_TRANSITION_LINK;
@@ -2425,7 +2426,7 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) {
fail_load_params));
// Now the pending restored entry commits.
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
params.url = url;
params.transition = PAGE_TRANSITION_LINK;
@@ -2456,7 +2457,7 @@ TEST_F(NavigationControllerTest, Interstitial) {
const GURL url1("http://foo");
controller.LoadURL(
url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
// Now navigate somewhere with an interstitial.
const GURL url2("http://bar");
@@ -2467,7 +2468,7 @@ TEST_F(NavigationControllerTest, Interstitial) {
// At this point the interstitial will be displayed and the load will still
// be pending. If the user continues, the load will commit.
- test_rvh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, url2);
// The page should be a normal page again.
EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL());
@@ -2487,19 +2488,19 @@ TEST_F(NavigationControllerTest, RemoveEntry) {
controller.LoadURL(
url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
controller.LoadURL(
url2, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, url2);
controller.LoadURL(
url3, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(2, url3);
+ main_test_rfh()->SendNavigate(2, url3);
controller.LoadURL(
url4, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(3, url4);
+ main_test_rfh()->SendNavigate(3, url4);
controller.LoadURL(
url5, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(4, url5);
+ main_test_rfh()->SendNavigate(4, url5);
// Try to remove the last entry. Will fail because it is the current entry.
EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1));
@@ -2513,7 +2514,7 @@ TEST_F(NavigationControllerTest, RemoveEntry) {
EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 2));
// Now commit and delete the last entry.
- test_rvh()->SendNavigate(3, url4);
+ main_test_rfh()->SendNavigate(3, url4);
EXPECT_TRUE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1));
EXPECT_EQ(4, controller.GetEntryCount());
EXPECT_EQ(3, controller.GetLastCommittedEntryIndex());
@@ -2550,10 +2551,10 @@ TEST_F(NavigationControllerTest, TransientEntry) {
controller.LoadURL(
url0, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(0, url0);
+ main_test_rfh()->SendNavigate(0, url0);
controller.LoadURL(
url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(1, url1);
+ main_test_rfh()->SendNavigate(1, url1);
notifications.Reset();
@@ -2579,7 +2580,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
// Navigate.
controller.LoadURL(
url2, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(2, url2);
+ main_test_rfh()->SendNavigate(2, url2);
// We should have navigated, transient entry should be gone.
EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
@@ -2590,7 +2591,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
transient_entry->SetURL(transient_url);
controller.SetTransientEntry(transient_entry);
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
- test_rvh()->SendNavigate(3, url3);
+ main_test_rfh()->SendNavigate(3, url3);
// Transient entry should be gone.
EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL());
EXPECT_EQ(controller.GetEntryCount(), 4);
@@ -2602,7 +2603,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
transient_entry->SetURL(transient_url);
controller.SetTransientEntry(transient_entry);
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
- test_rvh()->SendNavigate(4, url4);
+ main_test_rfh()->SendNavigate(4, url4);
EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
EXPECT_EQ(controller.GetEntryCount(), 5);
@@ -2617,7 +2618,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
// Transient entry should be gone.
EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
EXPECT_EQ(controller.GetEntryCount(), 5);
- test_rvh()->SendNavigate(3, url3);
+ main_test_rfh()->SendNavigate(3, url3);
// Add a transient and go to an entry before the current one.
transient_entry = new NavigationEntryImpl;
@@ -2630,7 +2631,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL());
// Visible entry does not update for history navigations until commit.
EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL());
- test_rvh()->SendNavigate(1, url1);
+ main_test_rfh()->SendNavigate(1, url1);
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
// Add a transient and go to an entry after the current one.
@@ -2644,7 +2645,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
// land on url2 (which is visible after the commit).
EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL());
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
- test_rvh()->SendNavigate(2, url2);
+ main_test_rfh()->SendNavigate(2, url2);
EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
// Add a transient and go forward.
@@ -2658,7 +2659,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
EXPECT_FALSE(controller.GetTransientEntry());
EXPECT_EQ(url3, controller.GetPendingEntry()->GetURL());
EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
- test_rvh()->SendNavigate(3, url3);
+ main_test_rfh()->SendNavigate(3, url3);
EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL());
// Add a transient and do an in-page navigation, replacing the current entry.
@@ -2666,7 +2667,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
transient_entry->SetURL(transient_url);
controller.SetTransientEntry(transient_entry);
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
- test_rvh()->SendNavigate(3, url3_ref);
+ main_test_rfh()->SendNavigate(3, url3_ref);
// Transient entry should be gone.
EXPECT_FALSE(controller.GetTransientEntry());
EXPECT_EQ(url3_ref, controller.GetVisibleEntry()->GetURL());
@@ -2690,7 +2691,7 @@ TEST_F(NavigationControllerTest, ReloadTransient) {
// Load |url0|, and start a pending navigation to |url1|.
controller.LoadURL(
url0, Referrer(), PAGE_TRANSITION_TYPED, std::string());
- test_rvh()->SendNavigate(0, url0);
+ main_test_rfh()->SendNavigate(0, url0);
controller.LoadURL(
url1, Referrer(), PAGE_TRANSITION_TYPED, std::string());
@@ -2712,7 +2713,7 @@ TEST_F(NavigationControllerTest, ReloadTransient) {
EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0);
// Load of |transient_url| completes.
- test_rvh()->SendNavigate(1, transient_url);
+ main_test_rfh()->SendNavigate(1, transient_url);
ASSERT_EQ(controller.GetEntryCount(), 2);
EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0);
EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), transient_url);
@@ -2751,7 +2752,7 @@ TEST_F(NavigationControllerTest, RendererInitiatedPendingEntries) {
EXPECT_EQ(url2, controller.GetPendingEntry()->GetVirtualURL());
// Once it commits, the URL and virtual URL should reflect the actual page.
- test_rvh()->SendNavigate(0, url2);
+ main_test_rfh()->SendNavigate(0, url2);
EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL());
EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetVirtualURL());
@@ -2774,7 +2775,7 @@ TEST_F(NavigationControllerTest, RendererInitiatedPendingEntries) {
// TODO(nasko): Until OnNavigate is moved to RenderFrameHost, we need
// to go through the RenderViewHost. The TestRenderViewHost routes navigations
// to the main frame.
- test_rvh()->SendNavigate(0, url2);
+ main_test_rfh()->SendNavigate(0, url2);
EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL());
}
@@ -2794,7 +2795,7 @@ TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) {
controller.LoadURL(url0, Referrer(), PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(url0, controller.GetPendingEntry()->GetURL());
EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL());
- test_rvh()->SendNavigate(0, url0);
+ main_test_rfh()->SendNavigate(0, url0);
// For link clicks (renderer-initiated navigations), the pending entry should
// update before commit but the visible should not.
@@ -2809,7 +2810,7 @@ TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) {
// After commit, both visible should be updated, there should be no pending
// entry, and we should no longer treat the entry as renderer-initiated.
- test_rvh()->SendNavigate(1, url1);
+ main_test_rfh()->SendNavigate(1, url1);
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
EXPECT_FALSE(controller.GetPendingEntry());
EXPECT_FALSE(
@@ -2882,7 +2883,7 @@ TEST_F(NavigationControllerTest, DontShowRendererURLInNewTabAfterCommit) {
EXPECT_FALSE(test_rvh()->has_accessed_initial_document());
// Simulate a commit and then starting a new pending navigation.
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
NavigationController::LoadURLParams load_url2_params(url2);
load_url2_params.transition_type = PAGE_TRANSITION_LINK;
load_url2_params.is_renderer_initiated = true;
@@ -2904,7 +2905,7 @@ TEST_F(NavigationControllerTest, IsInPageNavigation) {
NavigationControllerImpl& controller = controller_impl();
// Navigate to URL with no refs.
const GURL url("http://www.google.com/home.html");
- test_rvh()->SendNavigate(0, url);
+ main_test_rfh()->SendNavigate(0, url);
// Reloading the page is not an in-page navigation.
EXPECT_FALSE(controller.IsURLInPageNavigation(url));
@@ -2914,7 +2915,7 @@ TEST_F(NavigationControllerTest, IsInPageNavigation) {
EXPECT_TRUE(controller.IsURLInPageNavigation(url_with_ref));
// Navigate to URL with refs.
- test_rvh()->SendNavigate(1, url_with_ref);
+ main_test_rfh()->SendNavigate(1, url_with_ref);
// Reloading the page is not an in-page navigation.
EXPECT_FALSE(controller.IsURLInPageNavigation(url_with_ref));
@@ -2942,7 +2943,7 @@ TEST_F(NavigationControllerTest, SameSubframe) {
NavigationControllerImpl& controller = controller_impl();
// Navigate the main frame.
const GURL url("http://www.google.com/");
- test_rvh()->SendNavigate(0, url);
+ main_test_rfh()->SendNavigate(0, url);
// We should be at the first navigation entry.
EXPECT_EQ(controller.GetEntryCount(), 1);
@@ -2950,7 +2951,7 @@ TEST_F(NavigationControllerTest, SameSubframe) {
// Navigate a subframe that would normally count as in-page.
const GURL subframe("http://www.google.com/#");
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
params.url = subframe;
params.transition = PAGE_TRANSITION_AUTO_SUBFRAME;
@@ -3065,7 +3066,7 @@ TEST_F(NavigationControllerTest, SubframeWhilePending) {
// Send a subframe update from the first page, as if one had just
// automatically loaded. Auto subframes don't increment the page ID.
const GURL url1_sub("http://foo/subframe");
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = controller.GetLastCommittedEntry()->GetPageID();
params.url = url1_sub;
params.transition = PAGE_TRANSITION_AUTO_SUBFRAME;
@@ -3740,7 +3741,7 @@ TEST_F(NavigationControllerTest, PruneAllButLastCommittedForPendingNotInList) {
EXPECT_EQ(1, controller.GetEntryCount());
// Try to commit the pending entry.
- test_rvh()->SendNavigate(2, url3);
+ main_test_rfh()->SendNavigate(2, url3);
EXPECT_EQ(-1, controller.GetPendingEntryIndex());
EXPECT_FALSE(controller.GetPendingEntry());
EXPECT_EQ(2, controller.GetEntryCount());
@@ -3782,7 +3783,7 @@ TEST_F(NavigationControllerTest, IsInitialNavigation) {
// After commit, it stays false.
const GURL url1("http://foo1");
- test_rvh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_FALSE(controller.IsInitialNavigation());
@@ -3805,7 +3806,7 @@ TEST_F(NavigationControllerTest, ClearFaviconOnRedirect) {
TestNotificationTracker notifications;
RegisterForAllNavNotifications(&notifications, &controller);
- test_rvh()->SendNavigate(0, kPageWithFavicon);
+ main_test_rfh()->SendNavigate(0, kPageWithFavicon);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -3820,7 +3821,7 @@ TEST_F(NavigationControllerTest, ClearFaviconOnRedirect) {
favicon_status.valid = true;
EXPECT_FALSE(DoImagesMatch(kDefaultFavicon, entry->GetFavicon().image));
- test_rvh()->SendNavigateWithTransition(
+ main_test_rfh()->SendNavigateWithTransition(
0, // same page ID.
kPageWithoutFavicon,
PAGE_TRANSITION_CLIENT_REDIRECT);
@@ -3845,7 +3846,7 @@ TEST_F(NavigationControllerTest, BackNavigationDoesNotClearFavicon) {
TestNotificationTracker notifications;
RegisterForAllNavNotifications(&notifications, &controller);
- test_rvh()->SendNavigate(0, kUrl1);
+ main_test_rfh()->SendNavigate(0, kUrl1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -3859,10 +3860,10 @@ TEST_F(NavigationControllerTest, BackNavigationDoesNotClearFavicon) {
favicon_status.valid = true;
// Navigate to another page and go back to the original page.
- test_rvh()->SendNavigate(1, kUrl2);
+ main_test_rfh()->SendNavigate(1, kUrl2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
- test_rvh()->SendNavigateWithTransition(
+ main_test_rfh()->SendNavigateWithTransition(
0,
kUrl1,
PAGE_TRANSITION_FORWARD_BACK);
diff --git a/content/browser/frame_host/navigator.h b/content/browser/frame_host/navigator.h
index d069bf8..5bab536 100644
--- a/content/browser/frame_host/navigator.h
+++ b/content/browser/frame_host/navigator.h
@@ -10,6 +10,7 @@
#include "content/public/browser/navigation_controller.h"
class GURL;
+struct FrameHostMsg_DidCommitProvisionalLoad_Params;
struct FrameHostMsg_DidFailProvisionalLoadWithError_Params;
namespace base {
@@ -55,6 +56,11 @@ class CONTENT_EXPORT Navigator : public base::RefCounted<Navigator> {
const GURL& source_url,
const GURL& target_url) {}
+ // The RenderFrameHostImpl has committed a navigation.
+ virtual void DidNavigate(
+ RenderFrameHostImpl* render_frame_host,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {}
+
// Causes the Navigator to navigate in the right render frame to |entry|,
// which must be already part of the entries in the navigation controller.
// This does not change the NavigationController state.
diff --git a/content/browser/frame_host/navigator_delegate.cc b/content/browser/frame_host/navigator_delegate.cc
new file mode 100644
index 0000000..a284c0f
--- /dev/null
+++ b/content/browser/frame_host/navigator_delegate.cc
@@ -0,0 +1,13 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/frame_host/navigator_delegate.h"
+
+namespace content {
+
+bool NavigatorDelegate::CanOverscrollContent() {
+ return false;
+}
+
+} // namespace content
diff --git a/content/browser/frame_host/navigator_delegate.h b/content/browser/frame_host/navigator_delegate.h
index e918277..a1fa40c 100644
--- a/content/browser/frame_host/navigator_delegate.h
+++ b/content/browser/frame_host/navigator_delegate.h
@@ -5,16 +5,23 @@
#ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_DELEGATE_H_
#define CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_DELEGATE_H_
+#include "base/strings/string16.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/navigation_controller.h"
+#include "content/public/common/page_transition_types.h"
+
+class GURL;
+struct FrameHostMsg_DidCommitProvisionalLoad_Params;
+struct FrameHostMsg_DidFailProvisionalLoadWithError_Params;
namespace content {
-class RenderFrameHost;
+class RenderFrameHostImpl;
+struct LoadCommittedDetails;
// A delegate API used by Navigator to notify its embedder of navigation
// related events.
-class NavigatorDelegate {
+class CONTENT_EXPORT NavigatorDelegate {
public:
// The RenderFrameHost started a provisional load for the frame
// represented by |render_frame_host|.
@@ -37,6 +44,30 @@ class NavigatorDelegate {
RenderFrameHostImpl* render_frame_host,
const GURL& validated_target_url) {}
+ // A navigation was committed in |render_frame_host|.
+ virtual void DidCommitProvisionalLoad(
+ int64 frame_id,
+ const base::string16& frame_unique_name,
+ bool is_main_frame,
+ const GURL& url,
+ PageTransition transition_type,
+ RenderFrameHostImpl* render_frame_host) {}
+
+ // Handles post-navigation tasks in navigation AFTER the entry has been
+ // committed to the NavigationController. Note that the NavigationEntry is
+ // not provided since it may be invalid/changed after being committed. The
+ // NavigationController's last committed entry is for this navigation.
+ virtual void DidNavigateMainFramePostCommit(
+ const LoadCommittedDetails& details,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {}
+ virtual void DidNavigateAnyFramePostCommit(
+ RenderFrameHostImpl* render_frame_host,
+ const LoadCommittedDetails& details,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {}
+
+ virtual void SetMainFrameMimeType(const std::string& mime_type) {}
+ virtual bool CanOverscrollContent();
+
// Notification to the Navigator embedder that navigation state has
// changed. This method corresponds to
// WebContents::NotifyNavigationStateChanged.
diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc
index 0103285..bd7ce59 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -20,8 +20,10 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/navigation_details.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/common/bindings_policy.h"
+#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/url_utils.h"
@@ -30,6 +32,11 @@ namespace content {
namespace {
+content::RenderFrameHostManager* GetRenderManager(
+ content::RenderFrameHostImpl* rfh) {
+ return rfh->frame_tree_node()->render_manager();
+}
+
ViewMsg_Navigate_Type::Value GetNavigationType(
BrowserContext* browser_context, const NavigationEntryImpl& entry,
NavigationController::ReloadType reload_type) {
@@ -361,4 +368,164 @@ base::TimeTicks NavigatorImpl::GetCurrentLoadStart() {
return current_load_start_;
}
+void NavigatorImpl::DidNavigate(
+ RenderFrameHostImpl* render_frame_host,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params) {
+ FrameHostMsg_DidCommitProvisionalLoad_Params params(input_params);
+ FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree();
+ RenderViewHostImpl* rvh = render_frame_host->render_view_host();
+ bool use_site_per_process =
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess);
+ if (frame_tree->IsFirstNavigationAfterSwap()) {
+ // First navigation should be a main frame navigation.
+ // TODO(creis): This DCHECK is currently disabled for --site-per-process
+ // because cross-process subframe navigations still have a main frame
+ // PageTransition.
+ if (!use_site_per_process)
+ DCHECK(PageTransitionIsMainFrame(params.transition));
+ frame_tree->OnFirstNavigationAfterSwap(params.frame_id);
+ }
+
+ // When using --site-per-process, look up the FrameTreeNode ID that the
+ // renderer-specific frame ID corresponds to.
+ int64 frame_tree_node_id = frame_tree->root()->frame_tree_node_id();
+ if (use_site_per_process) {
+ frame_tree_node_id =
+ render_frame_host->frame_tree_node()->frame_tree_node_id();
+ DCHECK_EQ(params.frame_id,
+ render_frame_host->frame_tree_node()->frame_id());
+
+ // TODO(creis): In the short term, cross-process subframe navigations are
+ // happening in the pending RenderViewHost's top-level frame. (We need to
+ // both mirror the frame tree and get the navigation to occur in the correct
+ // subframe to fix this.) Until then, we should check whether we have a
+ // pending NavigationEntry with a frame ID and if so, treat the
+ // cross-process "main frame" navigation as a subframe navigation. This
+ // limits us to a single cross-process subframe per RVH, and it affects
+ // NavigateToEntry, NavigatorImpl::DidStartProvisionalLoad, and
+ // OnDidFinishLoad.
+ NavigationEntryImpl* pending_entry =
+ NavigationEntryImpl::FromNavigationEntry(
+ controller_->GetPendingEntry());
+ int root_ftn_id = frame_tree->root()->frame_tree_node_id();
+ if (pending_entry &&
+ pending_entry->frame_tree_node_id() != -1 &&
+ pending_entry->frame_tree_node_id() != root_ftn_id) {
+ params.transition = PAGE_TRANSITION_AUTO_SUBFRAME;
+ frame_tree_node_id = pending_entry->frame_tree_node_id();
+ }
+ }
+
+ if (PageTransitionIsMainFrame(params.transition)) {
+ // When overscroll navigation gesture is enabled, a screenshot of the page
+ // in its current state is taken so that it can be used during the
+ // nav-gesture. It is necessary to take the screenshot here, before calling
+ // RenderFrameHostManager::DidNavigateMainFrame, because that can change
+ // WebContents::GetRenderViewHost to return the new host, instead of the one
+ // that may have just been swapped out.
+ if (delegate_ && delegate_->CanOverscrollContent())
+ controller_->TakeScreenshot();
+
+ if (!use_site_per_process)
+ GetRenderManager(render_frame_host)->DidNavigateMainFrame(rvh);
+ }
+
+ // When using --site-per-process, we notify the RFHM for all navigations,
+ // not just main frame navigations.
+ if (use_site_per_process) {
+ FrameTreeNode* frame = frame_tree->FindByID(frame_tree_node_id);
+ // TODO(creis): Rename to DidNavigateFrame.
+ frame->render_manager()->DidNavigateMainFrame(rvh);
+ }
+
+ // Update the site of the SiteInstance if it doesn't have one yet, unless
+ // assigning a site is not necessary for this URL. In that case, the
+ // SiteInstance can still be considered unused until a navigation to a real
+ // page.
+ SiteInstanceImpl* site_instance =
+ static_cast<SiteInstanceImpl*>(render_frame_host->GetSiteInstance());
+ if (!site_instance->HasSite() &&
+ ShouldAssignSiteForURL(params.url)) {
+ site_instance->SetSite(params.url);
+ }
+
+ // Need to update MIME type here because it's referred to in
+ // UpdateNavigationCommands() called by RendererDidNavigate() to
+ // determine whether or not to enable the encoding menu.
+ // It's updated only for the main frame. For a subframe,
+ // RenderView::UpdateURL does not set params.contents_mime_type.
+ // (see http://code.google.com/p/chromium/issues/detail?id=2929 )
+ // TODO(jungshik): Add a test for the encoding menu to avoid
+ // regressing it again.
+ // TODO(nasko): Verify the correctness of the above comment, since some of the
+ // code doesn't exist anymore. Also, move this code in the
+ // PageTransitionIsMainFrame code block above.
+ if (PageTransitionIsMainFrame(params.transition) && delegate_)
+ delegate_->SetMainFrameMimeType(params.contents_mime_type);
+
+ LoadCommittedDetails details;
+ bool did_navigate = controller_->RendererDidNavigate(rvh, params, &details);
+
+ // For now, keep track of each frame's URL in its FrameTreeNode. This lets
+ // us estimate our process count for implementing OOP iframes.
+ // TODO(creis): Remove this when we track which pages commit in each frame.
+ frame_tree->SetFrameUrl(params.frame_id, params.url);
+
+ // Send notification about committed provisional loads. This notification is
+ // different from the NAV_ENTRY_COMMITTED notification which doesn't include
+ // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations.
+ if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) {
+ // For AUTO_SUBFRAME navigations, an event for the main frame is generated
+ // that is not recorded in the navigation history. For the purpose of
+ // tracking navigation events, we treat this event as a sub frame navigation
+ // event.
+ bool is_main_frame = did_navigate ? details.is_main_frame : false;
+ PageTransition transition_type = params.transition;
+ // Whether or not a page transition was triggered by going backward or
+ // forward in the history is only stored in the navigation controller's
+ // entry list.
+ if (did_navigate &&
+ (controller_->GetLastCommittedEntry()->GetTransitionType() &
+ PAGE_TRANSITION_FORWARD_BACK)) {
+ transition_type = PageTransitionFromInt(
+ params.transition | PAGE_TRANSITION_FORWARD_BACK);
+ }
+
+ delegate_->DidCommitProvisionalLoad(params.frame_id,
+ params.frame_unique_name,
+ is_main_frame,
+ params.url,
+ transition_type,
+ render_frame_host);
+ }
+
+ if (!did_navigate)
+ return; // No navigation happened.
+
+ // DO NOT ADD MORE STUFF TO THIS FUNCTION! Your component should either listen
+ // for the appropriate notification (best) or you can add it to
+ // DidNavigateMainFramePostCommit / DidNavigateAnyFramePostCommit (only if
+ // necessary, please).
+
+ // Run post-commit tasks.
+ if (delegate_) {
+ if (details.is_main_frame)
+ delegate_->DidNavigateMainFramePostCommit(details, params);
+
+ delegate_->DidNavigateAnyFramePostCommit(
+ render_frame_host, details, params);
+ }
+}
+
+bool NavigatorImpl::ShouldAssignSiteForURL(const GURL& url) {
+ // about:blank should not "use up" a new SiteInstance. The SiteInstance can
+ // still be used for a normal web site.
+ if (url == GURL(kAboutBlankURL))
+ return false;
+
+ // The embedder will then have the opportunity to determine if the URL
+ // should "use up" the SiteInstance.
+ return GetContentClient()->browser()->ShouldAssignSiteForURL(url);
+}
+
} // namespace content
diff --git a/content/browser/frame_host/navigator_impl.h b/content/browser/frame_host/navigator_impl.h
index 769b5d2..9fa33b6 100644
--- a/content/browser/frame_host/navigator_impl.h
+++ b/content/browser/frame_host/navigator_impl.h
@@ -14,6 +14,7 @@ namespace content {
class NavigationControllerImpl;
class NavigatorDelegate;
+struct LoadCommittedDetails;
// This class is an implementation of Navigator, responsible for managing
// navigations in regular browser tabs.
@@ -37,6 +38,10 @@ class CONTENT_EXPORT NavigatorImpl : public Navigator {
int32 page_id,
const GURL& source_url,
const GURL& target_url) OVERRIDE;
+ virtual void DidNavigate(
+ RenderFrameHostImpl* render_frame_host,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params&
+ input_params) OVERRIDE;
virtual bool NavigateToEntry(
RenderFrameHostImpl* render_frame_host,
const NavigationEntryImpl& entry,
@@ -49,6 +54,8 @@ class CONTENT_EXPORT NavigatorImpl : public Navigator {
private:
virtual ~NavigatorImpl() {}
+ bool ShouldAssignSiteForURL(const GURL& url);
+
// The NavigationController that will keep track of session history for all
// RenderFrameHost objects using this NavigatorImpl.
// TODO(nasko): Move ownership of the NavigationController from
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index 98122c8..570e771 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -6,6 +6,7 @@
#include "base/containers/hash_tables.h"
#include "base/lazy_instance.h"
+#include "base/metrics/user_metrics_action.h"
#include "content/browser/frame_host/cross_process_frame_connector.h"
#include "content/browser/frame_host/frame_tree.h"
#include "content/browser/frame_host/frame_tree_node.h"
@@ -14,9 +15,11 @@
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/common/frame_messages.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/user_metrics.h"
+#include "content/public/common/url_constants.h"
#include "url/gurl.h"
namespace content {
@@ -133,6 +136,8 @@ bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) {
OnDidFailProvisionalLoadWithError)
IPC_MESSAGE_HANDLER(FrameHostMsg_DidRedirectProvisionalLoad,
OnDidRedirectProvisionalLoad)
+ IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad,
+ OnNavigate(msg))
IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK)
IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu)
IPC_END_MESSAGE_MAP_EX()
@@ -187,6 +192,101 @@ void RenderFrameHostImpl::OnDidRedirectProvisionalLoad(
this, page_id, source_url, target_url);
}
+// Called when the renderer navigates. For every frame loaded, we'll get this
+// notification containing parameters identifying the navigation.
+//
+// Subframes are identified by the page transition type. For subframes loaded
+// as part of a wider page load, the page_id will be the same as for the top
+// level frame. If the user explicitly requests a subframe navigation, we will
+// get a new page_id because we need to create a new navigation entry for that
+// action.
+void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) {
+ // Read the parameters out of the IPC message directly to avoid making another
+ // copy when we filter the URLs.
+ PickleIterator iter(msg);
+ FrameHostMsg_DidCommitProvisionalLoad_Params validated_params;
+ if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>::
+ Read(&msg, &iter, &validated_params))
+ return;
+
+ // If we're waiting for a cross-site beforeunload ack from this renderer and
+ // we receive a Navigate message from the main frame, then the renderer was
+ // navigating already and sent it before hearing the ViewMsg_Stop message.
+ // We do not want to cancel the pending navigation in this case, since the
+ // old page will soon be stopped. Instead, treat this as a beforeunload ack
+ // to allow the pending navigation to continue.
+ if (render_view_host_->is_waiting_for_beforeunload_ack_ &&
+ render_view_host_->unload_ack_is_for_cross_site_transition_ &&
+ PageTransitionIsMainFrame(validated_params.transition)) {
+ render_view_host_->OnShouldCloseACK(
+ true, render_view_host_->send_should_close_start_time_,
+ base::TimeTicks::Now());
+ return;
+ }
+
+ // If we're waiting for an unload ack from this renderer and we receive a
+ // Navigate message, then the renderer was navigating before it received the
+ // unload request. It will either respond to the unload request soon or our
+ // timer will expire. Either way, we should ignore this message, because we
+ // have already committed to closing this renderer.
+ if (render_view_host_->is_waiting_for_unload_ack_)
+ return;
+
+ // Cache the main frame id, so we can use it for creating the frame tree
+ // root node when needed.
+ if (PageTransitionIsMainFrame(validated_params.transition)) {
+ if (render_view_host_->main_frame_id_ == -1) {
+ render_view_host_->main_frame_id_ = validated_params.frame_id;
+ } else {
+ // TODO(nasko): We plan to remove the usage of frame_id in navigation
+ // and move to routing ids. This is in place to ensure that a
+ // renderer is not misbehaving and sending us incorrect data.
+ DCHECK_EQ(render_view_host_->main_frame_id_, validated_params.frame_id);
+ }
+ }
+ RenderProcessHost* process = GetProcess();
+
+ // Attempts to commit certain off-limits URL should be caught more strictly
+ // than our FilterURL checks below. If a renderer violates this policy, it
+ // should be killed.
+ if (!CanCommitURL(validated_params.url)) {
+ VLOG(1) << "Blocked URL " << validated_params.url.spec();
+ validated_params.url = GURL(kAboutBlankURL);
+ RecordAction(base::UserMetricsAction("CanCommitURL_BlockedAndKilled"));
+ // Kills the process.
+ process->ReceivedBadMessage();
+ }
+
+ // Now that something has committed, we don't need to track whether the
+ // initial page has been accessed.
+ render_view_host_->has_accessed_initial_document_ = false;
+
+ // Without this check, an evil renderer can trick the browser into creating
+ // a navigation entry for a banned URL. If the user clicks the back button
+ // followed by the forward button (or clicks reload, or round-trips through
+ // session restore, etc), we'll think that the browser commanded the
+ // renderer to load the URL and grant the renderer the privileges to request
+ // the URL. To prevent this attack, we block the renderer from inserting
+ // banned URLs into the navigation controller in the first place.
+ process->FilterURL(false, &validated_params.url);
+ process->FilterURL(true, &validated_params.referrer.url);
+ for (std::vector<GURL>::iterator it(validated_params.redirects.begin());
+ it != validated_params.redirects.end(); ++it) {
+ process->FilterURL(false, &(*it));
+ }
+ process->FilterURL(true, &validated_params.searchable_form_url);
+
+ // Without this check, the renderer can trick the browser into using
+ // filenames it can't access in a future session restore.
+ if (!render_view_host_->CanAccessFilesOfPageState(
+ validated_params.page_state)) {
+ GetProcess()->ReceivedBadMessage();
+ return;
+ }
+
+ frame_tree_node()->navigator()->DidNavigate(this, validated_params);
+}
+
void RenderFrameHostImpl::SwapOut() {
if (render_view_host_->IsRenderViewLive()) {
Send(new FrameMsg_SwapOut(routing_id_));
@@ -221,4 +321,13 @@ void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) {
delegate_->ShowContextMenu(this, validated_params);
}
+bool RenderFrameHostImpl::CanCommitURL(const GURL& url) {
+ // TODO(creis): We should also check for WebUI pages here. Also, when the
+ // out-of-process iframes implementation is ready, we should check for
+ // cross-site URLs that are not allowed to commit in this process.
+
+ // Give the client a chance to disallow URLs from committing.
+ return GetContentClient()->browser()->CanCommitURL(GetProcess(), url);
+}
+
} // namespace content
diff --git a/content/browser/frame_host/render_frame_host_impl.h b/content/browser/frame_host/render_frame_host_impl.h
index 64864cb..7f1c04c 100644
--- a/content/browser/frame_host/render_frame_host_impl.h
+++ b/content/browser/frame_host/render_frame_host_impl.h
@@ -97,6 +97,7 @@ class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost {
bool is_swapped_out);
private:
+ friend class TestRenderFrameHost;
friend class TestRenderViewHost;
// IPC Message handlers.
@@ -110,9 +111,15 @@ class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost {
void OnDidRedirectProvisionalLoad(int32 page_id,
const GURL& source_url,
const GURL& target_url);
+ void OnNavigate(const IPC::Message& msg);
void OnSwapOutACK();
void OnContextMenu(const ContextMenuParams& params);
+ // Returns whether the given URL is allowed to commit in the current process.
+ // This is a more conservative check than RenderProcessHost::FilterURL, since
+ // it will be used to kill processes that commit unauthorized URLs.
+ bool CanCommitURL(const GURL& url);
+
// For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a
// refcount that calls Shutdown when it reaches zero. This allows each
// RenderFrameHostManager to just care about RenderFrameHosts, while ensuring
diff --git a/content/browser/frame_host/render_frame_host_manager_unittest.cc b/content/browser/frame_host/render_frame_host_manager_unittest.cc
index 92744e8..91f9761 100644
--- a/content/browser/frame_host/render_frame_host_manager_unittest.cc
+++ b/content/browser/frame_host/render_frame_host_manager_unittest.cc
@@ -5,9 +5,11 @@
#include "base/strings/utf_string_conversions.h"
#include "content/browser/frame_host/navigation_controller_impl.h"
#include "content/browser/frame_host/navigation_entry_impl.h"
+#include "content/browser/frame_host/navigator.h"
#include "content/browser/frame_host/render_frame_host_manager.h"
#include "content/browser/site_instance_impl.h"
#include "content/browser/webui/web_ui_controller_factory_registry.h"
+#include "content/common/frame_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
@@ -973,7 +975,7 @@ TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) {
pending_render_view_host());
// Before that RVH has committed, the evil page reloads itself.
- ViewHostMsg_FrameNavigate_Params params;
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
params.url = kUrl2;
params.transition = PAGE_TRANSITION_CLIENT_REDIRECT;
@@ -982,7 +984,11 @@ TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) {
params.was_within_same_page = false;
params.is_post = false;
params.page_state = PageState::CreateFromURL(kUrl2);
- contents()->DidNavigate(evil_rvh, params);
+
+ RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(evil_rvh);
+ RenderFrameHostImpl* rfh = RenderFrameHostImpl::FromID(
+ rvh->GetProcess()->GetID(), rvh->main_frame_routing_id());
+ contents()->GetFrameTree()->root()->navigator()->DidNavigate(rfh, params);
// That should have cancelled the pending RVH, and the evil RVH should be the
// current one.