| 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_TAB_CONTENTS_INFOBAR_CONTAINER_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_INFOBAR_CONTAINER_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_INFOBAR_CONTAINER_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_INFOBAR_CONTAINER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 const Delegate* delegate() const { return delegate_; } | 85 const Delegate* delegate() const { return delegate_; } |
| 86 | 86 |
| 87 protected: | 87 protected: |
| 88 // Subclasses must call this during destruction, so that we can remove | 88 // Subclasses must call this during destruction, so that we can remove |
| 89 // infobars (which will call the pure virtual functions below) while the | 89 // infobars (which will call the pure virtual functions below) while the |
| 90 // subclass portion of |this| has not yet been destroyed. | 90 // subclass portion of |this| has not yet been destroyed. |
| 91 void RemoveAllInfoBarsForDestruction(); | 91 void RemoveAllInfoBarsForDestruction(); |
| 92 | 92 |
| 93 // These must be implemented on each platform to e.g. adjust the visible | 93 // These must be implemented on each platform to e.g. adjust the visible |
| 94 // object hierarchy. | 94 // object hierarchy. |
| 95 virtual void PlatformSpecificAddInfoBar(InfoBar* infobar) = 0; | 95 virtual void PlatformSpecificAddInfoBar(InfoBar* infobar, |
| 96 size_t position) = 0; |
| 96 virtual void PlatformSpecificRemoveInfoBar(InfoBar* infobar) = 0; | 97 virtual void PlatformSpecificRemoveInfoBar(InfoBar* infobar) = 0; |
| 97 | 98 |
| 98 private: | 99 private: |
| 99 typedef std::vector<InfoBar*> InfoBars; | 100 typedef std::vector<InfoBar*> InfoBars; |
| 100 | 101 |
| 101 // NotificationObserver: | 102 // NotificationObserver: |
| 102 virtual void Observe(NotificationType type, | 103 virtual void Observe(NotificationType type, |
| 103 const NotificationSource& source, | 104 const NotificationSource& source, |
| 104 const NotificationDetails& details) OVERRIDE; | 105 const NotificationDetails& details) OVERRIDE; |
| 105 | 106 |
| 106 // Removes an InfoBar for the specified delegate, in response to a | 107 // Removes an InfoBar for the specified delegate, in response to a |
| 107 // notification from the selected TabContentsWrapper. The InfoBar's | 108 // notification from the selected TabContentsWrapper. The InfoBar's |
| 108 // disappearance will be animated if |use_animation| is true. | 109 // disappearance will be animated if |use_animation| is true. Returns the |
| 109 void RemoveInfoBar(InfoBarDelegate* delegate, bool use_animation); | 110 // position within |infobars_| the infobar was previously at. |
| 111 size_t RemoveInfoBar(InfoBarDelegate* delegate, bool use_animation); |
| 110 | 112 |
| 111 // Adds |infobar| to this container and calls Show() on it. |animate| is | 113 // Adds |infobar| to this container before the existing infobar at position |
| 112 // passed along to infobar->Show(). Depending on the value of | 114 // |position| and calls Show() on it. |animate| is passed along to |
| 113 // |callback_status|, this calls infobar->set_container(this) either before or | 115 // infobar->Show(). Depending on the value of |callback_status|, this calls |
| 114 // after the call to Show() so that OnInfoBarAnimated() either will or won't | 116 // infobar->set_container(this) either before or after the call to Show() so |
| 115 // be called as a result. | 117 // that OnInfoBarStateChanged() either will or won't be called as a result. |
| 116 enum CallbackStatus { NO_CALLBACK, WANT_CALLBACK }; | 118 enum CallbackStatus { NO_CALLBACK, WANT_CALLBACK }; |
| 117 void AddInfoBar(InfoBar* infobar, | 119 void AddInfoBar(InfoBar* infobar, |
| 120 size_t position, |
| 118 bool animate, | 121 bool animate, |
| 119 CallbackStatus callback_status); | 122 CallbackStatus callback_status); |
| 120 | 123 |
| 121 void UpdateInfoBarArrowTargetHeights(); | 124 void UpdateInfoBarArrowTargetHeights(); |
| 122 int ArrowTargetHeightForInfoBar(size_t infobar_index) const; | 125 int ArrowTargetHeightForInfoBar(size_t infobar_index) const; |
| 123 | 126 |
| 124 NotificationRegistrar registrar_; | 127 NotificationRegistrar registrar_; |
| 125 Delegate* delegate_; | 128 Delegate* delegate_; |
| 126 TabContentsWrapper* tab_contents_; | 129 TabContentsWrapper* tab_contents_; |
| 127 InfoBars infobars_; | 130 InfoBars infobars_; |
| 128 | 131 |
| 129 // Calculated in SetMaxTopArrowHeight(). | 132 // Calculated in SetMaxTopArrowHeight(). |
| 130 int top_arrow_target_height_; | 133 int top_arrow_target_height_; |
| 131 | 134 |
| 132 DISALLOW_COPY_AND_ASSIGN(InfoBarContainer); | 135 DISALLOW_COPY_AND_ASSIGN(InfoBarContainer); |
| 133 }; | 136 }; |
| 134 | 137 |
| 135 #endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_CONTAINER_H_ | 138 #endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_CONTAINER_H_ |
| OLD | NEW |