Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chrome/browser/tab_contents/infobar_delegate.h

Issue 5741001: Even more virtual method deinlining. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase (windows) Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_TAB_CONTENTS_INFOBAR_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_
6 #define CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ 6 #define CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 WARNING_TYPE, 51 WARNING_TYPE,
52 PAGE_ACTION_TYPE, 52 PAGE_ACTION_TYPE,
53 }; 53 };
54 54
55 // Returns true if the supplied |delegate| is equal to this one. Equality is 55 // Returns true if the supplied |delegate| is equal to this one. Equality is
56 // left to the implementation to define. This function is called by the 56 // left to the implementation to define. This function is called by the
57 // TabContents when determining whether or not a delegate should be added 57 // TabContents when determining whether or not a delegate should be added
58 // because a matching one already exists. If this function returns true, the 58 // because a matching one already exists. If this function returns true, the
59 // TabContents will not add the new delegate because it considers one to 59 // TabContents will not add the new delegate because it considers one to
60 // already be present. 60 // already be present.
61 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const { 61 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const;
62 return false;
63 }
64 62
65 // Returns true if the InfoBar should be closed automatically after the page 63 // Returns true if the InfoBar should be closed automatically after the page
66 // is navigated. The default behavior is to return true if the page is 64 // is navigated. The default behavior is to return true if the page is
67 // navigated somewhere else or reloaded. 65 // navigated somewhere else or reloaded.
68 virtual bool ShouldExpire( 66 virtual bool ShouldExpire(
69 const NavigationController::LoadCommittedDetails& details) const; 67 const NavigationController::LoadCommittedDetails& details) const;
70 68
71 // Called when the user clicks on the close button to dismiss the infobar. 69 // Called when the user clicks on the close button to dismiss the infobar.
72 virtual void InfoBarDismissed() {} 70 virtual void InfoBarDismissed() {}
73 71
74 // Called after the InfoBar is closed. The delegate is free to delete itself 72 // Called after the InfoBar is closed. The delegate is free to delete itself
75 // at this point. 73 // at this point.
76 virtual void InfoBarClosed() {} 74 virtual void InfoBarClosed() {}
77 75
78 // Called to create the InfoBar. Implementation of this method is 76 // Called to create the InfoBar. Implementation of this method is
79 // platform-specific. 77 // platform-specific.
80 virtual InfoBar* CreateInfoBar() = 0; 78 virtual InfoBar* CreateInfoBar() = 0;
81 79
82 // Return the icon to be shown for this InfoBar. If the returned bitmap is 80 // Return the icon to be shown for this InfoBar. If the returned bitmap is
83 // NULL, no icon is shown. 81 // NULL, no icon is shown.
84 virtual SkBitmap* GetIcon() const { return NULL; } 82 virtual SkBitmap* GetIcon() const;
85 83
86 // Returns a pointer to the AlertInfoBarDelegate interface, if implemented. 84 // Returns a pointer to the AlertInfoBarDelegate interface, if implemented.
87 virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate() { 85 virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate();
88 return NULL;
89 }
90 86
91 // Returns a pointer to the LinkInfoBarDelegate interface, if implemented. 87 // Returns a pointer to the LinkInfoBarDelegate interface, if implemented.
92 virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate() { 88 virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate();
93 return NULL;
94 }
95 89
96 // Returns a pointer to the ConfirmInfoBarDelegate interface, if implemented. 90 // Returns a pointer to the ConfirmInfoBarDelegate interface, if implemented.
97 virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() { 91 virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate();
98 return NULL;
99 }
100 92
101 // Returns a pointer to the ThemeInstalledInfoBarDelegate interface, if 93 // Returns a pointer to the ThemeInstalledInfoBarDelegate interface, if
102 // implemented. 94 // implemented.
103 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate() { 95 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate();
104 return NULL;
105 }
106 96
107 // Returns a pointer to the TranslateInfoBarDelegate interface, if 97 // Returns a pointer to the TranslateInfoBarDelegate interface, if
108 // implemented. 98 // implemented.
109 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate() { 99 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate();
110 return NULL;
111 }
112 100
113 // Returns a pointer to the ExtensionInfoBarDelegate interface, if 101 // Returns a pointer to the ExtensionInfoBarDelegate interface, if
114 // implemented. 102 // implemented.
115 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate() { 103 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate();
116 return NULL;
117 }
118 104
119 // Returns a pointer to the CrashedExtensionInfoBarDelegate interface, if 105 // Returns a pointer to the CrashedExtensionInfoBarDelegate interface, if
120 // implemented. 106 // implemented.
121 virtual CrashedExtensionInfoBarDelegate* AsCrashedExtensionInfoBarDelegate() { 107 virtual CrashedExtensionInfoBarDelegate* AsCrashedExtensionInfoBarDelegate();
122 return NULL;
123 }
124 108
125 // Returns the type of the infobar. The type determines the appearance (such 109 // Returns the type of the infobar. The type determines the appearance (such
126 // as background color) of the infobar. 110 // as background color) of the infobar.
127 virtual Type GetInfoBarType() { 111 virtual Type GetInfoBarType();
128 return WARNING_TYPE;
129 }
130 112
131 protected: 113 protected:
132 // Provided to subclasses as a convenience to initialize the state of this 114 // Provided to subclasses as a convenience to initialize the state of this
133 // object. If |contents| is non-NULL, its active entry's unique ID will be 115 // object. If |contents| is non-NULL, its active entry's unique ID will be
134 // stored using StoreActiveEntryUniqueID automatically. 116 // stored using StoreActiveEntryUniqueID automatically.
135 explicit InfoBarDelegate(TabContents* contents); 117 explicit InfoBarDelegate(TabContents* contents);
136 118
137 virtual ~InfoBarDelegate() { } 119 virtual ~InfoBarDelegate() { }
138 120
139 // Store the unique id for the active entry in the specified TabContents, to 121 // Store the unique id for the active entry in the specified TabContents, to
(...skipping 10 matching lines...) Expand all
150 }; 132 };
151 133
152 // An interface derived from InfoBarDelegate implemented by objects wishing to 134 // An interface derived from InfoBarDelegate implemented by objects wishing to
153 // control an AlertInfoBar. 135 // control an AlertInfoBar.
154 class AlertInfoBarDelegate : public InfoBarDelegate { 136 class AlertInfoBarDelegate : public InfoBarDelegate {
155 public: 137 public:
156 // Returns the message string to be displayed for the InfoBar. 138 // Returns the message string to be displayed for the InfoBar.
157 virtual string16 GetMessageText() const = 0; 139 virtual string16 GetMessageText() const = 0;
158 140
159 // Overridden from InfoBarDelegate. 141 // Overridden from InfoBarDelegate.
160 virtual SkBitmap* GetIcon() const { return NULL; } 142 virtual SkBitmap* GetIcon() const;
161 143
162 // Overridden from InfoBarDelegate: 144 // Overridden from InfoBarDelegate:
163 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; 145 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const;
164 virtual InfoBar* CreateInfoBar(); 146 virtual InfoBar* CreateInfoBar();
165 virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate() { return this; } 147 virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate();
166 148
167 protected: 149 protected:
168 explicit AlertInfoBarDelegate(TabContents* contents); 150 explicit AlertInfoBarDelegate(TabContents* contents);
169 151
170 DISALLOW_COPY_AND_ASSIGN(AlertInfoBarDelegate); 152 DISALLOW_COPY_AND_ASSIGN(AlertInfoBarDelegate);
171 }; 153 };
172 154
173 // An interface derived from InfoBarDelegate implemented by objects wishing to 155 // An interface derived from InfoBarDelegate implemented by objects wishing to
174 // control a LinkInfoBar. 156 // control a LinkInfoBar.
175 class LinkInfoBarDelegate : public InfoBarDelegate { 157 class LinkInfoBarDelegate : public InfoBarDelegate {
176 public: 158 public:
177 // Returns the message string to be displayed in the InfoBar. |link_offset| 159 // Returns the message string to be displayed in the InfoBar. |link_offset|
178 // is the position where the link should be inserted. If |link_offset| is set 160 // is the position where the link should be inserted. If |link_offset| is set
179 // to string16::npos (it is by default), the link is right aligned within 161 // to string16::npos (it is by default), the link is right aligned within
180 // the InfoBar rather than being embedded in the message text. 162 // the InfoBar rather than being embedded in the message text.
181 virtual string16 GetMessageTextWithOffset(size_t* link_offset) const { 163 virtual string16 GetMessageTextWithOffset(size_t* link_offset) const;
182 *link_offset = string16::npos;
183 return string16();
184 }
185 164
186 // Returns the text of the link to be displayed. 165 // Returns the text of the link to be displayed.
187 virtual string16 GetLinkText() const = 0; 166 virtual string16 GetLinkText() const = 0;
188 167
189 // Overridden from InfoBarDelegate. 168 // Overridden from InfoBarDelegate.
190 virtual SkBitmap* GetIcon() const { return NULL; } 169 virtual SkBitmap* GetIcon() const;
191 170
192 // Called when the Link is clicked. The |disposition| specifies how the 171 // Called when the Link is clicked. The |disposition| specifies how the
193 // resulting document should be loaded (based on the event flags present when 172 // resulting document should be loaded (based on the event flags present when
194 // the link was clicked). This function returns true if the InfoBar should be 173 // the link was clicked). This function returns true if the InfoBar should be
195 // closed now or false if it should remain until the user explicitly closes 174 // closed now or false if it should remain until the user explicitly closes
196 // it. 175 // it.
197 virtual bool LinkClicked(WindowOpenDisposition disposition) { 176 virtual bool LinkClicked(WindowOpenDisposition disposition);
198 return true;
199 }
200 177
201 // Overridden from InfoBarDelegate: 178 // Overridden from InfoBarDelegate:
202 virtual InfoBar* CreateInfoBar(); 179 virtual InfoBar* CreateInfoBar();
203 virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate() { 180 virtual LinkInfoBarDelegate* AsLinkInfoBarDelegate();
204 return this;
205 }
206 181
207 protected: 182 protected:
208 explicit LinkInfoBarDelegate(TabContents* contents); 183 explicit LinkInfoBarDelegate(TabContents* contents);
209 184
210 DISALLOW_COPY_AND_ASSIGN(LinkInfoBarDelegate); 185 DISALLOW_COPY_AND_ASSIGN(LinkInfoBarDelegate);
211 }; 186 };
212 187
213 // An interface derived from InfoBarDelegate implemented by objects wishing to 188 // An interface derived from InfoBarDelegate implemented by objects wishing to
214 // control a ConfirmInfoBar. 189 // control a ConfirmInfoBar.
215 class ConfirmInfoBarDelegate : public AlertInfoBarDelegate { 190 class ConfirmInfoBarDelegate : public AlertInfoBarDelegate {
216 public: 191 public:
217 enum InfoBarButton { 192 enum InfoBarButton {
218 BUTTON_NONE = 0, 193 BUTTON_NONE = 0,
219 BUTTON_OK = 1, 194 BUTTON_OK = 1,
220 BUTTON_CANCEL = 2, 195 BUTTON_CANCEL = 2,
221 // Specifies that the OK button should be rendered like a default button. 196 // Specifies that the OK button should be rendered like a default button.
222 BUTTON_OK_DEFAULT = 4 197 BUTTON_OK_DEFAULT = 4
223 }; 198 };
224 199
225 // Return the buttons to be shown for this InfoBar. 200 // Return the buttons to be shown for this InfoBar.
226 virtual int GetButtons() const { 201 virtual int GetButtons() const;
227 return BUTTON_NONE;
228 }
229 202
230 // Return the label for the specified button. The default implementation 203 // Return the label for the specified button. The default implementation
231 // returns "OK" for the OK button and "Cancel" for the Cancel button. 204 // returns "OK" for the OK button and "Cancel" for the Cancel button.
232 virtual string16 GetButtonLabel(InfoBarButton button) const; 205 virtual string16 GetButtonLabel(InfoBarButton button) const;
233 206
234 // Return whether or not the specified button needs elevation. 207 // Return whether or not the specified button needs elevation.
235 virtual bool NeedElevation(InfoBarButton button) const { return false; } 208 virtual bool NeedElevation(InfoBarButton button) const;
236 209
237 // Called when the OK button is pressed. If the function returns true, the 210 // Called when the OK button is pressed. If the function returns true, the
238 // InfoBarDelegate should be removed from the associated TabContents. 211 // InfoBarDelegate should be removed from the associated TabContents.
239 virtual bool Accept() { return true; } 212 virtual bool Accept();
240 213
241 // Called when the Cancel button is pressed. If the function returns true, 214 // Called when the Cancel button is pressed. If the function returns true,
242 // the InfoBarDelegate should be removed from the associated TabContents. 215 // the InfoBarDelegate should be removed from the associated TabContents.
243 virtual bool Cancel() { return true; } 216 virtual bool Cancel();
244 217
245 // Returns the text of the link to be displayed, if any. Otherwise returns 218 // Returns the text of the link to be displayed, if any. Otherwise returns
246 // and empty string. 219 // and empty string.
247 virtual string16 GetLinkText() { 220 virtual string16 GetLinkText();
248 return string16();
249 }
250 221
251 // Called when the Link is clicked. The |disposition| specifies how the 222 // Called when the Link is clicked. The |disposition| specifies how the
252 // resulting document should be loaded (based on the event flags present when 223 // resulting document should be loaded (based on the event flags present when
253 // the link was clicked). This function returns true if the InfoBar should be 224 // the link was clicked). This function returns true if the InfoBar should be
254 // closed now or false if it should remain until the user explicitly closes 225 // closed now or false if it should remain until the user explicitly closes
255 // it. 226 // it.
256 // Will only be called if GetLinkText() returns non-empty string. 227 // Will only be called if GetLinkText() returns non-empty string.
257 virtual bool LinkClicked(WindowOpenDisposition disposition) { 228 virtual bool LinkClicked(WindowOpenDisposition disposition);
258 return true;
259 }
260 229
261 // Overridden from InfoBarDelegate: 230 // Overridden from InfoBarDelegate:
262 virtual InfoBar* CreateInfoBar(); 231 virtual InfoBar* CreateInfoBar();
263 virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() { 232 virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate();
264 return this;
265 }
266 233
267 protected: 234 protected:
268 explicit ConfirmInfoBarDelegate(TabContents* contents); 235 explicit ConfirmInfoBarDelegate(TabContents* contents);
269 236
270 DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate); 237 DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate);
271 }; 238 };
272 239
273 // Simple implementations for common use cases --------------------------------- 240 // Simple implementations for common use cases ---------------------------------
274 241
275 class SimpleAlertInfoBarDelegate : public AlertInfoBarDelegate { 242 class SimpleAlertInfoBarDelegate : public AlertInfoBarDelegate {
(...skipping 13 matching lines...) Expand all
289 256
290 private: 257 private:
291 string16 message_; 258 string16 message_;
292 SkBitmap* icon_; 259 SkBitmap* icon_;
293 bool auto_expire_; // Should it expire automatically on navigation? 260 bool auto_expire_; // Should it expire automatically on navigation?
294 261
295 DISALLOW_COPY_AND_ASSIGN(SimpleAlertInfoBarDelegate); 262 DISALLOW_COPY_AND_ASSIGN(SimpleAlertInfoBarDelegate);
296 }; 263 };
297 264
298 #endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ 265 #endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/background_contents.cc ('k') | chrome/browser/tab_contents/infobar_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698