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 a25202563ee06c2918cbd4893d273a07bb040e7d..eaf00cc36efdc50c4df68dde1fc5ddee9c18101f 100644 |
| --- a/chrome/browser/infobars/infobar_container.cc |
| +++ b/chrome/browser/infobars/infobar_container.cc |
| @@ -15,6 +15,7 @@ |
| #include "chrome/browser/api/infobars/infobar_delegate.h" |
| #include "chrome/browser/api/infobars/infobar_service.h" |
| #include "chrome/browser/infobars/infobar.h" |
| +#include "chrome/browser/instant/instant_model.h" |
| #include "chrome/browser/ui/search/search_model.h" |
| #include "chrome/common/chrome_notification_types.h" |
| #include "content/public/browser/notification_details.h" |
| @@ -26,13 +27,17 @@ InfoBarContainer::Delegate::~Delegate() { |
| InfoBarContainer::InfoBarContainer( |
| Delegate* delegate, |
| - chrome::search::SearchModel* search_model) |
| + chrome::search::SearchModel* search_model, |
| + const InstantModel* instant_model) |
| : delegate_(delegate), |
| infobar_service_(NULL), |
| search_model_(search_model), |
| + instant_model_(instant_model), |
| top_arrow_target_height_(InfoBar::kDefaultArrowTargetHeight) { |
| if (search_model_) |
| search_model_->AddObserver(this); |
| + if (instant_model_) |
| + instant_model_->AddObserver(this); |
|
Peter Kasting
2013/01/28 21:51:00
Please pass in a non-const pointer if you're going
kuan
2013/01/29 00:17:08
i was forced to use const InstantModel 'cos Instan
|
| } |
| InfoBarContainer::~InfoBarContainer() { |
| @@ -40,6 +45,8 @@ InfoBarContainer::~InfoBarContainer() { |
| DCHECK(infobars_.empty()); |
| if (search_model_) |
| search_model_->RemoveObserver(this); |
| + if (instant_model_) |
| + instant_model_->RemoveObserver(this); |
| } |
| void InfoBarContainer::ChangeInfoBarService(InfoBarService* infobar_service) { |
| @@ -164,6 +171,11 @@ 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 preview is ready is received via |
| + // PreviewStateChanged(). |
|
Peter Kasting
2013/01/28 21:51:00
Nit: Add commentary on why you do this (i.e. what
kuan
2013/01/29 00:17:08
Done.
|
| + if (new_mode.is_origin_default()) |
| + return; |
| HideAllInfoBars(); |
| OnInfoBarStateChanged(false); |
| } else { |
| @@ -172,6 +184,16 @@ void InfoBarContainer::ModeChanged(const chrome::search::Mode& old_mode, |
| } |
| } |
| +void InfoBarContainer::PreviewStateChanged(const InstantModel& 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()) { |
| + HideAllInfoBars(); |
| + OnInfoBarStateChanged(false); |
| + } |
| +} |
| + |
| size_t InfoBarContainer::HideInfoBar(InfoBarDelegate* delegate, |
| bool use_animation) { |
| bool should_animate = use_animation && |