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

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

Issue 102163002: Revert 238283 "Infobar system refactor." (Closed) Base URL: svn://svn.chromium.org/chrome/
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
Index: trunk/src/chrome/browser/infobars/infobar_service.h
===================================================================
--- trunk/src/chrome/browser/infobars/infobar_service.h (revision 238401)
+++ trunk/src/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 InfoBar;
+class InfoBarDelegate;
// Provides access to creating, removing and enumerating info bars
// attached to a tab.
@@ -21,35 +21,32 @@
// Changes whether infobars are enabled. The default is true.
void set_infobars_enabled(bool enabled) { infobars_enabled_ = enabled; }
- // Adds the specified |infobar|, which already owns a delegate.
+ // Adds an InfoBar for the specified |delegate|.
//
- // 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.
+ // 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.
//
- // Returns the infobar if it was successfully added.
- virtual InfoBar* AddInfoBar(scoped_ptr<InfoBar> infobar);
+ // Returns the delegate if it was successfully added.
+ InfoBarDelegate* AddInfoBar(scoped_ptr<InfoBarDelegate> infobar);
- // Removes the specified |infobar|. This in turn may close immediately or
- // animate closed; at the end the infobar will delete itself.
+ // Removes the InfoBar for the specified |delegate|.
//
// If infobars are disabled for this tab, this will do nothing, on the
- // assumption that the matching AddInfoBar() call will have already deleted
- // the infobar (see above).
- void RemoveInfoBar(InfoBar* infobar);
+ // assumption that the matching AddInfoBar() call will have already closed the
+ // delegate (see above).
+ void RemoveInfoBar(InfoBarDelegate* infobar);
- // Replaces one infobar with another, without any animation in between. This
- // will result in |old_infobar| being synchronously deleted.
+ // Replaces one infobar with another, without any animation in between.
//
- // If infobars are disabled for this tab, |new_infobar| is deleted immediately
+ // If infobars are disabled for this tab, |new_delegate| is closed immediately
// without being added, and nothing else happens.
//
- // Returns the new infobar if it was successfully added.
+ // Returns the new delegate if it was successfully added.
//
// NOTE: This does not perform any EqualsDelegate() checks like AddInfoBar().
- InfoBar* ReplaceInfoBar(InfoBar* old_infobar,
- scoped_ptr<InfoBar> new_infobar);
+ InfoBarDelegate* ReplaceInfoBar(InfoBarDelegate* old_infobar,
+ scoped_ptr<InfoBarDelegate> new_infobar);
// Returns the number of infobars for this tab.
size_t infobar_count() const { return infobars_.size(); }
@@ -58,7 +55,7 @@
// ownership.
//
// Warning: Does not sanity check |index|.
- InfoBar* infobar_at(size_t index) { return infobars_[index]; }
+ InfoBarDelegate* infobar_at(size_t index) { return infobars_[index]; }
// Retrieve the WebContents for the tab this service is associated with.
content::WebContents* web_contents() {
@@ -68,13 +65,12 @@
private:
friend class content::WebContentsUserData<InfoBarService>;
- // 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;
+ typedef std::vector<InfoBarDelegate*> 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();
@@ -86,7 +82,7 @@
content::WebContents* web_contents) OVERRIDE;
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
- void RemoveInfoBarInternal(InfoBar* infobar, bool animate);
+ void RemoveInfoBarInternal(InfoBarDelegate* infobar, bool animate);
void RemoveAllInfoBars(bool animate);
// Message handlers.
« no previous file with comments | « trunk/src/chrome/browser/infobars/infobar_delegate.cc ('k') | trunk/src/chrome/browser/infobars/infobar_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698