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

Unified Diff: chrome/browser/ui/browser_instant_controller.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/ui/browser_instant_controller.cc
diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc
index 34e1ee717c995cf64155a0d39972e9467d70396b..226f5a0eb981c63c9e3884699f3cca87be32d4de 100644
--- a/chrome/browser/ui/browser_instant_controller.cc
+++ b/chrome/browser/ui/browser_instant_controller.cc
@@ -94,19 +94,21 @@ bool BrowserInstantController::MaybeSwapInInstantNTPContents(
return false;
}
+ // Make sure the instant WebContents is in a valid state (i.e., has a last
+ // committed entry, no transient entry, and no existing pending entry).
scoped_ptr<content::WebContents> instant_ntp = instant_.ReleaseNTPContents();
- if (!instant_ntp)
+ if (!instant_ntp || !instant_ntp->GetController().CanPruneAllButVisible())
return false;
*target_contents = instant_ntp.get();
if (source_contents) {
- instant_ntp->GetController().CopyStateFromAndPrune(
- &source_contents->GetController());
+ CHECK(instant_ntp->GetController().CopyStateFromAndPrune(
+ &source_contents->GetController()));
ReplaceWebContentsAt(
browser_->tab_strip_model()->GetIndexOfWebContents(source_contents),
instant_ntp.Pass());
} else {
- instant_ntp->GetController().PruneAllButActive();
+ CHECK(instant_ntp->GetController().PruneAllButVisible());
// If |source_contents| is NULL, then the caller is responsible for
// inserting instant_ntp into the tabstrip and will take ownership.
ignore_result(instant_ntp.release());

Powered by Google App Engine
This is Rietveld 408576698