OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_INFOBARS_CORE_INFOBAR_MANAGER_H_ | 5 #ifndef COMPONENTS_INFOBARS_CORE_INFOBAR_MANAGER_H_ |
6 #define COMPONENTS_INFOBARS_CORE_INFOBAR_MANAGER_H_ | 6 #define COMPONENTS_INFOBARS_CORE_INFOBAR_MANAGER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "components/infobars/core/infobar_delegate.h" | 12 #include "components/infobars/core/infobar_delegate.h" |
13 | 13 |
| 14 class ConfirmInfoBarDelegate; |
| 15 |
14 namespace content { | 16 namespace content { |
15 class WebContents; | 17 class WebContents; |
16 } | 18 } |
17 | 19 |
18 namespace infobars { | 20 namespace infobars { |
19 | 21 |
20 class InfoBar; | 22 class InfoBar; |
21 | 23 |
22 // Provides access to creating, removing and enumerating info bars | 24 // Provides access to creating, removing and enumerating info bars |
23 // attached to a tab. | 25 // attached to a tab. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 89 |
88 // Must be called when a navigation happens. | 90 // Must be called when a navigation happens. |
89 void OnNavigation(const InfoBarDelegate::NavigationDetails& details); | 91 void OnNavigation(const InfoBarDelegate::NavigationDetails& details); |
90 | 92 |
91 void AddObserver(Observer* obs); | 93 void AddObserver(Observer* obs); |
92 void RemoveObserver(Observer* obs); | 94 void RemoveObserver(Observer* obs); |
93 | 95 |
94 // Returns the active entry ID. | 96 // Returns the active entry ID. |
95 virtual int GetActiveEntryID() = 0; | 97 virtual int GetActiveEntryID() = 0; |
96 | 98 |
| 99 // Returns a confirm infobar that owns |delegate|. |
| 100 virtual scoped_ptr<infobars::InfoBar> CreateConfirmInfoBar( |
| 101 scoped_ptr<ConfirmInfoBarDelegate> delegate) = 0; |
| 102 |
97 protected: | 103 protected: |
98 // Notifies the observer in |observer_list_|. | 104 // Notifies the observer in |observer_list_|. |
99 // TODO(droger): Absorb these methods back into their callers once virtual | 105 // TODO(droger): Absorb these methods back into their callers once virtual |
100 // overrides are removed (see http://crbug.com/354380). | 106 // overrides are removed (see http://crbug.com/354380). |
101 virtual void NotifyInfoBarAdded(InfoBar* infobar); | 107 virtual void NotifyInfoBarAdded(InfoBar* infobar); |
102 virtual void NotifyInfoBarRemoved(InfoBar* infobar, bool animate); | 108 virtual void NotifyInfoBarRemoved(InfoBar* infobar, bool animate); |
103 | 109 |
104 private: | 110 private: |
105 // InfoBars associated with this InfoBarManager. We own these pointers. | 111 // InfoBars associated with this InfoBarManager. We own these pointers. |
106 // However, this is not a ScopedVector, because we don't delete the infobars | 112 // However, this is not a ScopedVector, because we don't delete the infobars |
107 // directly once they've been added to this; instead, when we're done with an | 113 // directly once they've been added to this; instead, when we're done with an |
108 // infobar, we instruct it to delete itself and then orphan it. See | 114 // infobar, we instruct it to delete itself and then orphan it. See |
109 // RemoveInfoBarInternal(). | 115 // RemoveInfoBarInternal(). |
110 typedef std::vector<InfoBar*> InfoBars; | 116 typedef std::vector<InfoBar*> InfoBars; |
111 | 117 |
112 void RemoveInfoBarInternal(InfoBar* infobar, bool animate); | 118 void RemoveInfoBarInternal(InfoBar* infobar, bool animate); |
113 | 119 |
114 InfoBars infobars_; | 120 InfoBars infobars_; |
115 bool infobars_enabled_; | 121 bool infobars_enabled_; |
116 | 122 |
117 ObserverList<Observer, true> observer_list_; | 123 ObserverList<Observer, true> observer_list_; |
118 | 124 |
119 DISALLOW_COPY_AND_ASSIGN(InfoBarManager); | 125 DISALLOW_COPY_AND_ASSIGN(InfoBarManager); |
120 }; | 126 }; |
121 | 127 |
122 } // namespace infobars | 128 } // namespace infobars |
123 | 129 |
124 #endif // COMPONENTS_INFOBARS_CORE_INFOBAR_MANAGER_H_ | 130 #endif // COMPONENTS_INFOBARS_CORE_INFOBAR_MANAGER_H_ |
OLD | NEW |