| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_ | 5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_ |
| 6 #define CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_ | 6 #define CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "chrome/browser/ui/search/instant_overlay_model_observer.h" | |
| 13 #include "chrome/browser/ui/search/search_model_observer.h" | 12 #include "chrome/browser/ui/search/search_model_observer.h" |
| 14 #include "chrome/common/search_types.h" | 13 #include "chrome/common/search_types.h" |
| 15 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 17 #include "third_party/skia/include/core/SkColor.h" | 16 #include "third_party/skia/include/core/SkColor.h" |
| 18 | 17 |
| 19 class InfoBar; | 18 class InfoBar; |
| 20 class InfoBarDelegate; | 19 class InfoBarDelegate; |
| 21 class InfoBarService; | 20 class InfoBarService; |
| 22 | 21 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 43 // TODO(kuan): this scenario requires more complex synchronization with | 42 // TODO(kuan): this scenario requires more complex synchronization with |
| 44 // renderer SearchBoxAPI and will be implemented as the next step; | 43 // renderer SearchBoxAPI and will be implemented as the next step; |
| 45 // for now, hiding is immediate. | 44 // for now, hiding is immediate. |
| 46 // When the user changes back out of |SEARCH_SUGGESTIONS| mode, it reshows any | 45 // When the user changes back out of |SEARCH_SUGGESTIONS| mode, it reshows any |
| 47 // infobars, and starts a 50 ms window during which any attempts to re-hide any | 46 // infobars, and starts a 50 ms window during which any attempts to re-hide any |
| 48 // infobars are handled without animation. This prevents glitchy-looking | 47 // infobars are handled without animation. This prevents glitchy-looking |
| 49 // behavior when the user navigates following a mode change, which otherwise | 48 // behavior when the user navigates following a mode change, which otherwise |
| 50 // would re-show the infobars only to instantly animate them closed. The window | 49 // would re-show the infobars only to instantly animate them closed. The window |
| 51 // to re-hide infobars without animation is canceled if a tab change occurs. | 50 // to re-hide infobars without animation is canceled if a tab change occurs. |
| 52 class InfoBarContainer : public content::NotificationObserver, | 51 class InfoBarContainer : public content::NotificationObserver, |
| 53 public chrome::search::SearchModelObserver, | 52 public chrome::search::SearchModelObserver { |
| 54 public InstantOverlayModelObserver { | |
| 55 public: | 53 public: |
| 56 class Delegate { | 54 class Delegate { |
| 57 public: | 55 public: |
| 58 // The separator color may vary depending on where the container is hosted. | 56 // The separator color may vary depending on where the container is hosted. |
| 59 virtual SkColor GetInfoBarSeparatorColor() const = 0; | 57 virtual SkColor GetInfoBarSeparatorColor() const = 0; |
| 60 | 58 |
| 61 // The delegate is notified each time the infobar container changes height, | 59 // The delegate is notified each time the infobar container changes height, |
| 62 // as well as when it stops animating. | 60 // as well as when it stops animating. |
| 63 virtual void InfoBarContainerStateChanged(bool is_animating) = 0; | 61 virtual void InfoBarContainerStateChanged(bool is_animating) = 0; |
| 64 | 62 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // anything necessary to respond, e.g. re-layout. | 101 // anything necessary to respond, e.g. re-layout. |
| 104 void OnInfoBarStateChanged(bool is_animating); | 102 void OnInfoBarStateChanged(bool is_animating); |
| 105 | 103 |
| 106 // Called by |infobar| to request that it be removed from the container, as it | 104 // Called by |infobar| to request that it be removed from the container, as it |
| 107 // is about to delete itself. At this point, |infobar| should already be | 105 // is about to delete itself. At this point, |infobar| should already be |
| 108 // hidden. | 106 // hidden. |
| 109 void RemoveInfoBar(InfoBar* infobar); | 107 void RemoveInfoBar(InfoBar* infobar); |
| 110 | 108 |
| 111 const Delegate* delegate() const { return delegate_; } | 109 const Delegate* delegate() const { return delegate_; } |
| 112 | 110 |
| 113 // InstantOverlayModelObserver: | |
| 114 virtual void OverlayStateChanged(const InstantOverlayModel& model) OVERRIDE; | |
| 115 | |
| 116 protected: | 111 protected: |
| 117 // Subclasses must call this during destruction, so that we can remove | 112 // Subclasses must call this during destruction, so that we can remove |
| 118 // infobars (which will call the pure virtual functions below) while the | 113 // infobars (which will call the pure virtual functions below) while the |
| 119 // subclass portion of |this| has not yet been destroyed. | 114 // subclass portion of |this| has not yet been destroyed. |
| 120 void RemoveAllInfoBarsForDestruction(); | 115 void RemoveAllInfoBarsForDestruction(); |
| 121 | 116 |
| 122 // These must be implemented on each platform to e.g. adjust the visible | 117 // These must be implemented on each platform to e.g. adjust the visible |
| 123 // object hierarchy. | 118 // object hierarchy. |
| 124 virtual void PlatformSpecificAddInfoBar(InfoBar* infobar, | 119 virtual void PlatformSpecificAddInfoBar(InfoBar* infobar, |
| 125 size_t position) = 0; | 120 size_t position) = 0; |
| 126 virtual void PlatformSpecificRemoveInfoBar(InfoBar* infobar) = 0; | 121 virtual void PlatformSpecificRemoveInfoBar(InfoBar* infobar) = 0; |
| 127 virtual void PlatformSpecificInfoBarStateChanged(bool is_animating) {} | 122 virtual void PlatformSpecificInfoBarStateChanged(bool is_animating) {} |
| 128 | 123 |
| 129 private: | 124 private: |
| 130 typedef std::vector<InfoBar*> InfoBars; | 125 typedef std::vector<InfoBar*> InfoBars; |
| 131 | 126 |
| 132 // content::NotificationObserver: | 127 // content::NotificationObserver: |
| 133 virtual void Observe(int type, | 128 virtual void Observe(int type, |
| 134 const content::NotificationSource& source, | 129 const content::NotificationSource& source, |
| 135 const content::NotificationDetails& details) OVERRIDE; | 130 const content::NotificationDetails& details) OVERRIDE; |
| 136 | 131 |
| 137 // chrome::search::SearchModelObserver: | 132 // chrome::search::SearchModelObserver: |
| 138 virtual void ModeChanged(const chrome::search::Mode& old_mode, | 133 virtual void ModelChanged( |
| 139 const chrome::search::Mode& new_mode) OVERRIDE; | 134 const chrome::search::SearchModel::State& old_state, |
| 135 const chrome::search::SearchModel::State& new_state) OVERRIDE; |
| 140 | 136 |
| 141 // Hides an InfoBar for the specified delegate, in response to a notification | 137 // Hides an InfoBar for the specified delegate, in response to a notification |
| 142 // from the selected InfoBarService. The InfoBar's disappearance will be | 138 // from the selected InfoBarService. The InfoBar's disappearance will be |
| 143 // animated if |use_animation| is true and it has been more than 50ms since | 139 // animated if |use_animation| is true and it has been more than 50ms since |
| 144 // infobars were reshown due to an Instant Extended mode change. The InfoBar | 140 // infobars were reshown due to an Instant Extended mode change. The InfoBar |
| 145 // will call back to RemoveInfoBar() to remove itself once it's hidden (which | 141 // will call back to RemoveInfoBar() to remove itself once it's hidden (which |
| 146 // may mean synchronously). Returns the position within |infobars_| the | 142 // may mean synchronously). Returns the position within |infobars_| the |
| 147 // infobar was previously at. | 143 // infobar was previously at. |
| 148 size_t HideInfoBar(InfoBarDelegate* delegate, bool use_animation); | 144 size_t HideInfoBar(InfoBarDelegate* delegate, bool use_animation); |
| 149 | 145 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 180 // Extended. | 176 // Extended. |
| 181 chrome::search::SearchModel* search_model_; | 177 chrome::search::SearchModel* search_model_; |
| 182 | 178 |
| 183 // Calculated in SetMaxTopArrowHeight(). | 179 // Calculated in SetMaxTopArrowHeight(). |
| 184 int top_arrow_target_height_; | 180 int top_arrow_target_height_; |
| 185 | 181 |
| 186 DISALLOW_COPY_AND_ASSIGN(InfoBarContainer); | 182 DISALLOW_COPY_AND_ASSIGN(InfoBarContainer); |
| 187 }; | 183 }; |
| 188 | 184 |
| 189 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_ | 185 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_ |
| OLD | NEW |