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

Unified Diff: chrome/browser/infobars/infobar_service.h

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/infobars/infobar_delegate.cc ('k') | chrome/browser/infobars/infobar_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/infobars/infobar_service.h
===================================================================
--- chrome/browser/infobars/infobar_service.h (revision 238220)
+++ chrome/browser/infobars/infobar_service.h (working copy)
@@ -11,7 +11,7 @@
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
-class InfoBarDelegate;
+class InfoBar;
// Provides access to creating, removing and enumerating info bars
// attached to a tab.
@@ -21,32 +21,35 @@
// Changes whether infobars are enabled. The default is true.
void set_infobars_enabled(bool enabled) { infobars_enabled_ = enabled; }
- // Adds an InfoBar for the specified |delegate|.
+ // Adds the specified |infobar|, which already owns a delegate.
//
- // If infobars are disabled for this tab or the tab already has a delegate
- // which returns true for InfoBarDelegate::EqualsDelegate(delegate),
- // |delegate| is closed immediately without being added.
+ // If infobars are disabled for this tab or the tab already has an infobar
+ // whose delegate returns true for
+ // InfoBarDelegate::EqualsDelegate(infobar->delegate()), |infobar| is deleted
+ // immediately without being added.
//
- // Returns the delegate if it was successfully added.
- InfoBarDelegate* AddInfoBar(scoped_ptr<InfoBarDelegate> infobar);
+ // Returns the infobar if it was successfully added.
+ virtual InfoBar* AddInfoBar(scoped_ptr<InfoBar> infobar);
- // Removes the InfoBar for the specified |delegate|.
+ // Removes the specified |infobar|. This in turn may close immediately or
+ // animate closed; at the end the infobar will delete itself.
//
// If infobars are disabled for this tab, this will do nothing, on the
- // assumption that the matching AddInfoBar() call will have already closed the
- // delegate (see above).
- void RemoveInfoBar(InfoBarDelegate* infobar);
+ // assumption that the matching AddInfoBar() call will have already deleted
+ // the infobar (see above).
+ void RemoveInfoBar(InfoBar* infobar);
- // Replaces one infobar with another, without any animation in between.
+ // Replaces one infobar with another, without any animation in between. This
+ // will result in |old_infobar| being synchronously deleted.
//
- // If infobars are disabled for this tab, |new_delegate| is closed immediately
+ // If infobars are disabled for this tab, |new_infobar| is deleted immediately
// without being added, and nothing else happens.
//
- // Returns the new delegate if it was successfully added.
+ // Returns the new infobar if it was successfully added.
//
// NOTE: This does not perform any EqualsDelegate() checks like AddInfoBar().
- InfoBarDelegate* ReplaceInfoBar(InfoBarDelegate* old_infobar,
- scoped_ptr<InfoBarDelegate> new_infobar);
+ InfoBar* ReplaceInfoBar(InfoBar* old_infobar,
+ scoped_ptr<InfoBar> new_infobar);
// Returns the number of infobars for this tab.
size_t infobar_count() const { return infobars_.size(); }
@@ -55,7 +58,7 @@
// ownership.
//
// Warning: Does not sanity check |index|.
- InfoBarDelegate* infobar_at(size_t index) { return infobars_[index]; }
+ InfoBar* infobar_at(size_t index) { return infobars_[index]; }
// Retrieve the WebContents for the tab this service is associated with.
content::WebContents* web_contents() {
@@ -65,12 +68,13 @@
private:
friend class content::WebContentsUserData<InfoBarService>;
- typedef std::vector<InfoBarDelegate*> InfoBars;
+ // InfoBars associated with this InfoBarService. We own these pointers.
+ // However, this is not a ScopedVector, because we don't delete the infobars
+ // directly once they've been added to this; instead, when we're done with an
+ // infobar, we instruct it to delete itself and then orphan it. See
+ // RemoveInfoBarInternal().
+ typedef std::vector<InfoBar*> InfoBars;
- // Delegates for InfoBars associated with this InfoBarService. We do not own
- // these pointers; they own themselves and are deleted in response to being
- // closed.
- // TODO(pkasting): These leak if closed while not visible.
explicit InfoBarService(content::WebContents* web_contents);
virtual ~InfoBarService();
@@ -82,7 +86,7 @@
content::WebContents* web_contents) OVERRIDE;
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
- void RemoveInfoBarInternal(InfoBarDelegate* infobar, bool animate);
+ void RemoveInfoBarInternal(InfoBar* infobar, bool animate);
void RemoveAllInfoBars(bool animate);
// Message handlers.
« no previous file with comments | « chrome/browser/infobars/infobar_delegate.cc ('k') | chrome/browser/infobars/infobar_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698