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

Unified Diff: chrome/browser/ui/browser_navigator.cc

Issue 9623018: Prerendered pages are swapped in at browser::Navigate time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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/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)) {

Powered by Google App Engine
This is Rietveld 408576698