Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 PAGE_ACTION_TYPE, | 40 PAGE_ACTION_TYPE, |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 enum InfoBarAutomationType { | 43 enum InfoBarAutomationType { |
| 44 CONFIRM_INFOBAR, | 44 CONFIRM_INFOBAR, |
| 45 PASSWORD_INFOBAR, | 45 PASSWORD_INFOBAR, |
| 46 RPH_INFOBAR, | 46 RPH_INFOBAR, |
| 47 UNKNOWN_INFOBAR, | 47 UNKNOWN_INFOBAR, |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 // Value to use when the InfoBar has no icon to show. | |
| 51 static const int kNoIconID = 0; | |
|
Peter Kasting
2013/05/15 21:47:43
You may want to merely declare this here, and defi
gone
2013/05/15 22:06:25
Done.
| |
| 52 | |
| 50 virtual ~InfoBarDelegate(); | 53 virtual ~InfoBarDelegate(); |
| 51 | 54 |
| 52 virtual InfoBarAutomationType GetInfoBarAutomationType() const; | 55 virtual InfoBarAutomationType GetInfoBarAutomationType() const; |
| 53 | 56 |
| 54 // Called to create the InfoBar. Implementation of this method is | 57 // Called to create the InfoBar. Implementation of this method is |
| 55 // platform-specific. | 58 // platform-specific. |
| 56 virtual InfoBar* CreateInfoBar(InfoBarService* owner) = 0; | 59 virtual InfoBar* CreateInfoBar(InfoBarService* owner) = 0; |
| 57 | 60 |
| 58 // TODO(pkasting): Move to InfoBar once InfoBars own their delegates. | 61 // TODO(pkasting): Move to InfoBar once InfoBars own their delegates. |
| 59 InfoBarService* owner() { return owner_; } | 62 InfoBarService* owner() { return owner_; } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 71 // Returns true if the InfoBar should be closed automatically after the page | 74 // Returns true if the InfoBar should be closed automatically after the page |
| 72 // is navigated. By default this returns true if the navigation is to a new | 75 // is navigated. By default this returns true if the navigation is to a new |
| 73 // page (not including reloads). Subclasses wishing to change this behavior | 76 // page (not including reloads). Subclasses wishing to change this behavior |
| 74 // can override either this function or ShouldExpireInternal(), depending on | 77 // can override either this function or ShouldExpireInternal(), depending on |
| 75 // what level of control they need. | 78 // what level of control they need. |
| 76 virtual bool ShouldExpire(const content::LoadCommittedDetails& details) const; | 79 virtual bool ShouldExpire(const content::LoadCommittedDetails& details) const; |
| 77 | 80 |
| 78 // Called when the user clicks on the close button to dismiss the infobar. | 81 // Called when the user clicks on the close button to dismiss the infobar. |
| 79 virtual void InfoBarDismissed(); | 82 virtual void InfoBarDismissed(); |
| 80 | 83 |
| 81 // Return the icon to be shown for this InfoBar. If the returned Image is | 84 // Return the resource ID of the icon to be shown for this InfoBar. If the |
| 82 // NULL, no icon is shown. | 85 // value is equal to |kNoIconID|, no icon is shown. |
| 83 virtual gfx::Image* GetIcon() const; | 86 virtual int GetIconID() const; |
| 84 | 87 |
| 85 // Returns the type of the infobar. The type determines the appearance (such | 88 // Returns the type of the infobar. The type determines the appearance (such |
| 86 // as background color) of the infobar. | 89 // as background color) of the infobar. |
| 87 virtual Type GetInfoBarType() const; | 90 virtual Type GetInfoBarType() const; |
| 88 | 91 |
| 89 // Type-checking downcast routines: | 92 // Type-checking downcast routines: |
| 90 virtual AutoLoginInfoBarDelegate* AsAutoLoginInfoBarDelegate(); | 93 virtual AutoLoginInfoBarDelegate* AsAutoLoginInfoBarDelegate(); |
| 91 virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate(); | 94 virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate(); |
| 92 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate(); | 95 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate(); |
| 93 virtual InsecureContentInfoBarDelegate* AsInsecureContentInfoBarDelegate(); | 96 virtual InsecureContentInfoBarDelegate* AsInsecureContentInfoBarDelegate(); |
| 94 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate(); | 97 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate(); |
| 95 virtual RegisterProtocolHandlerInfoBarDelegate* | 98 virtual RegisterProtocolHandlerInfoBarDelegate* |
| 96 AsRegisterProtocolHandlerInfoBarDelegate(); | 99 AsRegisterProtocolHandlerInfoBarDelegate(); |
| 97 virtual ScreenCaptureInfoBarDelegate* AsScreenCaptureInfoBarDelegate(); | 100 virtual ScreenCaptureInfoBarDelegate* AsScreenCaptureInfoBarDelegate(); |
| 98 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); | 101 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); |
| 99 virtual ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate(); | 102 virtual ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate(); |
| 100 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); | 103 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); |
| 101 | 104 |
| 105 // Return the icon to be shown for this InfoBar. If the returned Image is | |
| 106 // empty, no icon is shown. | |
| 107 gfx::Image GetIcon() const; | |
| 108 | |
| 102 content::WebContents* web_contents() { | 109 content::WebContents* web_contents() { |
| 103 return owner_ ? owner_->web_contents() : NULL; | 110 return owner_ ? owner_->web_contents() : NULL; |
| 104 } | 111 } |
| 105 | 112 |
| 106 protected: | 113 protected: |
| 107 // If |contents| is non-NULL, its active entry's unique ID will be stored | 114 // If |contents| is non-NULL, its active entry's unique ID will be stored |
| 108 // using StoreActiveEntryUniqueID automatically. | 115 // using StoreActiveEntryUniqueID automatically. |
| 109 explicit InfoBarDelegate(InfoBarService* infobar_service); | 116 explicit InfoBarDelegate(InfoBarService* infobar_service); |
| 110 | 117 |
| 111 // Store the unique id for the active entry in our WebContents, to be used | 118 // Store the unique id for the active entry in our WebContents, to be used |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 128 // opened for. Used to help expire on navigations. | 135 // opened for. Used to help expire on navigations. |
| 129 int contents_unique_id_; | 136 int contents_unique_id_; |
| 130 | 137 |
| 131 // TODO(pkasting): Remove. | 138 // TODO(pkasting): Remove. |
| 132 InfoBarService* owner_; | 139 InfoBarService* owner_; |
| 133 | 140 |
| 134 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); | 141 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); |
| 135 }; | 142 }; |
| 136 | 143 |
| 137 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ | 144 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ |
| OLD | NEW |