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 "ui/base/window_open_disposition.h" | 10 #include "ui/base/window_open_disposition.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 static const int kNoIconID; | 66 static const int kNoIconID; |
67 | 67 |
68 // Called when the InfoBar that owns this delegate is being destroyed. At | 68 // Called when the InfoBar that owns this delegate is being destroyed. At |
69 // this point nothing is visible onscreen. | 69 // this point nothing is visible onscreen. |
70 virtual ~InfoBarDelegate(); | 70 virtual ~InfoBarDelegate(); |
71 | 71 |
72 virtual InfoBarAutomationType GetInfoBarAutomationType() const; | 72 virtual InfoBarAutomationType GetInfoBarAutomationType() const; |
73 | 73 |
74 // Returns true if the supplied |delegate| is equal to this one. Equality is | 74 // Returns true if the supplied |delegate| is equal to this one. Equality is |
75 // left to the implementation to define. This function is called by the | 75 // left to the implementation to define. This function is called by the |
76 // InfoBarService when determining whether or not a delegate should be | 76 // InfoBarManager when determining whether or not a delegate should be |
77 // added because a matching one already exists. If this function returns true, | 77 // added because a matching one already exists. If this function returns true, |
78 // the InfoBarService will not add the new delegate because it considers | 78 // the InfoBarManager will not add the new delegate because it considers |
79 // one to already be present. | 79 // one to already be present. |
80 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; | 80 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; |
81 | 81 |
82 // Returns true if the InfoBar should be closed automatically after the page | 82 // Returns true if the InfoBar should be closed automatically after the page |
83 // is navigated. By default this returns true if the navigation is to a new | 83 // is navigated. By default this returns true if the navigation is to a new |
84 // page (not including reloads). Subclasses wishing to change this behavior | 84 // page (not including reloads). Subclasses wishing to change this behavior |
85 // can override either this function or ShouldExpireInternal(), depending on | 85 // can override either this function or ShouldExpireInternal(), depending on |
86 // what level of control they need. | 86 // what level of control they need. |
87 virtual bool ShouldExpire(const NavigationDetails& details) const; | 87 virtual bool ShouldExpire(const NavigationDetails& details) const; |
88 | 88 |
(...skipping 16 matching lines...) Expand all Loading... |
105 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate(); | 105 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate(); |
106 virtual PopupBlockedInfoBarDelegate* AsPopupBlockedInfoBarDelegate(); | 106 virtual PopupBlockedInfoBarDelegate* AsPopupBlockedInfoBarDelegate(); |
107 virtual RegisterProtocolHandlerInfoBarDelegate* | 107 virtual RegisterProtocolHandlerInfoBarDelegate* |
108 AsRegisterProtocolHandlerInfoBarDelegate(); | 108 AsRegisterProtocolHandlerInfoBarDelegate(); |
109 virtual ScreenCaptureInfoBarDelegate* AsScreenCaptureInfoBarDelegate(); | 109 virtual ScreenCaptureInfoBarDelegate* AsScreenCaptureInfoBarDelegate(); |
110 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); | 110 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); |
111 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); | 111 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); |
112 | 112 |
113 void set_infobar(InfoBar* infobar) { infobar_ = infobar; } | 113 void set_infobar(InfoBar* infobar) { infobar_ = infobar; } |
114 | 114 |
115 // Store the unique id for the active entry in our WebContents, to be used | 115 // Store the unique id for the active entry, to be used later upon navigation |
116 // later upon navigation to determine if this InfoBarDelegate should be | 116 // to determine if this InfoBarDelegate should be expired. |
117 // expired. | |
118 void StoreActiveEntryUniqueID(); | 117 void StoreActiveEntryUniqueID(); |
119 | 118 |
120 // Return the icon to be shown for this InfoBar. If the returned Image is | 119 // Return the icon to be shown for this InfoBar. If the returned Image is |
121 // empty, no icon is shown. | 120 // empty, no icon is shown. |
122 virtual gfx::Image GetIcon() const; | 121 virtual gfx::Image GetIcon() const; |
123 | 122 |
124 protected: | 123 protected: |
125 InfoBarDelegate(); | 124 InfoBarDelegate(); |
126 | 125 |
127 // Returns true if the navigation is to a new URL or a reload occured. | 126 // Returns true if the navigation is to a new URL or a reload occured. |
128 virtual bool ShouldExpireInternal(const NavigationDetails& details) const; | 127 virtual bool ShouldExpireInternal(const NavigationDetails& details) const; |
129 | 128 |
130 int contents_unique_id() const { return contents_unique_id_; } | 129 int contents_unique_id() const { return contents_unique_id_; } |
131 InfoBar* infobar() { return infobar_; } | 130 InfoBar* infobar() { return infobar_; } |
132 | 131 |
133 private: | 132 private: |
134 // The unique id of the active NavigationEntry of the WebContents that we were | 133 // The unique id of the active NavigationEntry of the WebContents that we were |
135 // opened for. Used to help expire on navigations. | 134 // opened for. Used to help expire on navigations. |
136 int contents_unique_id_; | 135 int contents_unique_id_; |
137 | 136 |
138 // The InfoBar associated with us. | 137 // The InfoBar associated with us. |
139 InfoBar* infobar_; | 138 InfoBar* infobar_; |
140 | 139 |
141 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); | 140 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); |
142 }; | 141 }; |
143 | 142 |
144 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ | 143 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ |
OLD | NEW |