| 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/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 enum InfoBarAutomationType { | 44 enum InfoBarAutomationType { |
| 45 CONFIRM_INFOBAR, | 45 CONFIRM_INFOBAR, |
| 46 PASSWORD_INFOBAR, | 46 PASSWORD_INFOBAR, |
| 47 RPH_INFOBAR, | 47 RPH_INFOBAR, |
| 48 UNKNOWN_INFOBAR, | 48 UNKNOWN_INFOBAR, |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 // Value to use when the InfoBar has no icon to show. | 51 // Value to use when the InfoBar has no icon to show. |
| 52 static const int kNoIconID; | 52 static const int kNoIconID; |
| 53 | 53 |
| 54 // Called when the InfoBar that owns this delegate is being destroyed. At |
| 55 // this point nothing is visible onscreen. |
| 54 virtual ~InfoBarDelegate(); | 56 virtual ~InfoBarDelegate(); |
| 55 | 57 |
| 56 virtual InfoBarAutomationType GetInfoBarAutomationType() const; | 58 virtual InfoBarAutomationType GetInfoBarAutomationType() const; |
| 57 | 59 |
| 58 // Called to create the InfoBar. Implementation of this method is | |
| 59 // platform-specific. | |
| 60 virtual InfoBar* CreateInfoBar(InfoBarService* owner) = 0; | |
| 61 | |
| 62 // TODO(pkasting): Move to InfoBar once InfoBars own their delegates. | |
| 63 InfoBarService* owner() { return owner_; } | |
| 64 | |
| 65 void clear_owner() { owner_ = NULL; } | |
| 66 | |
| 67 // Returns true if the supplied |delegate| is equal to this one. Equality is | 60 // Returns true if the supplied |delegate| is equal to this one. Equality is |
| 68 // left to the implementation to define. This function is called by the | 61 // left to the implementation to define. This function is called by the |
| 69 // InfoBarService when determining whether or not a delegate should be | 62 // InfoBarService when determining whether or not a delegate should be |
| 70 // added because a matching one already exists. If this function returns true, | 63 // added because a matching one already exists. If this function returns true, |
| 71 // the InfoBarService will not add the new delegate because it considers | 64 // the InfoBarService will not add the new delegate because it considers |
| 72 // one to already be present. | 65 // one to already be present. |
| 73 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; | 66 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; |
| 74 | 67 |
| 75 // Returns true if the InfoBar should be closed automatically after the page | 68 // Returns true if the InfoBar should be closed automatically after the page |
| 76 // is navigated. By default this returns true if the navigation is to a new | 69 // is navigated. By default this returns true if the navigation is to a new |
| (...skipping 20 matching lines...) Expand all Loading... |
| 97 virtual InsecureContentInfoBarDelegate* AsInsecureContentInfoBarDelegate(); | 90 virtual InsecureContentInfoBarDelegate* AsInsecureContentInfoBarDelegate(); |
| 98 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate(); | 91 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate(); |
| 99 virtual PopupBlockedInfoBarDelegate* AsPopupBlockedInfoBarDelegate(); | 92 virtual PopupBlockedInfoBarDelegate* AsPopupBlockedInfoBarDelegate(); |
| 100 virtual RegisterProtocolHandlerInfoBarDelegate* | 93 virtual RegisterProtocolHandlerInfoBarDelegate* |
| 101 AsRegisterProtocolHandlerInfoBarDelegate(); | 94 AsRegisterProtocolHandlerInfoBarDelegate(); |
| 102 virtual ScreenCaptureInfoBarDelegate* AsScreenCaptureInfoBarDelegate(); | 95 virtual ScreenCaptureInfoBarDelegate* AsScreenCaptureInfoBarDelegate(); |
| 103 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); | 96 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); |
| 104 virtual ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate(); | 97 virtual ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate(); |
| 105 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); | 98 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); |
| 106 | 99 |
| 107 // Return the icon to be shown for this InfoBar. If the returned Image is | 100 void set_infobar(InfoBar* infobar) { infobar_ = infobar; } |
| 108 // empty, no icon is shown. | |
| 109 virtual gfx::Image GetIcon() const; | |
| 110 | |
| 111 content::WebContents* web_contents() { | |
| 112 return owner_ ? owner_->web_contents() : NULL; | |
| 113 } | |
| 114 | |
| 115 protected: | |
| 116 // If |contents| is non-NULL, its active entry's unique ID will be stored | |
| 117 // using StoreActiveEntryUniqueID automatically. | |
| 118 explicit InfoBarDelegate(InfoBarService* owner); | |
| 119 | 101 |
| 120 // Store the unique id for the active entry in our WebContents, to be used | 102 // Store the unique id for the active entry in our WebContents, to be used |
| 121 // later upon navigation to determine if this InfoBarDelegate should be | 103 // later upon navigation to determine if this InfoBarDelegate should be |
| 122 // expired. | 104 // expired. |
| 123 void StoreActiveEntryUniqueID(); | 105 void StoreActiveEntryUniqueID(); |
| 124 | 106 |
| 125 int contents_unique_id() const { return contents_unique_id_; } | 107 // Return the icon to be shown for this InfoBar. If the returned Image is |
| 108 // empty, no icon is shown. |
| 109 virtual gfx::Image GetIcon() const; |
| 110 |
| 111 // This trivial getter is defined out-of-line in order to avoid needing to |
| 112 // #include infobar.h, which would lead to circular #includes. |
| 113 content::WebContents* web_contents(); |
| 114 |
| 115 protected: |
| 116 InfoBarDelegate(); |
| 126 | 117 |
| 127 // Returns true if the navigation is to a new URL or a reload occured. | 118 // Returns true if the navigation is to a new URL or a reload occured. |
| 128 virtual bool ShouldExpireInternal( | 119 virtual bool ShouldExpireInternal( |
| 129 const content::LoadCommittedDetails& details) const; | 120 const content::LoadCommittedDetails& details) const; |
| 130 | 121 |
| 131 // Removes ourself from |owner_| if we haven't already been removed. | 122 int contents_unique_id() const { return contents_unique_id_; } |
| 132 // TODO(pkasting): Move to InfoBar. | 123 InfoBar* infobar() { return infobar_; } |
| 133 void RemoveSelf(); | |
| 134 | 124 |
| 135 private: | 125 private: |
| 136 // The unique id of the active NavigationEntry of the WebContents that we were | 126 // The unique id of the active NavigationEntry of the WebContents that we were |
| 137 // opened for. Used to help expire on navigations. | 127 // opened for. Used to help expire on navigations. |
| 138 int contents_unique_id_; | 128 int contents_unique_id_; |
| 139 | 129 |
| 140 // TODO(pkasting): Remove. | 130 // The InfoBar associated with us. |
| 141 InfoBarService* owner_; | 131 InfoBar* infobar_; |
| 142 | 132 |
| 143 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); | 133 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); |
| 144 }; | 134 }; |
| 145 | 135 |
| 146 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ | 136 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ |
| OLD | NEW |