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

Side by Side Diff: chrome/browser/ui/browser_instant_controller.cc

Issue 10959049: Change visibility semantics for Instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Enable a test Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/browser_instant_controller.h" 5 #include "chrome/browser/ui/browser_instant_controller.h"
6 6
7 #include "chrome/browser/browser_shutdown.h" 7 #include "chrome/browser/browser_shutdown.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/instant/instant_controller.h" 9 #include "chrome/browser/instant/instant_controller.h"
10 #include "chrome/browser/instant/instant_unload_handler.h" 10 #include "chrome/browser/instant/instant_unload_handler.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // to handle them. If you hit this NOTREACHED file a bug and I'll (sky) add 71 // to handle them. If you hit this NOTREACHED file a bug and I'll (sky) add
72 // support for the new disposition. 72 // support for the new disposition.
73 NOTREACHED(); 73 NOTREACHED();
74 return false; 74 return false;
75 } 75 }
76 76
77 //////////////////////////////////////////////////////////////////////////////// 77 ////////////////////////////////////////////////////////////////////////////////
78 // BrowserInstantController, InstantControllerDelegate implementation: 78 // BrowserInstantController, InstantControllerDelegate implementation:
79 79
80 void BrowserInstantController::ShowInstant(int height, InstantSizeUnits units) { 80 void BrowserInstantController::ShowInstant(int height, InstantSizeUnits units) {
81 // Call ShowInstant() first, before WasShown(), so that the preview is added 81 browser_->window()->ShowInstant(instant_->GetPreviewContents(),
82 // to the window hierarchy before it's painted. http://crbug.com/145568 82 height, units);
83 TabContents* preview = instant_->GetPreviewContents();
84 browser_->window()->ShowInstant(preview, height, units);
85
86 // TODO(beng): Investigate if we can avoid this and instead rely on the
87 // visibility of the WebContentsView.
88 preview->web_contents()->WasShown();
89 chrome::GetActiveWebContents(browser_)->WasHidden();
90 } 83 }
91 84
92 void BrowserInstantController::HideInstant() { 85 void BrowserInstantController::HideInstant() {
93 browser_->window()->HideInstant(); 86 browser_->window()->HideInstant();
94
95 if (chrome::GetActiveWebContents(browser_))
96 chrome::GetActiveWebContents(browser_)->WasShown();
97 if (TabContents* preview = instant_->GetPreviewContents())
98 preview->web_contents()->WasHidden();
99 } 87 }
100 88
101 void BrowserInstantController::CommitInstant(TabContents* preview) { 89 void BrowserInstantController::CommitInstant(TabContents* preview) {
102 TabContents* active_tab = chrome::GetActiveTabContents(browser_); 90 TabContents* active_tab = chrome::GetActiveTabContents(browser_);
103 int index = browser_->tab_strip_model()->GetIndexOfTabContents(active_tab); 91 int index = browser_->tab_strip_model()->GetIndexOfTabContents(active_tab);
104 DCHECK_NE(TabStripModel::kNoTab, index); 92 DCHECK_NE(TabStripModel::kNoTab, index);
105 // TabStripModel takes ownership of |preview|. 93 // TabStripModel takes ownership of |preview|.
106 browser_->tab_strip_model()->ReplaceTabContentsAt(index, preview); 94 browser_->tab_strip_model()->ReplaceTabContentsAt(index, preview);
107 // InstantUnloadHandler takes ownership of |active_tab|. 95 // InstantUnloadHandler takes ownership of |active_tab|.
108 instant_unload_handler_->RunUnloadListenersOrDestroy(active_tab, index); 96 instant_unload_handler_->RunUnloadListenersOrDestroy(active_tab, index);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 void BrowserInstantController::ResetInstant() { 151 void BrowserInstantController::ResetInstant() {
164 instant_.reset( 152 instant_.reset(
165 !browser_shutdown::ShuttingDownWithoutClosingBrowsers() && 153 !browser_shutdown::ShuttingDownWithoutClosingBrowsers() &&
166 browser_->is_type_tabbed() ? 154 browser_->is_type_tabbed() ?
167 InstantController::CreateInstant(browser_->profile(), this) : NULL); 155 InstantController::CreateInstant(browser_->profile(), this) : NULL);
168 instant_unload_handler_.reset(instant() ? 156 instant_unload_handler_.reset(instant() ?
169 new InstantUnloadHandler(browser_) : NULL); 157 new InstantUnloadHandler(browser_) : NULL);
170 } 158 }
171 159
172 } // namespace chrome 160 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_controller.cc ('k') | chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698