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 CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_H_ |
6 #define CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_H_ | 6 #define CHROME_BROWSER_INFOBARS_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" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 class Observer { | 25 class Observer { |
26 public: | 26 public: |
27 virtual void OnInfoBarAdded(InfoBar* infobar) = 0; | 27 virtual void OnInfoBarAdded(InfoBar* infobar) = 0; |
28 virtual void OnInfoBarRemoved(InfoBar* infobar, bool animate) = 0; | 28 virtual void OnInfoBarRemoved(InfoBar* infobar, bool animate) = 0; |
29 virtual void OnInfoBarReplaced(InfoBar* old_infobar, | 29 virtual void OnInfoBarReplaced(InfoBar* old_infobar, |
30 InfoBar* new_infobar) = 0; | 30 InfoBar* new_infobar) = 0; |
31 virtual void OnManagerShuttingDown(InfoBarManager* manager) = 0; | 31 virtual void OnManagerShuttingDown(InfoBarManager* manager) = 0; |
32 }; | 32 }; |
33 | 33 |
34 explicit InfoBarManager(content::WebContents* web_contents); | 34 explicit InfoBarManager(content::WebContents* web_contents); |
35 ~InfoBarManager(); | 35 virtual ~InfoBarManager(); |
36 | |
37 // Must be called before destruction. | |
38 // TODO(droger): Merge this method with the destructor once the virtual calls | |
39 // for notifications are removed (see http://crbug.com/354380). | |
40 void ShutDown(); | |
36 | 41 |
37 // Adds the specified |infobar|, which already owns a delegate. | 42 // Adds the specified |infobar|, which already owns a delegate. |
38 // | 43 // |
39 // If infobars are disabled for this tab or the tab already has an infobar | 44 // If infobars are disabled for this tab or the tab already has an infobar |
40 // whose delegate returns true for | 45 // whose delegate returns true for |
41 // InfoBarDelegate::EqualsDelegate(infobar->delegate()), |infobar| is deleted | 46 // InfoBarDelegate::EqualsDelegate(infobar->delegate()), |infobar| is deleted |
42 // immediately without being added. | 47 // immediately without being added. |
43 // | 48 // |
44 // Returns the infobar if it was successfully added. | 49 // Returns the infobar if it was successfully added. |
45 virtual InfoBar* AddInfoBar(scoped_ptr<InfoBar> infobar); | 50 InfoBar* AddInfoBar(scoped_ptr<InfoBar> infobar); |
46 | 51 |
47 // Removes the specified |infobar|. This in turn may close immediately or | 52 // Removes the specified |infobar|. This in turn may close immediately or |
48 // animate closed; at the end the infobar will delete itself. | 53 // animate closed; at the end the infobar will delete itself. |
49 // | 54 // |
50 // If infobars are disabled for this tab, this will do nothing, on the | 55 // If infobars are disabled for this tab, this will do nothing, on the |
51 // assumption that the matching AddInfoBar() call will have already deleted | 56 // assumption that the matching AddInfoBar() call will have already deleted |
52 // the infobar (see above). | 57 // the infobar (see above). |
53 void RemoveInfoBar(InfoBar* infobar); | 58 void RemoveInfoBar(InfoBar* infobar); |
54 | 59 |
55 // Removes all the infobars. | 60 // Removes all the infobars. |
(...skipping 27 matching lines...) Expand all Loading... | |
83 | 88 |
84 // Must be called when a navigation happens. | 89 // Must be called when a navigation happens. |
85 void OnNavigation(const InfoBarDelegate::NavigationDetails& details); | 90 void OnNavigation(const InfoBarDelegate::NavigationDetails& details); |
86 | 91 |
87 // Called when the associated WebContents is being destroyed. | 92 // Called when the associated WebContents is being destroyed. |
88 void OnWebContentsDestroyed(); | 93 void OnWebContentsDestroyed(); |
89 | 94 |
90 void AddObserver(Observer* obs); | 95 void AddObserver(Observer* obs); |
91 void RemoveObserver(Observer* obs); | 96 void RemoveObserver(Observer* obs); |
92 | 97 |
98 protected: | |
99 // Notifies the observer in |observer_list_|. | |
blundell
2014/04/09 09:41:21
Reference the bug here as well.
| |
100 virtual void NotifyInfoBarAdded(InfoBar* infobar); | |
101 virtual void NotifyInfoBarRemoved(InfoBar* infobar, bool animate); | |
102 virtual void NotifyInfoBarReplaced(InfoBar* old_infobar, | |
103 InfoBar* new_infobar); | |
104 void NotifyManagerShuttingDown(); | |
105 | |
93 private: | 106 private: |
94 // InfoBars associated with this InfoBarManager. We own these pointers. | 107 // InfoBars associated with this InfoBarManager. We own these pointers. |
95 // However, this is not a ScopedVector, because we don't delete the infobars | 108 // However, this is not a ScopedVector, because we don't delete the infobars |
96 // directly once they've been added to this; instead, when we're done with an | 109 // directly once they've been added to this; instead, when we're done with an |
97 // infobar, we instruct it to delete itself and then orphan it. See | 110 // infobar, we instruct it to delete itself and then orphan it. See |
98 // RemoveInfoBarInternal(). | 111 // RemoveInfoBarInternal(). |
99 typedef std::vector<InfoBar*> InfoBars; | 112 typedef std::vector<InfoBar*> InfoBars; |
100 | 113 |
101 void RemoveInfoBarInternal(InfoBar* infobar, bool animate); | 114 void RemoveInfoBarInternal(InfoBar* infobar, bool animate); |
102 | 115 |
103 InfoBars infobars_; | 116 InfoBars infobars_; |
104 bool infobars_enabled_; | 117 bool infobars_enabled_; |
105 | 118 |
106 // TODO(droger): remove this field. See http://crbug.com/354379. | 119 // TODO(droger): remove this field. See http://crbug.com/354379. |
107 content::WebContents* web_contents_; | 120 content::WebContents* web_contents_; |
108 | 121 |
109 ObserverList<Observer, true> observer_list_; | 122 ObserverList<Observer, true> observer_list_; |
110 | 123 |
111 DISALLOW_COPY_AND_ASSIGN(InfoBarManager); | 124 DISALLOW_COPY_AND_ASSIGN(InfoBarManager); |
112 }; | 125 }; |
113 | 126 |
114 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_H_ | 127 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_H_ |
OLD | NEW |