diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/instant/instant_controller.cc | 11 | ||||
-rw-r--r-- | chrome/browser/tab_contents/web_contents_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 11 |
3 files changed, 17 insertions, 9 deletions
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc index c7b7494..4949783 100644 --- a/chrome/browser/instant/instant_controller.cc +++ b/chrome/browser/instant/instant_controller.cc @@ -234,7 +234,18 @@ bool InstantController::IsCurrent() { void InstantController::CommitCurrentPreview(InstantCommitType type) { DCHECK(loader_manager_.get()); DCHECK(loader_manager_->current_loader()); + bool showing_instant = + loader_manager_->current_loader()->is_showing_instant(); TabContentsWrapper* tab = ReleasePreviewContents(type); + // If the loader was showing an instant page then it's navigation stack is + // something like: search-engine-home-page (eg google.com) search-term1 + // search-term2 .... Each search-term navigation corresponds to the page + // deciding enough time has passed to commit a navigation. We don't want the + // searche-engine-home-page navigation in this case so we pass true to + // CopyStateFromAndPrune to have the search-engine-home-page navigation + // removed. + tab->controller().CopyStateFromAndPrune( + &tab_contents_->controller(), showing_instant); delegate_->CommitInstant(tab); CompleteRelease(tab->tab_contents()); } diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc index 0bc1463..7de346d 100644 --- a/chrome/browser/tab_contents/web_contents_unittest.cc +++ b/chrome/browser/tab_contents/web_contents_unittest.cc @@ -1560,7 +1560,7 @@ TEST_F(TabContentsTest, CopyStateFromAndPruneSourceInterstitial) { scoped_ptr<TestTabContents> other_contents(CreateTestTabContents()); NavigationController& other_controller = other_contents->controller(); other_contents->NavigateAndCommit(url3); - other_controller.CopyStateFromAndPrune(&controller()); + other_controller.CopyStateFromAndPrune(&controller(), false); // The merged controller should only have two entries: url1 and url2. ASSERT_EQ(2, other_controller.entry_count()); @@ -1601,7 +1601,7 @@ TEST_F(TabContentsTest, CopyStateFromAndPruneTargetInterstitial) { EXPECT_TRUE(interstitial->is_showing()); EXPECT_EQ(2, other_controller.entry_count()); - other_controller.CopyStateFromAndPrune(&controller()); + other_controller.CopyStateFromAndPrune(&controller(), false); // The merged controller should only have two entries: url1 and url2. ASSERT_EQ(2, other_controller.entry_count()); diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 310778f..8eaa0fb 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -3519,14 +3519,11 @@ void Browser::CommitInstant(TabContentsWrapper* preview_contents) { int index = tab_handler_->GetTabStripModel()->GetIndexOfTabContents(tab_contents); DCHECK_NE(TabStripModel::kNoTab, index); - preview_contents->controller().CopyStateFromAndPrune( - &tab_contents->controller()); // TabStripModel takes ownership of preview_contents. - TabContentsWrapper* old_contents = - tab_handler_->GetTabStripModel()->ReplaceTabContentsAt( - index, preview_contents); - // InstantUnloadHandler takes ownership of old_contents. - instant_unload_handler_->RunUnloadListenersOrDestroy(old_contents, index); + tab_handler_->GetTabStripModel()->ReplaceTabContentsAt( + index, preview_contents); + // InstantUnloadHandler takes ownership of tab_contents. + instant_unload_handler_->RunUnloadListenersOrDestroy(tab_contents, index); GURL url = preview_contents->tab_contents()->GetURL(); DCHECK(profile_->GetExtensionService()); |