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

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

Issue 15041004: Replace PruneAllButActive with PruneAllButVisible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 7 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_manager.cc
diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc
index dc1f78006fdc69b5eaa1c6942eea181cec7ef8e9..7e63ec7ea5fadd6e038fce6fdcb4604d0928a7aa 100644
--- a/chrome/browser/prerender/prerender_manager.cc
+++ b/chrome/browser/prerender/prerender_manager.cc
@@ -427,6 +427,14 @@ bool PrerenderManager::MaybeUsePrerenderedPage(WebContents* web_contents,
prerender_data->contents()->prerender_contents()) {
if (web_contents == new_web_contents)
return false; // Do not swap in to ourself.
+
+ // We cannot swap in if there is no last committed entry, because we would
+ // show a blank page under an existing entry from the current tab. Even if
+ // there is a pending entry, it may not commit.
+ // TODO(creis): If there is a pending navigation and no last committed
+ // entry, we might be able to transfer the network request instead.
+ if (!new_web_contents->GetController().CanPruneAllButVisible())
+ return false;
}
// Do not use the prerendered version if there is an opener object.
@@ -520,8 +528,8 @@ bool PrerenderManager::MaybeUsePrerenderedPage(WebContents* web_contents,
MarkWebContentsAsPrerendered(new_web_contents, prerender_contents->origin());
// Merge the browsing history.
- new_web_contents->GetController().CopyStateFromAndPrune(
- &old_web_contents->GetController());
+ CHECK(new_web_contents->GetController().CopyStateFromAndPrune(
+ &old_web_contents->GetController()));
CoreTabHelper::FromWebContents(old_web_contents)->delegate()->
SwapTabContents(old_web_contents, new_web_contents);
prerender_contents->CommitHistory(new_web_contents);

Powered by Google App Engine
This is Rietveld 408576698