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

Side by Side Diff: chrome/browser/ui/cocoa/tab_contents/instant_overlay_controller_mac.mm

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

Powered by Google App Engine
This is Rietveld 408576698