diff options
author | tburkard@chromium.org <tburkard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-19 21:47:38 +0000 |
---|---|---|
committer | tburkard@chromium.org <tburkard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-19 21:47:38 +0000 |
commit | e7d5089c8c879e6af4ba82bde7919335b02e09d0 (patch) | |
tree | 51384f20121ad889ab3385c8d594d09b6f8fa350 | |
parent | b1420b19dedf7d174e1d42f9aa67b1e591bd893a (diff) | |
download | chromium_src-e7d5089c8c879e6af4ba82bde7919335b02e09d0.zip chromium_src-e7d5089c8c879e6af4ba82bde7919335b02e09d0.tar.gz chromium_src-e7d5089c8c879e6af4ba82bde7919335b02e09d0.tar.bz2 |
Prerendering for redirects -- part 2.
BUG=none
TEST=search for techcrunch and notice how the preloaded techcrunch.com is used despite the redirect
Review URL: http://codereview.chromium.org/6288007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71843 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 31 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 5 |
2 files changed, 28 insertions, 8 deletions
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 522adc9..10d7890 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -1635,6 +1635,10 @@ void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, if (!is_error_page) content_settings_delegate_->ClearCookieSpecificContentSettings(); content_settings_delegate_->ClearGeolocationContentSettings(); + + // Check if the URL we are about to load has been prerendered by any chance, + // and use it if possible. + MaybeUsePreloadedPage(url); } } @@ -1649,6 +1653,10 @@ void TabContents::OnDidRedirectProvisionalLoad(int32 page_id, if (!entry || entry->url() != source_url) return; entry->set_url(target_url); + + // Check if the URL we are about to load has been prerendered by any chance, + // and use it if possible. + MaybeUsePreloadedPage(target_url); } void TabContents::OnDidFailProvisionalLoadWithError( @@ -2563,14 +2571,8 @@ void TabContents::DidNavigate(RenderViewHost* rvh, int extra_invalidate_flags = 0; if (PageTransition::IsMainFrame(params.transition)) { - PrerenderManager* pm = profile()->GetPrerenderManager(); - if (pm != NULL) { - if (pm->MaybeUsePreloadedPage(this, params.url)) { - // TODO(tburkard): If the preloaded page has not finished preloading - // yet, we should not do this. - DidStopLoading(); - return; - } + if (MaybeUsePreloadedPage(params.url)) { + return; } bool was_bookmark_bar_visible = ShouldShowBookmarkBar(); @@ -3378,3 +3380,16 @@ void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); rwh_view->SetSize(view()->GetContainerSize()); } + +bool TabContents::MaybeUsePreloadedPage(const GURL& url) { + PrerenderManager* pm = profile()->GetPrerenderManager(); + if (pm != NULL) { + if (pm->MaybeUsePreloadedPage(this, url)) { + // TODO(tburkard): If the preloaded page has not finished preloading + // yet, we should not do this. + DidStopLoading(); + return true; + } + } + return false; +} diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index ef6f259..050f6ff 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -1089,6 +1089,11 @@ class TabContents : public PageNavigator, virtual void OnImageLoaded(SkBitmap* image, ExtensionResource resource, int index); + // Checks with the PrerenderManager if the specified URL has been preloaded, + // and if so, swap the RenderViewHost with the preload into this TabContents + // object. + bool MaybeUsePreloadedPage(const GURL& url); + // Data for core operation --------------------------------------------------- // Delegate for notifying our owner about stuff. Not owned by us. |