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" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // IMPORTANT: This MUST NOT result in a call back to | 88 // IMPORTANT: This MUST NOT result in a call back to |
89 // Delegate::InfoBarContainerStateChanged() unless it causes an actual | 89 // Delegate::InfoBarContainerStateChanged() unless it causes an actual |
90 // change, lest we infinitely recurse. | 90 // change, lest we infinitely recurse. |
91 void SetMaxTopArrowHeight(int height); | 91 void SetMaxTopArrowHeight(int height); |
92 | 92 |
93 // Called when a contained infobar has animated or by some other means changed | 93 // Called when a contained infobar has animated or by some other means changed |
94 // its height, or when it stops animating. The container is expected to do | 94 // its height, or when it stops animating. The container is expected to do |
95 // anything necessary to respond, e.g. re-layout. | 95 // anything necessary to respond, e.g. re-layout. |
96 void OnInfoBarStateChanged(bool is_animating); | 96 void OnInfoBarStateChanged(bool is_animating); |
97 | 97 |
98 // Called by |infobar| to request that it be removed from the container, as it | 98 // Called by |infobar| to request that it be removed from the container. At |
99 // is about to delete itself. At this point, |infobar| should already be | 99 // this point, |infobar| should already be hidden. Once the infobar is |
100 // hidden. | 100 // removed, it is guaranteed to delete itself and will not be re-added again. |
101 void RemoveInfoBar(InfoBar* infobar); | 101 void RemoveInfoBar(InfoBar* infobar); |
102 | 102 |
103 const Delegate* delegate() const { return delegate_; } | 103 const Delegate* delegate() const { return delegate_; } |
104 | 104 |
105 protected: | 105 protected: |
106 // Subclasses must call this during destruction, so that we can remove | 106 // Subclasses must call this during destruction, so that we can remove |
107 // infobars (which will call the pure virtual functions below) while the | 107 // infobars (which will call the pure virtual functions below) while the |
108 // subclass portion of |this| has not yet been destroyed. | 108 // subclass portion of |this| has not yet been destroyed. |
109 void RemoveAllInfoBarsForDestruction(); | 109 void RemoveAllInfoBarsForDestruction(); |
110 | 110 |
111 // These must be implemented on each platform to e.g. adjust the visible | 111 // These must be implemented on each platform to e.g. adjust the visible |
112 // object hierarchy. | 112 // object hierarchy. The first two functions should each be called exactly |
| 113 // once during an infobar's life (see comments on RemoveInfoBar() and |
| 114 // AddInfoBar()). |
113 virtual void PlatformSpecificAddInfoBar(InfoBar* infobar, | 115 virtual void PlatformSpecificAddInfoBar(InfoBar* infobar, |
114 size_t position) = 0; | 116 size_t position) = 0; |
115 virtual void PlatformSpecificRemoveInfoBar(InfoBar* infobar) = 0; | 117 virtual void PlatformSpecificRemoveInfoBar(InfoBar* infobar) = 0; |
116 virtual void PlatformSpecificInfoBarStateChanged(bool is_animating) {} | 118 virtual void PlatformSpecificInfoBarStateChanged(bool is_animating) {} |
117 | 119 |
118 private: | 120 private: |
119 typedef std::vector<InfoBar*> InfoBars; | 121 typedef std::vector<InfoBar*> InfoBars; |
120 | 122 |
121 // content::NotificationObserver: | 123 // content::NotificationObserver: |
122 virtual void Observe(int type, | 124 virtual void Observe(int type, |
(...skipping 14 matching lines...) Expand all Loading... |
137 size_t HideInfoBar(InfoBarDelegate* delegate, bool use_animation); | 139 size_t HideInfoBar(InfoBarDelegate* delegate, bool use_animation); |
138 | 140 |
139 // Hides all infobars in this container without animation. | 141 // Hides all infobars in this container without animation. |
140 void HideAllInfoBars(); | 142 void HideAllInfoBars(); |
141 | 143 |
142 // Adds |infobar| to this container before the existing infobar at position | 144 // Adds |infobar| to this container before the existing infobar at position |
143 // |position| and calls Show() on it. |animate| is passed along to | 145 // |position| and calls Show() on it. |animate| is passed along to |
144 // infobar->Show(). Depending on the value of |callback_status|, this calls | 146 // infobar->Show(). Depending on the value of |callback_status|, this calls |
145 // infobar->set_container(this) either before or after the call to Show() so | 147 // infobar->set_container(this) either before or after the call to Show() so |
146 // that OnInfoBarStateChanged() either will or won't be called as a result. | 148 // that OnInfoBarStateChanged() either will or won't be called as a result. |
| 149 // |
| 150 // This should be called only once for an infobar -- once it's added, it can |
| 151 // be repeatedly shown and hidden, but not removed and then re-added (see |
| 152 // comments on RemoveInfoBar()). |
147 enum CallbackStatus { NO_CALLBACK, WANT_CALLBACK }; | 153 enum CallbackStatus { NO_CALLBACK, WANT_CALLBACK }; |
148 void AddInfoBar(InfoBar* infobar, | 154 void AddInfoBar(InfoBar* infobar, |
149 size_t position, | 155 size_t position, |
150 bool animate, | 156 bool animate, |
151 CallbackStatus callback_status); | 157 CallbackStatus callback_status); |
152 | 158 |
153 void UpdateInfoBarArrowTargetHeights(); | 159 void UpdateInfoBarArrowTargetHeights(); |
154 int ArrowTargetHeightForInfoBar(size_t infobar_index) const; | 160 int ArrowTargetHeightForInfoBar(size_t infobar_index) const; |
155 | 161 |
156 content::NotificationRegistrar registrar_; | 162 content::NotificationRegistrar registrar_; |
(...skipping 12 matching lines...) Expand all Loading... |
169 // Extended. | 175 // Extended. |
170 SearchModel* search_model_; | 176 SearchModel* search_model_; |
171 | 177 |
172 // Calculated in SetMaxTopArrowHeight(). | 178 // Calculated in SetMaxTopArrowHeight(). |
173 int top_arrow_target_height_; | 179 int top_arrow_target_height_; |
174 | 180 |
175 DISALLOW_COPY_AND_ASSIGN(InfoBarContainer); | 181 DISALLOW_COPY_AND_ASSIGN(InfoBarContainer); |
176 }; | 182 }; |
177 | 183 |
178 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_ | 184 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_ |
OLD | NEW |