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

Unified Diff: chrome/browser/infobars/infobar_container.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 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/infobars/infobar_container.cc
diff --git a/chrome/browser/infobars/infobar_container.cc b/chrome/browser/infobars/infobar_container.cc
index b601744e09fac3f45aca280186dab6b1d419ac9d..b0fa3d41f844d4709c3e179dcdbcca695e32efbf 100644
--- a/chrome/browser/infobars/infobar_container.cc
+++ b/chrome/browser/infobars/infobar_container.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/api/infobars/infobar_service.h"
#include "chrome/browser/infobars/infobar.h"
#include "chrome/browser/instant/instant_overlay_model.h"
+#include "chrome/browser/instant/search.h"
#include "chrome/browser/ui/search/search_model.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/notification_details.h"
@@ -73,6 +74,10 @@ void InfoBarContainer::ChangeInfoBarService(InfoBarService* infobar_service) {
infobar_service_),
i, false, NO_CALLBACK);
}
+
+ // Hide infobars if search model requires so.
Peter Kasting 2013/03/15 05:32:01 Don't do this. Instead, make this function begin
kuan 2013/03/15 15:53:49 Done.
kuan 2013/03/15 16:32:17 i moved HideAllInfoBars() to start of function. c
+ if (!search_model_->top_bars_visible())
+ HideAllInfoBars();
}
// Now that everything is up to date, signal the delegate to re-layout.
@@ -174,29 +179,18 @@ void InfoBarContainer::Observe(int type,
}
}
-void InfoBarContainer::ModeChanged(const chrome::search::Mode& old_mode,
- const chrome::search::Mode& new_mode) {
- // Hide infobars when showing Instant Extended suggestions.
- if (new_mode.is_search_suggestions()) {
- // If suggestions are being shown on a |DEFAULT| page, delay the hiding
- // until notification that Instant overlay is ready is received via
- // OverlayStateChanged(); this prevents jankiness caused by infobars hiding
- // followed by suggestions appearing.
- if (new_mode.is_origin_default())
- return;
- HideAllInfoBars();
- OnInfoBarStateChanged(false);
- } else {
- ChangeInfoBarService(infobar_service_);
- infobars_shown_time_ = base::TimeTicks::Now();
+void InfoBarContainer::ModelChanged(
+ const chrome::search::SearchModel::State& old_state,
+ const chrome::search::SearchModel::State& new_state) {
+ if (!chrome::search::SearchModel::ShouldChangeTopBarsVisibility(old_state,
+ new_state)) {
Peter Kasting 2013/03/15 05:32:01 Nit: No {}
kuan 2013/03/15 15:53:49 Done.
+ return;
}
-}
-void InfoBarContainer::OverlayStateChanged(const InstantOverlayModel& model) {
- // If suggestions are being shown on a |DEFAULT| page, hide the infobars now.
- // See comments for ModeChanged() for explanation.
- if (model.mode().is_search_suggestions() &&
- model.mode().is_origin_default()) {
+ if (new_state.top_bars_visible && !infobars_shown_) {
+ ChangeInfoBarService(infobar_service_);
+ infobars_shown_time_ = base::TimeTicks::Now();
+ } else if (!new_state.top_bars_visible && infobars_shown_) {
HideAllInfoBars();
OnInfoBarStateChanged(false);
}

Powered by Google App Engine
This is Rietveld 408576698