| OLD | NEW |
| 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 <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 int contents_unique_id_; | 149 int contents_unique_id_; |
| 150 | 150 |
| 151 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); | 151 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 // An interface derived from InfoBarDelegate implemented by objects wishing to | 154 // An interface derived from InfoBarDelegate implemented by objects wishing to |
| 155 // control an AlertInfoBar. | 155 // control an AlertInfoBar. |
| 156 class AlertInfoBarDelegate : public InfoBarDelegate { | 156 class AlertInfoBarDelegate : public InfoBarDelegate { |
| 157 public: | 157 public: |
| 158 // Returns the message string to be displayed for the InfoBar. | 158 // Returns the message string to be displayed for the InfoBar. |
| 159 virtual std::wstring GetMessageText() const = 0; | 159 virtual string16 GetMessageText() const = 0; |
| 160 | 160 |
| 161 // Overridden from InfoBarDelegate. | 161 // Overridden from InfoBarDelegate. |
| 162 virtual SkBitmap* GetIcon() const { return NULL; } | 162 virtual SkBitmap* GetIcon() const { return NULL; } |
| 163 | 163 |
| 164 // Overridden from InfoBarDelegate: | 164 // Overridden from InfoBarDelegate: |
| 165 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; | 165 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; |
| 166 virtual InfoBar* CreateInfoBar(); | 166 virtual InfoBar* CreateInfoBar(); |
| 167 virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate() { return this; } | 167 virtual AlertInfoBarDelegate* AsAlertInfoBarDelegate() { return this; } |
| 168 | 168 |
| 169 protected: | 169 protected: |
| 170 explicit AlertInfoBarDelegate(TabContents* contents); | 170 explicit AlertInfoBarDelegate(TabContents* contents); |
| 171 | 171 |
| 172 DISALLOW_COPY_AND_ASSIGN(AlertInfoBarDelegate); | 172 DISALLOW_COPY_AND_ASSIGN(AlertInfoBarDelegate); |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 // An interface derived from InfoBarDelegate implemented by objects wishing to | 175 // An interface derived from InfoBarDelegate implemented by objects wishing to |
| 176 // control a LinkInfoBar. | 176 // control a LinkInfoBar. |
| 177 class LinkInfoBarDelegate : public InfoBarDelegate { | 177 class LinkInfoBarDelegate : public InfoBarDelegate { |
| 178 public: | 178 public: |
| 179 // Returns the message string to be displayed in the InfoBar. |link_offset| | 179 // Returns the message string to be displayed in the InfoBar. |link_offset| |
| 180 // is the position where the link should be inserted. If |link_offset| is set | 180 // is the position where the link should be inserted. If |link_offset| is set |
| 181 // to std::wstring::npos (it is by default), the link is right aligned within | 181 // to string16::npos (it is by default), the link is right aligned within |
| 182 // the InfoBar rather than being embedded in the message text. | 182 // the InfoBar rather than being embedded in the message text. |
| 183 virtual std::wstring GetMessageTextWithOffset(size_t* link_offset) const { | 183 virtual string16 GetMessageTextWithOffset(size_t* link_offset) const { |
| 184 *link_offset = std::wstring::npos; | 184 *link_offset = string16::npos; |
| 185 return std::wstring(); | 185 return string16(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 // Returns the text of the link to be displayed. | 188 // Returns the text of the link to be displayed. |
| 189 virtual std::wstring GetLinkText() const = 0; | 189 virtual string16 GetLinkText() const = 0; |
| 190 | 190 |
| 191 // Overridden from InfoBarDelegate. | 191 // Overridden from InfoBarDelegate. |
| 192 virtual SkBitmap* GetIcon() const { return NULL; } | 192 virtual SkBitmap* GetIcon() const { return NULL; } |
| 193 | 193 |
| 194 // Called when the Link is clicked. The |disposition| specifies how the | 194 // Called when the Link is clicked. The |disposition| specifies how the |
| 195 // resulting document should be loaded (based on the event flags present when | 195 // resulting document should be loaded (based on the event flags present when |
| 196 // the link was clicked). This function returns true if the InfoBar should be | 196 // the link was clicked). This function returns true if the InfoBar should be |
| 197 // closed now or false if it should remain until the user explicitly closes | 197 // closed now or false if it should remain until the user explicitly closes |
| 198 // it. | 198 // it. |
| 199 virtual bool LinkClicked(WindowOpenDisposition disposition) { | 199 virtual bool LinkClicked(WindowOpenDisposition disposition) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 224 BUTTON_OK_DEFAULT = 4 | 224 BUTTON_OK_DEFAULT = 4 |
| 225 }; | 225 }; |
| 226 | 226 |
| 227 // Return the buttons to be shown for this InfoBar. | 227 // Return the buttons to be shown for this InfoBar. |
| 228 virtual int GetButtons() const { | 228 virtual int GetButtons() const { |
| 229 return BUTTON_NONE; | 229 return BUTTON_NONE; |
| 230 } | 230 } |
| 231 | 231 |
| 232 // Return the label for the specified button. The default implementation | 232 // Return the label for the specified button. The default implementation |
| 233 // returns "OK" for the OK button and "Cancel" for the Cancel button. | 233 // returns "OK" for the OK button and "Cancel" for the Cancel button. |
| 234 virtual std::wstring GetButtonLabel(InfoBarButton button) const; | 234 virtual string16 GetButtonLabel(InfoBarButton button) const; |
| 235 | 235 |
| 236 // Return whether or not the specified button needs elevation. | 236 // Return whether or not the specified button needs elevation. |
| 237 virtual bool NeedElevation(InfoBarButton button) const { return false; } | 237 virtual bool NeedElevation(InfoBarButton button) const { return false; } |
| 238 | 238 |
| 239 // Called when the OK button is pressed. If the function returns true, the | 239 // Called when the OK button is pressed. If the function returns true, the |
| 240 // InfoBarDelegate should be removed from the associated TabContents. | 240 // InfoBarDelegate should be removed from the associated TabContents. |
| 241 virtual bool Accept() { return true; } | 241 virtual bool Accept() { return true; } |
| 242 | 242 |
| 243 // Called when the Cancel button is pressed. If the function returns true, | 243 // Called when the Cancel button is pressed. If the function returns true, |
| 244 // the InfoBarDelegate should be removed from the associated TabContents. | 244 // the InfoBarDelegate should be removed from the associated TabContents. |
| 245 virtual bool Cancel() { return true; } | 245 virtual bool Cancel() { return true; } |
| 246 | 246 |
| 247 // Returns the text of the link to be displayed, if any. Otherwise returns | 247 // Returns the text of the link to be displayed, if any. Otherwise returns |
| 248 // and empty string. | 248 // and empty string. |
| 249 virtual std::wstring GetLinkText() { | 249 virtual string16 GetLinkText() { |
| 250 return std::wstring(); | 250 return string16(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 // Called when the Link is clicked. The |disposition| specifies how the | 253 // Called when the Link is clicked. The |disposition| specifies how the |
| 254 // resulting document should be loaded (based on the event flags present when | 254 // resulting document should be loaded (based on the event flags present when |
| 255 // the link was clicked). This function returns true if the InfoBar should be | 255 // the link was clicked). This function returns true if the InfoBar should be |
| 256 // closed now or false if it should remain until the user explicitly closes | 256 // closed now or false if it should remain until the user explicitly closes |
| 257 // it. | 257 // it. |
| 258 // Will only be called if GetLinkText() returns non-empty string. | 258 // Will only be called if GetLinkText() returns non-empty string. |
| 259 virtual bool LinkClicked(WindowOpenDisposition disposition) { | 259 virtual bool LinkClicked(WindowOpenDisposition disposition) { |
| 260 return true; | 260 return true; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 271 | 271 |
| 272 DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate); | 272 DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate); |
| 273 }; | 273 }; |
| 274 | 274 |
| 275 // Simple implementations for common use cases --------------------------------- | 275 // Simple implementations for common use cases --------------------------------- |
| 276 | 276 |
| 277 class SimpleAlertInfoBarDelegate : public AlertInfoBarDelegate { | 277 class SimpleAlertInfoBarDelegate : public AlertInfoBarDelegate { |
| 278 public: | 278 public: |
| 279 // |icon| may be |NULL|. | 279 // |icon| may be |NULL|. |
| 280 SimpleAlertInfoBarDelegate(TabContents* contents, | 280 SimpleAlertInfoBarDelegate(TabContents* contents, |
| 281 const std::wstring& message, | 281 const string16& message, |
| 282 SkBitmap* icon, | 282 SkBitmap* icon, |
| 283 bool auto_expire); | 283 bool auto_expire); |
| 284 | 284 |
| 285 // Overridden from AlertInfoBarDelegate: | 285 // Overridden from AlertInfoBarDelegate: |
| 286 virtual bool ShouldExpire( | 286 virtual bool ShouldExpire( |
| 287 const NavigationController::LoadCommittedDetails& details) const; | 287 const NavigationController::LoadCommittedDetails& details) const; |
| 288 virtual std::wstring GetMessageText() const; | 288 virtual string16 GetMessageText() const; |
| 289 virtual SkBitmap* GetIcon() const; | 289 virtual SkBitmap* GetIcon() const; |
| 290 virtual void InfoBarClosed(); | 290 virtual void InfoBarClosed(); |
| 291 | 291 |
| 292 private: | 292 private: |
| 293 std::wstring message_; | 293 string16 message_; |
| 294 SkBitmap* icon_; | 294 SkBitmap* icon_; |
| 295 bool auto_expire_; // Should it expire automatically on navigation? | 295 bool auto_expire_; // Should it expire automatically on navigation? |
| 296 | 296 |
| 297 DISALLOW_COPY_AND_ASSIGN(SimpleAlertInfoBarDelegate); | 297 DISALLOW_COPY_AND_ASSIGN(SimpleAlertInfoBarDelegate); |
| 298 }; | 298 }; |
| 299 | 299 |
| 300 #endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ | 300 #endif // CHROME_BROWSER_TAB_CONTENTS_INFOBAR_DELEGATE_H_ |
| OLD | NEW |