Index: chrome/browser/infobars/infobar_container.h |
diff --git a/chrome/browser/infobars/infobar_container.h b/chrome/browser/infobars/infobar_container.h |
index 508bf76dd23826c5d8ecda213526b6d07069a2ea..d0f3439b0835251e49b81bd57e3d6485b95debbe 100644 |
--- a/chrome/browser/infobars/infobar_container.h |
+++ b/chrome/browser/infobars/infobar_container.h |
@@ -9,6 +9,7 @@ |
#include "base/compiler_specific.h" |
#include "base/time.h" |
+#include "chrome/browser/instant/instant_model_observer.h" |
#include "chrome/browser/ui/search/search_model_observer.h" |
#include "chrome/common/search_types.h" |
#include "content/public/browser/notification_observer.h" |
@@ -18,6 +19,7 @@ |
class InfoBar; |
class InfoBarDelegate; |
class InfoBarService; |
+class InstantModel; |
namespace chrome { |
namespace search { |
@@ -33,16 +35,25 @@ class SearchModel; |
// Platforms need to subclass this to implement a few platform-specific |
// functions, which are pure virtual here. |
// |
-// This class also observes changes to the SearchModel mode. If the user changes |
-// into suggestions mode, it hides all the infobars temporarily. When the user |
-// changes back out of suggestions mode, it reshows any infobars, and starts a |
-// 50 ms window during which any attempts to re-hide any infobars are handled |
-// without animation. This prevents glitchy-looking behavior when the user |
-// navigates following a mode change, which otherwise would re-show the infobars |
-// only to instantly animate them closed. The window is canceled if a tab |
-// change occurs. |
+// This class also observes changes to the SearchModel and InstantModel modes. |
+// It hides infobars temporarily if the user changes into |SEARCH_SUGGESTIONS| |
+// mode (refer to chrome::search::Mode in chrome/common/search_types.h for all |
+// search modes) when: |
+// - on a page that is not |NTP| or |SEARCH_RESULTS|: when instant preview is |
+// ready; |
+// - on a page that is |NTP| or |SEARCH_RESULTS|: immediately; |
+// TODO(kuan): this scenario requires more complex synchronization with |
+// renderer SearchBoxAPI and will be implemented as the next step; |
+// for now, hiding is immediate. |
+// When the user changes back out of |SEARCH_SUGGESTIONS| mode, it reshows any |
+// infobars, and starts a 50 ms window during which any attempts to re-hide any |
+// infobars are handled without animation. This prevents glitchy-looking |
+// behavior when the user navigates following a mode change, which otherwise |
+// would re-show the infobars only to instantly animate them closed. The window |
+// to re-hide infobars without animation is canceled if a tab change occurs. |
class InfoBarContainer : public content::NotificationObserver, |
- public chrome::search::SearchModelObserver { |
+ public chrome::search::SearchModelObserver, |
+ public InstantModelObserver { |
public: |
class Delegate { |
public: |
@@ -61,10 +72,11 @@ class InfoBarContainer : public content::NotificationObserver, |
virtual ~Delegate(); |
}; |
- // |search_model| may be NULL if this class is used in a window that does not |
- // support Instant Extended. |
+ // |search_model| and |instant_model| may be NULL if this class is used in a |
+ // window that does not support Instant Extended. |
InfoBarContainer(Delegate* delegate, |
- chrome::search::SearchModel* search_model); |
+ chrome::search::SearchModel* search_model, |
+ const InstantModel* instant_model); |
virtual ~InfoBarContainer(); |
// Changes the InfoBarService for which this container is showing |
@@ -126,6 +138,9 @@ class InfoBarContainer : public content::NotificationObserver, |
virtual void ModeChanged(const chrome::search::Mode& old_mode, |
const chrome::search::Mode& new_mode) OVERRIDE; |
+ // InstantModelObserver: |
+ virtual void PreviewStateChanged(const InstantModel& model) OVERRIDE; |
+ |
// Hides an InfoBar for the specified delegate, in response to a notification |
// from the selected InfoBarService. The InfoBar's disappearance will be |
// animated if |use_animation| is true and it has been more than 50ms since |
@@ -165,6 +180,9 @@ class InfoBarContainer : public content::NotificationObserver, |
// Extended. |
chrome::search::SearchModel* search_model_; |
+ // Tracks state of instant preview for Instant Extended. |
+ const InstantModel* instant_model_; // Weak. |
+ |
// Calculated in SetMaxTopArrowHeight(). |
int top_arrow_target_height_; |