Chromium Code Reviews| 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 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 // The delegate is notified each time InfoBarContainer::OnInfoBarAnimated() is | 27 // The delegate is notified each time InfoBarContainer::OnInfoBarAnimated() is |
| 28 // called. | 28 // called. |
| 29 class Delegate { | 29 class Delegate { |
| 30 public: | 30 public: |
| 31 virtual void InfoBarContainerSizeChanged(bool is_animating) = 0; | 31 virtual void InfoBarContainerSizeChanged(bool is_animating) = 0; |
| 32 | 32 |
| 33 protected: | 33 protected: |
| 34 virtual ~Delegate(); | 34 virtual ~Delegate(); |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 class Heights { | |
|
Peter Kasting
2011/03/04 22:23:42
I think it would be clearer to write the InfoBarCo
Sheridan Rawlins
2011/03/05 18:06:54
The reason for the class was that the layout code
| |
| 38 public: | |
| 39 Heights(int tab_height, int bar_height) | |
| 40 : tab_height_(tab_height), | |
| 41 bar_height_(bar_height) {} | |
| 42 | |
| 43 int tab_height() const { return tab_height_; } | |
| 44 int bar_height() const { return bar_height_; } | |
| 45 int height() const { return tab_height_ + bar_height_; } | |
| 46 | |
| 47 private: | |
| 48 friend class InfoBarContainer; | |
| 49 | |
| 50 int tab_height_; | |
| 51 int bar_height_; | |
| 52 }; | |
| 53 | |
| 37 explicit InfoBarContainer(Delegate* delegate); | 54 explicit InfoBarContainer(Delegate* delegate); |
| 38 virtual ~InfoBarContainer(); | 55 virtual ~InfoBarContainer(); |
| 39 | 56 |
| 57 // Return the tab and bar heights for this infobar container. | |
| 58 Heights GetHeights() const; | |
| 59 | |
| 40 // Changes the TabContents for which this container is showing infobars. This | 60 // Changes the TabContents for which this container is showing infobars. This |
| 41 // will remove all current infobars from the container, add the infobars from | 61 // will remove all current infobars from the container, add the infobars from |
| 42 // |contents|, and show them all. |contents| may be NULL. | 62 // |contents|, and show them all. |contents| may be NULL. |
| 43 void ChangeTabContents(TabContents* contents); | 63 void ChangeTabContents(TabContents* contents); |
| 44 | 64 |
| 45 // Called when a contained infobar has animated. The container is expected to | 65 // Called when a contained infobar has animated. The container is expected to |
| 46 // do anything necessary to respond to the infobar's possible size change, | 66 // do anything necessary to respond to the infobar's possible size change, |
| 47 // e.g. re-layout. | 67 // e.g. re-layout. |
| 48 void OnInfoBarAnimated(bool done); | 68 void OnInfoBarAnimated(bool done); |
| 49 | 69 |
| 50 // Remove the specified InfoBarDelegate from the selected TabContents. This | 70 // Remove the specified InfoBarDelegate from the selected TabContents. This |
| 51 // will notify us back and cause us to close the InfoBar. This is called from | 71 // will notify us back and cause us to close the InfoBar. This is called from |
| 52 // the InfoBar's close button handler. | 72 // the InfoBar's close button handler. |
| 53 void RemoveDelegate(InfoBarDelegate* delegate); | 73 void RemoveDelegate(InfoBarDelegate* delegate); |
| 54 | 74 |
| 55 // Called by |infobar| to request that it be removed from the container, as it | 75 // Called by |infobar| to request that it be removed from the container, as it |
| 56 // is about to delete itself. At this point, |infobar| should already be | 76 // is about to delete itself. At this point, |infobar| should already be |
| 57 // hidden. | 77 // hidden. |
| 58 void RemoveInfoBar(InfoBarView* infobar); | 78 void RemoveInfoBar(InfoBarView* infobar); |
| 59 | 79 |
| 60 // Paint the InfoBar arrows on |canvas|. |arrow_center_x| indicates | |
| 61 // the desired location of the center of the arrow in the | |
| 62 // |outer_view| coordinate system. | |
| 63 void PaintInfoBarArrows(gfx::Canvas* canvas, | |
| 64 View* outer_view, | |
| 65 int arrow_center_x); | |
| 66 | |
| 67 private: | 80 private: |
| 68 typedef std::set<InfoBarView*> InfoBars; | 81 typedef std::set<InfoBarView*> InfoBars; |
| 69 | 82 |
| 70 // AccessiblePaneView: | 83 // AccessiblePaneView: |
| 71 virtual gfx::Size GetPreferredSize() OVERRIDE; | 84 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 72 virtual void Layout() OVERRIDE; | 85 virtual void Layout() OVERRIDE; |
| 73 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 86 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 74 | 87 |
| 75 // NotificationObserver: | 88 // NotificationObserver: |
| 76 virtual void Observe(NotificationType type, | 89 virtual void Observe(NotificationType type, |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 94 | 107 |
| 95 NotificationRegistrar registrar_; | 108 NotificationRegistrar registrar_; |
| 96 Delegate* delegate_; | 109 Delegate* delegate_; |
| 97 TabContents* tab_contents_; | 110 TabContents* tab_contents_; |
| 98 InfoBars infobars_; | 111 InfoBars infobars_; |
| 99 | 112 |
| 100 DISALLOW_COPY_AND_ASSIGN(InfoBarContainer); | 113 DISALLOW_COPY_AND_ASSIGN(InfoBarContainer); |
| 101 }; | 114 }; |
| 102 | 115 |
| 103 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_CONTAINER_H_ | 116 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_CONTAINER_H_ |
| OLD | NEW |