| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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/cocoa/tab_contents/instant_overlay_controller_mac.h" |
| 6 |
| 7 #include "chrome/browser/search/search.h" |
| 5 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 6 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 7 #include "chrome/browser/ui/cocoa/tab_contents/instant_overlay_controller_mac.h" | 10 #include "chrome/browser/ui/cocoa/tab_contents/instant_overlay_controller_mac.h" |
| 8 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" | 11 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" |
| 9 #include "chrome/browser/ui/search/instant_overlay_model.h" | 12 #include "chrome/browser/ui/search/instant_overlay_model.h" |
| 13 #include "chrome/browser/ui/search/search_model.h" |
| 14 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 10 | 16 |
| 11 InstantOverlayControllerMac::InstantOverlayControllerMac( | 17 InstantOverlayControllerMac::InstantOverlayControllerMac( |
| 12 Browser* browser, | 18 Browser* browser, |
| 13 BrowserWindowController* window, | 19 BrowserWindowController* window, |
| 14 OverlayableContentsController* overlay) | 20 OverlayableContentsController* overlay) |
| 15 : InstantOverlayController(browser), | 21 : InstantOverlayController(browser), |
| 16 window_(window), | 22 window_(window), |
| 17 overlay_(overlay) { | 23 overlay_(overlay) { |
| 18 } | 24 } |
| 19 | 25 |
| 20 InstantOverlayControllerMac::~InstantOverlayControllerMac() { | 26 InstantOverlayControllerMac::~InstantOverlayControllerMac() { |
| 21 } | 27 } |
| 22 | 28 |
| 23 void InstantOverlayControllerMac::OverlayStateChanged( | 29 void InstantOverlayControllerMac::OverlayStateChanged( |
| 24 const InstantOverlayModel& model) { | 30 const InstantOverlayModel& model) { |
| 31 // TODO(sail): migrate from InstantOverlayControllerViews::OverlayStateChanged |
| 32 // to only call SetTopBarsVisible if we did something with overlay; this |
| 33 // prevents the top bars from flashing in this transition |
| 34 // DEFAULT->SUGGESTIONS->SERP. |
| 35 bool has_overlay = false; |
| 25 if (model.mode().is_ntp() || model.mode().is_search_suggestions()) { | 36 if (model.mode().is_ntp() || model.mode().is_search_suggestions()) { |
| 26 // Drop shadow is only needed if search mode is not |NTP| and overlay does | 37 // Drop shadow is only needed if search mode is not |NTP| and overlay does |
| 27 // not fill up the entire contents page. | 38 // not fill up the entire contents page. |
| 28 BOOL drawDropShadow = !model.mode().is_ntp() && | 39 BOOL drawDropShadow = !model.mode().is_ntp() && |
| 29 !(model.height() == 100 && | 40 !(model.height() == 100 && |
| 30 model.height_units() == INSTANT_SIZE_PERCENT); | 41 model.height_units() == INSTANT_SIZE_PERCENT); |
| 31 [overlay_ setOverlay:model.GetOverlayContents() | 42 [overlay_ setOverlay:model.GetOverlayContents() |
| 32 height:model.height() | 43 height:model.height() |
| 33 heightUnits:model.height_units() | 44 heightUnits:model.height_units() |
| 34 drawDropShadow:drawDropShadow]; | 45 drawDropShadow:drawDropShadow]; |
| 46 has_overlay = true; |
| 35 } else { | 47 } else { |
| 36 [overlay_ setOverlay:NULL | 48 [overlay_ setOverlay:NULL |
| 37 height:0 | 49 height:0 |
| 38 heightUnits:INSTANT_SIZE_PIXELS | 50 heightUnits:INSTANT_SIZE_PIXELS |
| 39 drawDropShadow:NO]; | 51 drawDropShadow:NO]; |
| 40 } | 52 } |
| 41 browser_->MaybeUpdateBookmarkBarStateForInstantOverlay(model.mode()); | 53 |
| 54 if (chrome::search::IsInstantExtendedAPIEnabled()) { |
| 55 // Set top bars (bookmark and info bars) visibility for current tab via |
| 56 // |SearchTabHelper| of current active web contents: top bars are hidden if |
| 57 // there's overlay. |
| 58 chrome::search::SearchTabHelper* search_tab_helper = |
| 59 chrome::search::SearchTabHelper::FromWebContents( |
| 60 browser_->tab_strip_model()->GetActiveWebContents()); |
| 61 if (search_tab_helper) |
| 62 search_tab_helper->model()->SetTopBarsVisible(!has_overlay); |
| 63 } |
| 64 |
| 42 [window_ updateBookmarkBarStateForInstantOverlay]; | 65 [window_ updateBookmarkBarStateForInstantOverlay]; |
| 43 } | 66 } |
| OLD | NEW |