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

Unified Diff: chrome/browser/prerender/prerender_contents.cc

Issue 7736003: Revert 98539 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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/prerender/prerender_contents.cc
===================================================================
--- chrome/browser/prerender/prerender_contents.cc (revision 98544)
+++ chrome/browser/prerender/prerender_contents.cc (working copy)
@@ -172,6 +172,7 @@
prerender_contents_.reset(new TabContentsWrapper(new_contents));
TabContentsObserver::Observe(new_contents);
+ gfx::Rect tab_bounds;
if (source_render_view_host) {
DCHECK(source_render_view_host->view() != NULL);
TabContents* source_tc =
@@ -182,7 +183,7 @@
starting_page_id_ = source_tc->GetMaxPageID();
// Set the size of the new TC to that of the old TC.
- source_tc->view()->GetContainerBounds(&tab_bounds_);
+ source_tc->view()->GetContainerBounds(&tab_bounds);
}
} else {
int max_page_id = -1;
@@ -208,7 +209,7 @@
if (active_browser) {
TabContents* active_tab_contents = active_browser->GetTabContentsAt(
active_browser->active_index());
- active_tab_contents->view()->GetContainerBounds(&tab_bounds_);
+ active_tab_contents->view()->GetContainerBounds(&tab_bounds);
}
}
@@ -222,6 +223,9 @@
tab_contents_delegate_.reset(new TabContentsDelegateImpl(this));
new_contents->set_delegate(tab_contents_delegate_.get());
+ // Set the size of the prerender TabContents.
+ prerender_contents_->view()->SizeContents(tab_bounds.size());
+
// Register as an observer of the RenderViewHost so we get messages.
render_view_host_observer_.reset(
new PrerenderRenderViewHostObserver(this, render_view_host_mutable()));
@@ -254,6 +258,12 @@
this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB,
Source<TabContents>(new_contents));
+ // Register to be told when the RenderView is ready, so we can hide it.
+ // It will automatically be set to visible when we resize it, otherwise.
+ notification_registrar_.Add(this,
+ content::NOTIFICATION_TAB_CONTENTS_CONNECTED,
+ Source<TabContents>(new_contents));
+
// Register for redirect notifications sourced from |this|.
notification_registrar_.Add(
this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
@@ -371,17 +381,20 @@
new ChromeViewMsg_SetIsPrerendering(
new_render_view_host->routing_id(),
true));
+ }
+ break;
+ }
- // Set the size of the prerender TabContents. This must be done after
- // the RenderView has been created so that the RenderView will be
- // informated promptly of the size change.
- prerender_contents_->view()->SizeContents(tab_bounds_.size());
-
- // Hide the tab contents. Must be done after setting the size, as
- // resizing currently forces the RenderView to set itself as visible.
+ case content::NOTIFICATION_TAB_CONTENTS_CONNECTED: {
+ if (prerender_contents_.get()) {
+ DCHECK_EQ(Source<TabContents>(source).ptr(),
+ prerender_contents_->tab_contents());
+ // Set the new TabContents and its RenderViewHost as hidden, to reduce
+ // resource usage. This can only be done after the size has been sent
+ // to the RenderView, which is why it's done here.
prerender_contents_->tab_contents()->HideContents();
}
- break;
+ return;
}
case content::NOTIFICATION_CREATING_NEW_WINDOW_CANCELLED: {
« no previous file with comments | « chrome/browser/prerender/prerender_contents.h ('k') | chrome/test/data/prerender/prerender_visibility_hidden_quick.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698