summaryrefslogtreecommitdiffstats
path: root/chrome/browser/prerender
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 14:46:52 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 14:46:52 +0000
commit165602bb51d5ec0aa1f910193ba78896911ce69f (patch)
treea3e0c3a104240e068753c8c36cf3478518518986 /chrome/browser/prerender
parent1c57acfd8ac009a3b4f3ebb93a0f58a3258c3a0e (diff)
downloadchromium_src-165602bb51d5ec0aa1f910193ba78896911ce69f.zip
chromium_src-165602bb51d5ec0aa1f910193ba78896911ce69f.tar.gz
chromium_src-165602bb51d5ec0aa1f910193ba78896911ce69f.tar.bz2
Make prerender plugin/HTML5 tests work with PrerenderContents
when using TabContents. BUG=81229 TEST=PrerenderBrowserTest.PrerenderDelayLoadPlugin, PrerenderIframeDelayLoadPlugin, PrerenderHTML5Audio, PrerenderHTML5Video, PrerenderHTML5VideoJs when PrerenderContents::UseTabContents is true. Review URL: http://codereview.chromium.org/6928012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84246 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/prerender')
-rw-r--r--chrome/browser/prerender/prerender_contents.cc29
-rw-r--r--chrome/browser/prerender/prerender_manager.cc7
2 files changed, 26 insertions, 10 deletions
diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc
index 20e5fb02..d68294e 100644
--- a/chrome/browser/prerender/prerender_contents.cc
+++ b/chrome/browser/prerender/prerender_contents.cc
@@ -272,7 +272,7 @@ void PrerenderContents::StartPrerendering(
// APP_TERMINATING before non-OTR profiles are destroyed).
// TODO(tburkard): figure out if this is needed.
notification_registrar_.Add(this, NotificationType::PROFILE_DESTROYED,
- Source<Profile>(profile_));
+ Source<Profile>(profile_));
// Register to cancel if Authentication is required.
notification_registrar_.Add(this, NotificationType::AUTH_NEEDED,
@@ -285,6 +285,11 @@ void PrerenderContents::StartPrerendering(
notification_registrar_.Add(this, NotificationType::DOWNLOAD_INITIATED,
NotificationService::AllSources());
+ // Register to inform new RenderViews that we're prerendering.
+ notification_registrar_.Add(
+ this, NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB,
+ Source<TabContents>(new_contents));
+
// Register for redirect notifications sourced from |this|.
notification_registrar_.Add(
this, NotificationType::RESOURCE_RECEIVED_REDIRECT,
@@ -293,10 +298,6 @@ void PrerenderContents::StartPrerendering(
DCHECK(load_start_time_.is_null());
load_start_time_ = base::TimeTicks::Now();
- RenderViewHost* rvh = prerender_contents_->render_view_host();
- CHECK(rvh);
- rvh->Send(new ViewMsg_SetIsPrerendering(rvh->routing_id(), true));
-
new_contents->controller().LoadURL(prerender_url_,
referrer_, PageTransition::LINK);
}
@@ -483,6 +484,24 @@ void PrerenderContents::Observe(NotificationType type,
break;
}
+ case NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB: {
+ // When a new RenderView is created for a prerendering TabContents,
+ // tell the new RenderView it's being used for prerendering before any
+ // navigations occur. Note that this is always triggered before the
+ // first navigation, so there's no need to send the message just after the
+ // TabContents is created.
+ if (prerender_contents_.get()) {
+ DCHECK_EQ(Source<TabContents>(source).ptr(),
+ prerender_contents_->tab_contents());
+
+ Details<RenderViewHost> new_render_view_host(details);
+ new_render_view_host->Send(
+ new ViewMsg_SetIsPrerendering(new_render_view_host->routing_id(),
+ true));
+ }
+ break;
+ }
+
default:
NOTREACHED() << "Unexpected notification sent.";
break;
diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc
index 70a1a4b..9b294e7 100644
--- a/chrome/browser/prerender/prerender_manager.cc
+++ b/chrome/browser/prerender/prerender_manager.cc
@@ -542,12 +542,9 @@ bool PrerenderManager::MaybeUsePreloadedPage(TabContents* tab_contents,
RenderViewHost* render_view_host =
prerender_contents->prerender_contents()->render_view_host();
DCHECK(render_view_host);
- // TODO(tburkard): this crashes b/c the navigation type is not set
- // correctly (yet).
- /*
render_view_host->Send(
- new ViewMsg_DisplayPrerenderedPage(render_view_host->routing_id()));
- */
+ new ViewMsg_SetIsPrerendering(render_view_host->routing_id(), false));
+
TabContentsWrapper* new_tab_contents =
prerender_contents->ReleasePrerenderContents();
TabContentsWrapper* old_tab_contents =