Chromium Code Reviews| 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..a987301d15d95d13ae58e917574bf1415383732b 100644 |
| --- a/chrome/browser/infobars/infobar_container.cc |
| +++ b/chrome/browser/infobars/infobar_container.cc |
| @@ -176,32 +176,56 @@ void InfoBarContainer::Observe(int type, |
| void InfoBarContainer::ModeChanged(const chrome::search::Mode& old_mode, |
| const chrome::search::Mode& new_mode) { |
|
Peter Kasting
2013/03/08 00:51:36
I'm not terribly thrilled by having three differen
dhollowa
2013/03/08 01:14:19
+1
Kuan, I think we may be able to collapse these
kuan
2013/03/12 18:00:38
i've consolidated all 3 notifications into 1: Mode
kuan
2013/03/12 18:00:38
i've consolidated all 3 different functions into j
|
| - // 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 { |
| + // If new mode is |SEARCH_SUGGESTIONS| or |SEARCH_RESULTS|, don't update |
| + // infobars' states now: |
| + // - for |DEFAULT| page, wait for instant overlay to show or hide, via |
| + // OverlayStateChanged(). |
| + // - for |NTP| and |SERP| pages, wait for SearchBox API callback via |
| + // TopBarsVisibilityChanged(). |
| + // For other mode transitions, show infobars now. |
| + if (new_mode.is_search()) |
| + return; |
| + if (!infobars_shown_) { |
| ChangeInfoBarService(infobar_service_); |
| infobars_shown_time_ = base::TimeTicks::Now(); |
| } |
| } |
| -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()) { |
| +void InfoBarContainer::TopBarsVisibilityChanged( |
| + const chrome::search::Mode& mode, |
| + bool visible) { |
| + // Only handle non-|DEFAULT| pages in |SEARCH_SUGGESTIONS| or |SEARCH_RESULTS| |
| + // modes for this callback. |
| + if (!mode.is_search() || mode.is_origin_default()) |
| + return; |
| + if (visible && !infobars_shown_) { |
| + ChangeInfoBarService(infobar_service_); |
| + infobars_shown_time_ = base::TimeTicks::Now(); |
| + } else if (!visible && infobars_shown_) { |
| HideAllInfoBars(); |
| OnInfoBarStateChanged(false); |
| } |
| } |
| +void InfoBarContainer::OverlayStateChanged(const InstantOverlayModel& model) { |
| + // This is invoked by a platform-specific implementation of |
| + // |InstantOverlayController| to update infobars' states according to instant |
| + // overlay state. Only handle |DEFAULT| pages for this callback. |
| + if (!model.mode().is_origin_default()) |
| + return; |
| + if (model.mode().is_search_suggestions()) { |
| + // Hide infobars if they're shown. |
| + if (infobars_shown_) { |
| + HideAllInfoBars(); |
| + OnInfoBarStateChanged(false); |
| + } |
| + } else if (!infobars_shown_) { |
| + // Show hidden infobars. |
| + ChangeInfoBarService(infobar_service_); |
| + infobars_shown_time_ = base::TimeTicks::Now(); |
| + } |
| +} |
| + |
| size_t InfoBarContainer::HideInfoBar(InfoBarDelegate* delegate, |
| bool use_animation) { |
| bool should_animate = use_animation && |