| 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_UI_VIEWS_INFOBARS_INFOBAR_CONTAINER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_CONTAINER_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_CONTAINER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_CONTAINER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "content/common/notification_observer.h" | 12 #include "content/common/notification_observer.h" |
| 13 #include "content/common/notification_registrar.h" | 13 #include "content/common/notification_registrar.h" |
| 14 | 14 |
| 15 class InfoBar; | 15 class InfoBar; |
| 16 class InfoBarDelegate; | 16 class InfoBarDelegate; |
| 17 class TabContents; | 17 class TabContents; |
| 18 | 18 |
| 19 // InfoBarContainer is a cross-platform base class to handle the visibility- | 19 // InfoBarContainer is a cross-platform base class to handle the visibility- |
| 20 // related aspects of InfoBars. While InfoBars own themselves, the | 20 // related aspects of InfoBars. While InfoBars own themselves, the |
| 21 // InfoBarContainer is responsible for telling particular InfoBars that they | 21 // InfoBarContainer is responsible for telling particular InfoBars that they |
| 22 // should be hidden or visible. | 22 // should be hidden or visible. |
| 23 // | 23 // |
| 24 // Platforms need to subclass this to implement a few platform-specific | 24 // Platforms need to subclass this to implement a few platform-specific |
| 25 // functions, which are pure virtual here. | 25 // functions, which are pure virtual here. |
| 26 class InfoBarContainer : public NotificationObserver { | 26 class InfoBarContainer : public NotificationObserver { |
| 27 public: | 27 public: |
| 28 // The delegate is notified each time InfoBarContainer::OnInfoBarAnimated() is | 28 // The delegate is notified each time the infobar container changes height. |
| 29 // called. | |
| 30 class Delegate { | 29 class Delegate { |
| 31 public: | 30 public: |
| 32 virtual void InfoBarContainerSizeChanged(bool is_animating) = 0; | 31 virtual void InfoBarContainerHeightChanged(bool is_animating) = 0; |
| 33 | 32 |
| 34 protected: | 33 protected: |
| 35 virtual ~Delegate(); | 34 virtual ~Delegate(); |
| 36 }; | 35 }; |
| 37 | 36 |
| 38 explicit InfoBarContainer(Delegate* delegate); | 37 explicit InfoBarContainer(Delegate* delegate); |
| 39 virtual ~InfoBarContainer(); | 38 virtual ~InfoBarContainer(); |
| 40 | 39 |
| 41 // Changes the TabContents for which this container is showing infobars. This | 40 // Changes the TabContents for which this container is showing infobars. This |
| 42 // will remove all current infobars from the container, add the infobars from | 41 // will remove all current infobars from the container, add the infobars from |
| 43 // |contents|, and show them all. |contents| may be NULL. | 42 // |contents|, and show them all. |contents| may be NULL. |
| 44 void ChangeTabContents(TabContents* contents); | 43 void ChangeTabContents(TabContents* contents); |
| 45 | 44 |
| 46 // Called when a contained infobar has animated. The container is expected to | 45 // Called when a contained infobar has animated or by some other means changed |
| 47 // do anything necessary to respond to the infobar's possible size change, | 46 // its height. The container is expected to do anything necessary to respond, |
| 48 // e.g. re-layout. | 47 // e.g. re-layout. |
| 49 void OnInfoBarAnimated(bool done); | 48 void OnInfoBarHeightChanged(bool is_animating); |
| 50 | 49 |
| 51 // Remove the specified InfoBarDelegate from the selected TabContents. This | 50 // Remove the specified InfoBarDelegate from the selected TabContents. This |
| 52 // will notify us back and cause us to close the InfoBar. This is called from | 51 // will notify us back and cause us to close the InfoBar. This is called from |
| 53 // the InfoBar's close button handler. | 52 // the InfoBar's close button handler. |
| 54 void RemoveDelegate(InfoBarDelegate* delegate); | 53 void RemoveDelegate(InfoBarDelegate* delegate); |
| 55 | 54 |
| 56 // Called by |infobar| to request that it be removed from the container, as it | 55 // Called by |infobar| to request that it be removed from the container, as it |
| 57 // is about to delete itself. At this point, |infobar| should already be | 56 // is about to delete itself. At this point, |infobar| should already be |
| 58 // hidden. | 57 // hidden. |
| 59 void RemoveInfoBar(InfoBar* infobar); | 58 void RemoveInfoBar(InfoBar* infobar); |
| 60 | 59 |
| 60 // Return the amount by which to overlap the toolbar above, so that the |
| 61 // InfoBars inside may draw anti-spoof arrows atop it. |
| 62 virtual int GetVerticalOverlap() = 0; |
| 63 |
| 61 protected: | 64 protected: |
| 62 // These must be implemented on each platform to e.g. adjust the visible | 65 // These must be implemented on each platform to e.g. adjust the visible |
| 63 // object hierarchy. | 66 // object hierarchy. |
| 64 virtual void PlatformSpecificAddInfoBar(InfoBar* infobar) = 0; | 67 virtual void PlatformSpecificAddInfoBar(InfoBar* infobar) = 0; |
| 65 virtual void PlatformSpecificRemoveInfoBar(InfoBar* infobar) = 0; | 68 virtual void PlatformSpecificRemoveInfoBar(InfoBar* infobar) = 0; |
| 66 | 69 |
| 67 private: | 70 private: |
| 68 typedef std::set<InfoBar*> InfoBars; | 71 typedef std::set<InfoBar*> InfoBars; |
| 69 | 72 |
| 70 // NotificationObserver: | 73 // NotificationObserver: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 89 | 92 |
| 90 NotificationRegistrar registrar_; | 93 NotificationRegistrar registrar_; |
| 91 Delegate* delegate_; | 94 Delegate* delegate_; |
| 92 TabContents* tab_contents_; | 95 TabContents* tab_contents_; |
| 93 InfoBars infobars_; | 96 InfoBars infobars_; |
| 94 | 97 |
| 95 DISALLOW_COPY_AND_ASSIGN(InfoBarContainer); | 98 DISALLOW_COPY_AND_ASSIGN(InfoBarContainer); |
| 96 }; | 99 }; |
| 97 | 100 |
| 98 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_CONTAINER_H_ | 101 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_CONTAINER_H_ |
| OLD | NEW |