Index: chrome/browser/tab_contents/infobar_delegate.h |
=================================================================== |
--- chrome/browser/tab_contents/infobar_delegate.h (revision 72158) |
+++ chrome/browser/tab_contents/infobar_delegate.h (working copy) |
@@ -15,11 +15,11 @@ |
class ConfirmInfoBarDelegate; |
class CrashedExtensionInfoBarDelegate; |
class ExtensionInfoBarDelegate; |
-class TranslateInfoBarDelegate; |
class InfoBar; |
class LinkInfoBarDelegate; |
class SkBitmap; |
class ThemeInstalledInfoBarDelegate; |
+class TranslateInfoBarDelegate; |
// An interface implemented by objects wishing to control an InfoBar. |
// Implementing this interface is not sufficient to use an InfoBar, since it |
@@ -52,6 +52,12 @@ |
PAGE_ACTION_TYPE, |
}; |
+ virtual ~InfoBarDelegate(); |
+ |
+ // Called to create the InfoBar. Implementation of this method is |
+ // platform-specific. |
+ virtual InfoBar* CreateInfoBar() = 0; |
+ |
// 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 |
// TabContents when determining whether or not a delegate should be added |
@@ -67,64 +73,42 @@ |
const NavigationController::LoadCommittedDetails& details) const; |
// Called when the user clicks on the close button to dismiss the infobar. |
- virtual void InfoBarDismissed() {} |
+ virtual void InfoBarDismissed(); |
// Called after the InfoBar is closed. The delegate is free to delete itself |
// at this point. |
- virtual void InfoBarClosed() {} |
+ virtual void InfoBarClosed(); |
- // Called to create the InfoBar. Implementation of this method is |
- // platform-specific. |
- virtual InfoBar* CreateInfoBar() = 0; |
- |
// Return the icon to be shown for this InfoBar. If the returned bitmap is |
// NULL, no icon is shown. |
virtual SkBitmap* GetIcon() const; |
- // Returns a pointer to the AlertInfoBarDelegate interface, if implemented. |
- virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate(); |
+ // Returns the type of the infobar. The type determines the appearance (such |
+ // as background color) of the infobar. |
+ virtual Type GetInfoBarType() const; |
- // Returns a pointer to the LinkInfoBarDelegate interface, if implemented. |
- virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate(); |
- |
- // Returns a pointer to the ConfirmInfoBarDelegate interface, if implemented. |
+ // Type-checking downcast routines: |
+ virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate(); |
virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate(); |
- |
- // Returns a pointer to the ThemeInstalledInfoBarDelegate interface, if |
- // implemented. |
+ virtual CrashedExtensionInfoBarDelegate* AsCrashedExtensionInfoBarDelegate(); |
+ virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate(); |
+ virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate(); |
virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); |
- |
- // Returns a pointer to the TranslateInfoBarDelegate interface, if |
- // implemented. |
virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); |
- // Returns a pointer to the ExtensionInfoBarDelegate interface, if |
- // implemented. |
- virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate(); |
- |
- // Returns a pointer to the CrashedExtensionInfoBarDelegate interface, if |
- // implemented. |
- virtual CrashedExtensionInfoBarDelegate* AsCrashedExtensionInfoBarDelegate(); |
- |
- // Returns the type of the infobar. The type determines the appearance (such |
- // as background color) of the infobar. |
- virtual Type GetInfoBarType(); |
- |
protected: |
// Provided to subclasses as a convenience to initialize the state of this |
// object. If |contents| is non-NULL, its active entry's unique ID will be |
// stored using StoreActiveEntryUniqueID automatically. |
explicit InfoBarDelegate(TabContents* contents); |
- virtual ~InfoBarDelegate() { } |
- |
// Store the unique id for the active entry in the specified TabContents, to |
// be used later upon navigation to determine if this InfoBarDelegate should |
// be expired from |contents_|. |
void StoreActiveEntryUniqueID(TabContents* contents); |
private: |
- // The unique id of the active NavigationEntry of the TabContents taht we were |
+ // The unique id of the active NavigationEntry of the TabContents that we were |
// opened for. Used to help expire on navigations. |
int contents_unique_id_; |
@@ -138,17 +122,17 @@ |
// Returns the message string to be displayed for the InfoBar. |
virtual string16 GetMessageText() const = 0; |
- // Overridden from InfoBarDelegate. |
- virtual SkBitmap* GetIcon() const; |
- |
- // Overridden from InfoBarDelegate: |
- virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; |
+ // InfoBarDelegate: |
virtual InfoBar* CreateInfoBar(); |
- virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate(); |
+ virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; |
protected: |
explicit AlertInfoBarDelegate(TabContents* contents); |
+ virtual ~AlertInfoBarDelegate(); |
+ private: |
+ virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate(); |
+ |
DISALLOW_COPY_AND_ASSIGN(AlertInfoBarDelegate); |
}; |
@@ -165,9 +149,6 @@ |
// Returns the text of the link to be displayed. |
virtual string16 GetLinkText() const = 0; |
- // Overridden from InfoBarDelegate. |
- virtual SkBitmap* GetIcon() const; |
- |
// Called when the Link is clicked. The |disposition| specifies how the |
// resulting document should be loaded (based on the event flags present when |
// the link was clicked). This function returns true if the InfoBar should be |
@@ -175,13 +156,15 @@ |
// it. |
virtual bool LinkClicked(WindowOpenDisposition disposition); |
- // Overridden from InfoBarDelegate: |
- virtual InfoBar* CreateInfoBar(); |
- virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate(); |
- |
protected: |
explicit LinkInfoBarDelegate(TabContents* contents); |
+ virtual ~LinkInfoBarDelegate(); |
+ private: |
+ // InfoBarDelegate: |
+ virtual InfoBar* CreateInfoBar(); |
+ virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate(); |
+ |
DISALLOW_COPY_AND_ASSIGN(LinkInfoBarDelegate); |
}; |
@@ -193,8 +176,6 @@ |
BUTTON_NONE = 0, |
BUTTON_OK = 1 << 0, |
BUTTON_CANCEL = 1 << 1, |
- // Specifies that the OK button should be rendered like a default button. |
- BUTTON_OK_DEFAULT = 1 << 2 |
}; |
// Return the buttons to be shown for this InfoBar. |
@@ -227,13 +208,15 @@ |
// Will only be called if GetLinkText() returns non-empty string. |
virtual bool LinkClicked(WindowOpenDisposition disposition); |
- // Overridden from InfoBarDelegate: |
- virtual InfoBar* CreateInfoBar(); |
- virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate(); |
- |
protected: |
explicit ConfirmInfoBarDelegate(TabContents* contents); |
+ virtual ~ConfirmInfoBarDelegate(); |
+ private: |
+ // InfoBarDelegate: |
+ virtual InfoBar* CreateInfoBar(); |
+ virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate(); |
+ |
DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate); |
}; |
@@ -241,22 +224,23 @@ |
class SimpleAlertInfoBarDelegate : public AlertInfoBarDelegate { |
public: |
- // |icon| may be |NULL|. |
SimpleAlertInfoBarDelegate(TabContents* contents, |
+ SkBitmap* icon, // May be NULL. |
const string16& message, |
- SkBitmap* icon, |
bool auto_expire); |
- // Overridden from AlertInfoBarDelegate: |
+ private: |
+ virtual ~SimpleAlertInfoBarDelegate(); |
+ |
+ // AlertInfoBarDelegate: |
virtual bool ShouldExpire( |
const NavigationController::LoadCommittedDetails& details) const; |
- virtual string16 GetMessageText() const; |
- virtual SkBitmap* GetIcon() const; |
virtual void InfoBarClosed(); |
+ virtual SkBitmap* GetIcon() const; |
+ virtual string16 GetMessageText() const; |
- private: |
- string16 message_; |
SkBitmap* icon_; |
+ string16 message_; |
bool auto_expire_; // Should it expire automatically on navigation? |
DISALLOW_COPY_AND_ASSIGN(SimpleAlertInfoBarDelegate); |