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

Unified Diff: chrome/browser/ui/browser.cc

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 build break 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
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_instant_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser.cc
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index c34edf92392ed71e6144ff97c031499bb4a70b9f..d16ac65ffe20c0df067bda5351f1139d5965be49 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -1225,20 +1225,6 @@ void Browser::ShowFirstRunBubble() {
window()->GetLocationBar()->ShowFirstRunBubble();
}
-void Browser::MaybeUpdateBookmarkBarStateForInstantOverlay(
- const chrome::search::Mode& mode) {
- // This is invoked by a platform-specific implementation of
- // |InstantOverlayController| to update bookmark bar state according to
- // Instant overlay state.
- // ModeChanged() updates bookmark bar state for all mode transitions except
- // when new mode is |SEARCH_SUGGESTIONS|, because that needs to be done when
- // the suggestions are ready.
- if (mode.is_search_suggestions() &&
- bookmark_bar_state_ == BookmarkBar::SHOW) {
- UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
- }
-}
-
void Browser::ShowDownload(content::DownloadItem* download) {
if (!window())
return;
@@ -1814,22 +1800,13 @@ void Browser::Observe(int type,
}
}
-void Browser::ModeChanged(const chrome::search::Mode& old_mode,
- const chrome::search::Mode& new_mode) {
- // If new mode is |SEARCH_SUGGESTIONS|, don't update bookmark bar state now;
- // wait till the Instant overlay is ready to show suggestions before hiding
- // the bookmark bar (in MaybeUpdateBookmarkBarStateForInstantOverlay()).
- // TODO(kuan): but for now, only delay updating bookmark bar state if origin
- // is |DEFAULT|; other origins require more complex logic to be implemented
- // to prevent jankiness caused by hiding bookmark bar, so just hide the
- // bookmark bar immediately and tolerate the jankiness for a while.
- // For other mode transitions, update bookmark bar state accordingly.
- if (new_mode.is_search_suggestions() &&
- new_mode.is_origin_default() &&
- bookmark_bar_state_ == BookmarkBar::SHOW) {
- return;
+void Browser::ModelChanged(
+ const chrome::search::SearchModel::State& old_state,
+ const chrome::search::SearchModel::State& new_state) {
+ if (chrome::search::SearchModel::ShouldChangeTopBarsVisibility(old_state,
+ new_state)) {
+ UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
}
- UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
}
///////////////////////////////////////////////////////////////////////////////
@@ -2139,16 +2116,22 @@ void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) {
state = BookmarkBar::HIDDEN;
}
- // Don't allow the bookmark bar to be shown in suggestions mode.
+ // Bookmark bar may need to be hidden for |SEARCH_SUGGESTIONS| and
+ // |SEARCH_RESULTS| modes as per SearchBox API or Instant overlay or if it's
+ // detached.
+ // TODO(sail): remove conditional MACOSX flag when bookmark bar is actually
+ // hidden on mac; for now, mac keeps the bookmark bar shown but changes its
+ // z-order to stack it below contents.
#if !defined(OS_MACOSX)
- if (search_model_->mode().is_search_suggestions())
+ if (search_model_->mode().is_search() &&
+ (state == BookmarkBar::DETACHED || !search_model_->top_bars_visible())) {
state = BookmarkBar::HIDDEN;
-#endif
-
- // Don't allow detached bookmark bar to be shown in suggestions or results
- // modes.
+ }
+#else
+ // TODO(sail): remove this when the above block is enabled for mac.
if (state == BookmarkBar::DETACHED && search_model_->mode().is_search())
state = BookmarkBar::HIDDEN;
+#endif // !defined(OS_MACOSX)
if (state == bookmark_bar_state_)
return;
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_instant_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698