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

Unified Diff: chrome/browser/ui/views/frame/instant_overlay_controller_views.cc

Issue 12386019: Instant: Use only one hidden WebContents per profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 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/views/frame/instant_overlay_controller_views.cc
diff --git a/chrome/browser/ui/views/frame/instant_overlay_controller_views.cc b/chrome/browser/ui/views/frame/instant_overlay_controller_views.cc
index ef8fdbbe479d84dc107a6eeef338cad1dbc910d0..6efe9ecfc3a29047e2f9316c9c9ef4a3c8ecfe7f 100644
--- a/chrome/browser/ui/views/frame/instant_overlay_controller_views.cc
+++ b/chrome/browser/ui/views/frame/instant_overlay_controller_views.cc
@@ -25,37 +25,38 @@ InstantOverlayControllerViews::~InstantOverlayControllerViews() {
void InstantOverlayControllerViews::OverlayStateChanged(
const InstantOverlayModel& model) {
- if (model.mode().is_ntp() || model.mode().is_search_suggestions()) {
- // Show the overlay.
- if (!overlay_) {
- overlay_.reset(new views::WebView(browser_->profile()));
- overlay_->set_id(VIEW_ID_TAB_CONTAINER);
- }
- // Drop shadow is only needed if search mode is not |NTP| and overlay does
- // not fill up the entire contents page.
- bool draw_drop_shadow = !model.mode().is_ntp() &&
- !(contents_->IsOverlayFullHeight(model.height(), model.height_units()));
- content::WebContents* web_contents = model.GetOverlayContents();
- contents_->SetOverlay(overlay_.get(), web_contents, model.height(),
- model.height_units(), draw_drop_shadow);
- overlay_->SetWebContents(web_contents);
- } else if (overlay_) {
+ if (!model.contents()) {
// Hide the overlay. SetWebContents() must happen before SetOverlay().
- overlay_->SetWebContents(NULL);
- contents_->SetOverlay(NULL, NULL, 100, INSTANT_SIZE_PERCENT, false);
- overlay_.reset();
+ if (overlay_) {
+ overlay_->SetWebContents(NULL);
+ contents_->SetOverlay(NULL, NULL, 0, INSTANT_SIZE_PIXELS, false);
+ overlay_.reset();
+ }
+ return;
+ }
+
+ // Show the overlay.
+ if (!overlay_) {
+ overlay_.reset(new views::WebView(browser_->profile()));
+ overlay_->set_id(VIEW_ID_TAB_CONTAINER);
}
- browser_->MaybeUpdateBookmarkBarStateForInstantOverlay(model.mode());
+ // Drop shadow is only needed if the overlay does not fill up the entire
+ // contents page.
+ bool draw_drop_shadow =
+ !contents_->IsOverlayFullHeight(model.height(), model.height_units());
+ contents_->SetOverlay(overlay_.get(), model.contents(), model.height(),
+ model.height_units(), draw_drop_shadow);
+ overlay_->SetWebContents(model.contents());
+
+ browser_->MaybeUpdateBookmarkBarStateForInstantOverlay();
// If an Instant overlay is added during an immersive mode reveal, the reveal
// view needs to stay on top.
// Notify infobar container of change in overlay state.
- if (overlay_) {
- BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
- if (browser_view) {
- browser_view->MaybeStackImmersiveRevealAtTop();
- browser_view->infobar_container()->OverlayStateChanged(model);
- }
+ BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
+ if (browser_view) {
+ browser_view->MaybeStackImmersiveRevealAtTop();
+ browser_view->infobar_container()->InstantOverlayShown();
}
}

Powered by Google App Engine
This is Rietveld 408576698