Index: trunk/src/chrome/browser/infobars/infobar_delegate.h |
=================================================================== |
--- trunk/src/chrome/browser/infobars/infobar_delegate.h (revision 238401) |
+++ trunk/src/chrome/browser/infobars/infobar_delegate.h (working copy) |
@@ -51,12 +51,19 @@ |
// Value to use when the InfoBar has no icon to show. |
static const int kNoIconID; |
- // Called when the InfoBar that owns this delegate is being destroyed. At |
- // this point nothing is visible onscreen. |
virtual ~InfoBarDelegate(); |
virtual InfoBarAutomationType GetInfoBarAutomationType() const; |
+ // Called to create the InfoBar. Implementation of this method is |
+ // platform-specific. |
+ virtual InfoBar* CreateInfoBar(InfoBarService* owner) = 0; |
+ |
+ // TODO(pkasting): Move to InfoBar once InfoBars own their delegates. |
+ InfoBarService* owner() { return owner_; } |
+ |
+ void clear_owner() { owner_ = NULL; } |
+ |
// Returns true if the supplied |delegate| is equal to this one. Equality is |
// left to the implementation to define. This function is called by the |
// InfoBarService when determining whether or not a delegate should be |
@@ -97,38 +104,41 @@ |
virtual ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate(); |
virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); |
- void set_infobar(InfoBar* infobar) { infobar_ = infobar; } |
+ // Return the icon to be shown for this InfoBar. If the returned Image is |
+ // empty, no icon is shown. |
+ virtual gfx::Image GetIcon() const; |
+ content::WebContents* web_contents() { |
+ return owner_ ? owner_->web_contents() : NULL; |
+ } |
+ |
+ protected: |
+ // If |contents| is non-NULL, its active entry's unique ID will be stored |
+ // using StoreActiveEntryUniqueID automatically. |
+ explicit InfoBarDelegate(InfoBarService* owner); |
+ |
// Store the unique id for the active entry in our WebContents, to be used |
// later upon navigation to determine if this InfoBarDelegate should be |
// expired. |
void StoreActiveEntryUniqueID(); |
- // Return the icon to be shown for this InfoBar. If the returned Image is |
- // empty, no icon is shown. |
- virtual gfx::Image GetIcon() const; |
+ int contents_unique_id() const { return contents_unique_id_; } |
- // This trivial getter is defined out-of-line in order to avoid needing to |
- // #include infobar.h, which would lead to circular #includes. |
- content::WebContents* web_contents(); |
- |
- protected: |
- InfoBarDelegate(); |
- |
// Returns true if the navigation is to a new URL or a reload occured. |
virtual bool ShouldExpireInternal( |
const content::LoadCommittedDetails& details) const; |
- int contents_unique_id() const { return contents_unique_id_; } |
- InfoBar* infobar() { return infobar_; } |
+ // Removes ourself from |owner_| if we haven't already been removed. |
+ // TODO(pkasting): Move to InfoBar. |
+ void RemoveSelf(); |
private: |
// The unique id of the active NavigationEntry of the WebContents that we were |
// opened for. Used to help expire on navigations. |
int contents_unique_id_; |
- // The InfoBar associated with us. |
- InfoBar* infobar_; |
+ // TODO(pkasting): Remove. |
+ InfoBarService* owner_; |
DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); |
}; |