| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/views/frame/instant_overlay_controller_views.h" |
| 6 |
| 7 #include "chrome/browser/instant/instant_model.h" |
| 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/view_ids.h" |
| 11 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 12 #include "chrome/browser/ui/views/frame/contents_container.h" |
| 13 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" |
| 14 #include "ui/views/controls/webview/webview.h" |
| 15 |
| 16 InstantOverlayControllerViews::InstantOverlayControllerViews( |
| 17 Browser* browser, |
| 18 ContentsContainer* contents) |
| 19 : InstantOverlayController(browser), |
| 20 contents_(contents) { |
| 21 } |
| 22 |
| 23 InstantOverlayControllerViews::~InstantOverlayControllerViews() { |
| 24 } |
| 25 |
| 26 void InstantOverlayControllerViews::OverlayStateChanged( |
| 27 const InstantModel& model) { |
| 28 if (model.overlay()) { |
| 29 // Show the overlay. |
| 30 if (!overlay_) { |
| 31 overlay_.reset(new views::WebView(browser_->profile())); |
| 32 overlay_->set_id(VIEW_ID_TAB_CONTAINER); |
| 33 } |
| 34 // Drop shadow is only needed if the overlay does not fill up the entire |
| 35 // contents page. |
| 36 bool draw_drop_shadow = !contents_->IsOverlayFullHeight( |
| 37 model.height(), model.is_height_in_pixels()); |
| 38 contents_->SetOverlay(overlay_.get(), model.overlay(), model.height(), |
| 39 model.is_height_in_pixels(), draw_drop_shadow); |
| 40 overlay_->SetWebContents(model.overlay()); |
| 41 browser_->MaybeUpdateBookmarkBarStateForInstantOverlay(); |
| 42 } else if (overlay_) { |
| 43 // Hide the overlay. SetWebContents() must happen before SetOverlay(). |
| 44 overlay_->SetWebContents(NULL); |
| 45 contents_->SetOverlay(NULL, NULL, 0, false, false); |
| 46 overlay_.reset(); |
| 47 } |
| 48 |
| 49 // If an Instant overlay is added during an immersive mode reveal, the reveal |
| 50 // view needs to stay on top. |
| 51 // Notify infobar container of change in overlay state. |
| 52 if (overlay_) { |
| 53 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); |
| 54 if (browser_view) { |
| 55 browser_view->MaybeStackImmersiveRevealAtTop(); |
| 56 browser_view->infobar_container()->OverlayStateChanged(model); |
| 57 } |
| 58 } |
| 59 } |
| OLD | NEW |