Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1431)

Side by Side Diff: chrome/browser/infobars/infobar_manager.h

Issue 228293004: InfoBarService inherits from InfoBarManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a ShutDown method Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 void ShutDown();
droger 2014/04/08 15:00:11 This method is needed as there are virtual calls d
Peter Kasting 2014/04/08 20:39:56 I'd add a comment to that effect.
36 39
37 // Adds the specified |infobar|, which already owns a delegate. 40 // Adds the specified |infobar|, which already owns a delegate.
38 // 41 //
39 // If infobars are disabled for this tab or the tab already has an infobar 42 // If infobars are disabled for this tab or the tab already has an infobar
40 // whose delegate returns true for 43 // whose delegate returns true for
41 // InfoBarDelegate::EqualsDelegate(infobar->delegate()), |infobar| is deleted 44 // InfoBarDelegate::EqualsDelegate(infobar->delegate()), |infobar| is deleted
42 // immediately without being added. 45 // immediately without being added.
43 // 46 //
44 // Returns the infobar if it was successfully added. 47 // Returns the infobar if it was successfully added.
45 virtual InfoBar* AddInfoBar(scoped_ptr<InfoBar> infobar); 48 InfoBar* AddInfoBar(scoped_ptr<InfoBar> infobar);
46 49
47 // Removes the specified |infobar|. This in turn may close immediately or 50 // Removes the specified |infobar|. This in turn may close immediately or
48 // animate closed; at the end the infobar will delete itself. 51 // animate closed; at the end the infobar will delete itself.
49 // 52 //
50 // If infobars are disabled for this tab, this will do nothing, on the 53 // If infobars are disabled for this tab, this will do nothing, on the
51 // assumption that the matching AddInfoBar() call will have already deleted 54 // assumption that the matching AddInfoBar() call will have already deleted
52 // the infobar (see above). 55 // the infobar (see above).
53 void RemoveInfoBar(InfoBar* infobar); 56 void RemoveInfoBar(InfoBar* infobar);
54 57
55 // Removes all the infobars. 58 // Removes all the infobars.
(...skipping 16 matching lines...) Expand all
72 75
73 // Returns the infobar at the given |index|. The InfoBarManager retains 76 // Returns the infobar at the given |index|. The InfoBarManager retains
74 // ownership. 77 // ownership.
75 // 78 //
76 // Warning: Does not sanity check |index|. 79 // Warning: Does not sanity check |index|.
77 InfoBar* infobar_at(size_t index) { return infobars_[index]; } 80 InfoBar* infobar_at(size_t index) { return infobars_[index]; }
78 81
79 // Retrieve the WebContents for the tab this service is associated with. 82 // Retrieve the WebContents for the tab this service is associated with.
80 // Do not add new call sites for this. 83 // Do not add new call sites for this.
81 // TODO(droger): remove this method. See http://crbug.com/354379. 84 // TODO(droger): remove this method. See http://crbug.com/354379.
82 content::WebContents* web_contents() { return web_contents_; } 85 content::WebContents* web_contents() { return web_contents_; }
Peter Kasting 2014/04/08 20:39:56 Can this method (and member) be removed too?
droger 2014/04/08 20:54:46 I'd prefer doing it in another CL if you don't mi
83 86
84 // Must be called when a navigation happens. 87 // Must be called when a navigation happens.
85 void OnNavigation(const InfoBarDelegate::NavigationDetails& details); 88 void OnNavigation(const InfoBarDelegate::NavigationDetails& details);
86 89
87 // Called when the associated WebContents is being destroyed. 90 // Called when the associated WebContents is being destroyed.
88 void OnWebContentsDestroyed(); 91 void OnWebContentsDestroyed();
89 92
90 void AddObserver(Observer* obs); 93 void AddObserver(Observer* obs);
91 void RemoveObserver(Observer* obs); 94 void RemoveObserver(Observer* obs);
92 95
96 protected:
97 // Notifies the observer in |observer_list_|.
98 virtual void NotifyInfoBarAdded(InfoBar* infobar);
99 virtual void NotifyInfoBarRemoved(InfoBar* infobar, bool animate);
100 virtual void NotifyInfoBarReplaced(InfoBar* old_infobar,
101 InfoBar* new_infobar);
102 void NotifyManagerShuttingDown();
103
93 private: 104 private:
94 // InfoBars associated with this InfoBarManager. We own these pointers. 105 // InfoBars associated with this InfoBarManager. We own these pointers.
95 // However, this is not a ScopedVector, because we don't delete the infobars 106 // 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 107 // 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 108 // infobar, we instruct it to delete itself and then orphan it. See
98 // RemoveInfoBarInternal(). 109 // RemoveInfoBarInternal().
99 typedef std::vector<InfoBar*> InfoBars; 110 typedef std::vector<InfoBar*> InfoBars;
100 111
101 void RemoveInfoBarInternal(InfoBar* infobar, bool animate); 112 void RemoveInfoBarInternal(InfoBar* infobar, bool animate);
102 113
103 InfoBars infobars_; 114 InfoBars infobars_;
104 bool infobars_enabled_; 115 bool infobars_enabled_;
116 bool did_shut_down_;
105 117
106 // TODO(droger): remove this field. See http://crbug.com/354379. 118 // TODO(droger): remove this field. See http://crbug.com/354379.
107 content::WebContents* web_contents_; 119 content::WebContents* web_contents_;
108 120
109 ObserverList<Observer, true> observer_list_; 121 ObserverList<Observer, true> observer_list_;
110 122
111 DISALLOW_COPY_AND_ASSIGN(InfoBarManager); 123 DISALLOW_COPY_AND_ASSIGN(InfoBarManager);
112 }; 124 };
113 125
114 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_H_ 126 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698