Index: chrome/browser/ui/browser_navigator.cc |
diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc |
index 6dd05b2ab8d55a89282f326e563bcf52006b0eeb..80aa31904ed72b37286f5a7b8acc22f8b1973dbc 100644 |
--- a/chrome/browser/ui/browser_navigator.cc |
+++ b/chrome/browser/ui/browser_navigator.cc |
@@ -16,6 +16,8 @@ |
#include "chrome/browser/google/google_util.h" |
#include "chrome/browser/prefs/incognito_mode_prefs.h" |
#include "chrome/browser/prefs/pref_service.h" |
+#include "chrome/browser/prerender/prerender_manager.h" |
+#include "chrome/browser/prerender/prerender_manager_factory.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/rlz/rlz.h" |
#include "chrome/browser/tab_contents/tab_util.h" |
@@ -361,6 +363,18 @@ void InitializeExtraHeaders(browser::NavigateParams* params, |
#endif |
} |
+// If a prerendered page exists for |url|, replace the page at |target_contents| |
+// with it. |
+bool SwapInPrerender(TabContentsWrapper* target_contents, const GURL& url) { |
+ prerender::PrerenderManager* prerender_manager = |
+ prerender::PrerenderManagerFactory::GetForProfile( |
+ target_contents->profile()); |
+ if (!prerender_manager) |
Peter Kasting
2012/03/08 20:56:38
Nit: Shorter:
return prerender_manager && prere
|
+ return false; |
+ return prerender_manager->MaybeUsePrerenderedPage( |
+ target_contents->web_contents(), url); |
+} |
+ |
} // namespace |
namespace browser { |
@@ -535,6 +549,9 @@ void Navigate(NavigateParams* params) { |
InitializeExtraHeaders(params, params->target_contents->profile(), |
&extra_headers); |
+ if (SwapInPrerender(params->target_contents, url)) |
+ return; |
+ |
// Try to handle non-navigational URLs that popup dialogs and such, these |
// should not actually navigate. |
if (!HandleNonNavigationAboutURL(url)) { |