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

Unified Diff: chrome/browser/ui/search/instant_controller.cc

Issue 15041004: Replace PruneAllButActive with PruneAllButVisible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update tests, mark TODOs 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/search/instant_controller.cc
diff --git a/chrome/browser/ui/search/instant_controller.cc b/chrome/browser/ui/search/instant_controller.cc
index 54f27f664854b9b867b8065be1bdf0dc34fa9b83..c5dc9a22692b058050ac26408fdf0341fd785307 100644
--- a/chrome/browser/ui/search/instant_controller.cc
+++ b/chrome/browser/ui/search/instant_controller.cc
@@ -825,7 +825,11 @@ bool InstantController::CommitIfPossible(InstantCommitType type) {
overlay_->Submit(last_omnibox_text_);
}
+ // Make sure the overlay 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> overlay = overlay_->ReleaseContents();
+ if (!overlay || !overlay->GetController().CanPruneAllButVisible())
+ return false;
// If the overlay page has navigated since the last Update(), we need to add
// the navigation to history ourselves. Else, the page will navigate after
@@ -865,12 +869,12 @@ bool InstantController::CommitIfPossible(InstantCommitType type) {
}
if (type == INSTANT_COMMIT_PRESSED_ALT_ENTER) {
- overlay->GetController().PruneAllButActive();
+ CHECK(overlay->GetController().PruneAllButVisible());
} else {
content::WebContents* active_tab = browser_->GetActiveWebContents();
AddSessionStorageHistogram(extended_enabled_, active_tab, overlay.get());
- overlay->GetController().CopyStateFromAndPrune(
- &active_tab->GetController());
+ CHECK(overlay->GetController().CopyStateFromAndPrune(
+ &active_tab->GetController()));
}
if (extended_enabled_) {

Powered by Google App Engine
This is Rietveld 408576698