| 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 895303e846827f05b99fdefb40218eaf21fedeeb..d5df8bc1551535be706a2c82a2acec78ef2adc46 100644
|
| --- a/chrome/browser/ui/browser_instant_controller.cc
|
| +++ b/chrome/browser/ui/browser_instant_controller.cc
|
| @@ -41,7 +41,7 @@ BrowserInstantController::~BrowserInstantController() {
|
| }
|
|
|
| bool BrowserInstantController::OpenInstant(WindowOpenDisposition disposition) {
|
| - if (!instant() || !instant()->PrepareForCommit() ||
|
| + if (!instant() || !instant()->IsCurrent() ||
|
| disposition == NEW_BACKGROUND_TAB) {
|
| // NEW_BACKGROUND_TAB results in leaving the omnibox open, so we don't
|
| // attempt to use the instant preview.
|
| @@ -58,17 +58,13 @@ bool BrowserInstantController::OpenInstant(WindowOpenDisposition disposition) {
|
| }
|
| if (disposition == NEW_FOREGROUND_TAB) {
|
| TabContents* preview_contents = instant()->ReleasePreviewContents(
|
| - INSTANT_COMMIT_PRESSED_ENTER, NULL);
|
| - // HideInstant is invoked after release so that InstantController is not
|
| - // active when HideInstant asks it for its state.
|
| - HideInstant();
|
| + INSTANT_COMMIT_PRESSED_ENTER);
|
| preview_contents->web_contents()->GetController().PruneAllButActive();
|
| browser_->tab_strip_model()->AddTabContents(
|
| preview_contents,
|
| -1,
|
| - instant()->last_transition_type(),
|
| + content::PAGE_TRANSITION_GENERATED,
|
| TabStripModel::ADD_ACTIVE);
|
| - instant()->CompleteRelease(preview_contents);
|
| content::NotificationService::current()->Notify(
|
| chrome::NOTIFICATION_INSTANT_COMMITTED,
|
| content::Source<TabContents>(preview_contents),
|
| @@ -85,21 +81,22 @@ bool BrowserInstantController::OpenInstant(WindowOpenDisposition disposition) {
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // BrowserInstantController, InstantControllerDelegate implementation:
|
|
|
| -void BrowserInstantController::ShowInstant(TabContents* preview_contents) {
|
| +void BrowserInstantController::ShowInstant() {
|
| + TabContents* preview_contents = instant_->GetPreviewContents();
|
| browser_->window()->ShowInstant(preview_contents);
|
|
|
| - // TODO(beng): investigate if we can avoid this and instead rely on the
|
| - // visibility of the WebContentsView
|
| - chrome::GetActiveWebContents(browser_)->WasHidden();
|
| + content::NotificationService::current()->Notify(
|
| + chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN,
|
| + content::Source<InstantController>(instant_.get()),
|
| + content::NotificationService::NoDetails());
|
| +
|
| preview_contents->web_contents()->WasRestored();
|
| }
|
|
|
| void BrowserInstantController::HideInstant() {
|
| browser_->window()->HideInstant();
|
| - if (chrome::GetActiveWebContents(browser_))
|
| - chrome::GetActiveWebContents(browser_)->WasRestored();
|
| - if (instant_->GetPreviewContents())
|
| - instant_->GetPreviewContents()->web_contents()->WasHidden();
|
| + if (TabContents* preview_contents = instant_->GetPreviewContents())
|
| + preview_contents->web_contents()->WasHidden();
|
| }
|
|
|
| void BrowserInstantController::CommitInstant(TabContents* preview_contents) {
|
| @@ -154,7 +151,6 @@ void BrowserInstantController::Observe(
|
| if (browser_shutdown::ShuttingDownWithoutClosingBrowsers() ||
|
| !InstantController::IsEnabled(browser_->profile())) {
|
| if (instant()) {
|
| - instant()->DestroyPreviewContents();
|
| instant_.reset();
|
| instant_unload_handler_.reset();
|
| }
|
|
|