[email protected] | 7cceebac | 2011-03-03 00:32:21 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_TAB_CONTENTS_CONFIRM_INFOBAR_DELEGATE_H_ |
| 6 | #define CHROME_BROWSER_TAB_CONTENTS_CONFIRM_INFOBAR_DELEGATE_H_ |
| 7 | #pragma once |
| 8 | |
| 9 | #include "base/basictypes.h" |
| 10 | #include "base/compiler_specific.h" |
| 11 | #include "base/string16.h" |
[email protected] | 95a33ed6 | 2011-09-30 15:07:08 | [diff] [blame] | 12 | #include "chrome/browser/infobars/infobar_delegate.h" |
[email protected] | 7cceebac | 2011-03-03 00:32:21 | [diff] [blame] | 13 | |
| 14 | // An interface derived from InfoBarDelegate implemented by objects wishing to |
| 15 | // control a ConfirmInfoBar. |
| 16 | class ConfirmInfoBarDelegate : public InfoBarDelegate { |
| 17 | public: |
| 18 | enum InfoBarButton { |
| 19 | BUTTON_NONE = 0, |
| 20 | BUTTON_OK = 1 << 0, |
| 21 | BUTTON_CANCEL = 1 << 1, |
| 22 | }; |
| 23 | |
| 24 | // Returns the message string to be displayed for the InfoBar. |
| 25 | virtual string16 GetMessageText() const = 0; |
| 26 | |
| 27 | // Return the buttons to be shown for this InfoBar. |
| 28 | virtual int GetButtons() const; |
| 29 | |
| 30 | // Return the label for the specified button. The default implementation |
| 31 | // returns "OK" for the OK button and "Cancel" for the Cancel button. |
| 32 | virtual string16 GetButtonLabel(InfoBarButton button) const; |
| 33 | |
| 34 | // Return whether or not the specified button needs elevation. |
| 35 | virtual bool NeedElevation(InfoBarButton button) const; |
| 36 | |
[email protected] | b0349df | 2011-09-30 23:29:18 | [diff] [blame] | 37 | // Called when the OK button is pressed. If this function returns true, the |
| 38 | // infobar is then immediately closed. Subclasses MUST NOT return true if in |
| 39 | // handling this call something triggers the infobar to begin closing. |
[email protected] | 7cceebac | 2011-03-03 00:32:21 | [diff] [blame] | 40 | virtual bool Accept(); |
| 41 | |
[email protected] | b0349df | 2011-09-30 23:29:18 | [diff] [blame] | 42 | // Called when the Cancel button is pressed. If this function returns true, |
| 43 | // the infobar is then immediately closed. Subclasses MUST NOT return true if |
| 44 | // in handling this call something triggers the infobar to begin closing. |
[email protected] | 7cceebac | 2011-03-03 00:32:21 | [diff] [blame] | 45 | virtual bool Cancel(); |
| 46 | |
| 47 | // Returns the text of the link to be displayed, if any. Otherwise returns |
| 48 | // and empty string. |
[email protected] | 8f28ba3b3 | 2011-06-24 00:32:52 | [diff] [blame] | 49 | virtual string16 GetLinkText() const; |
[email protected] | 7cceebac | 2011-03-03 00:32:21 | [diff] [blame] | 50 | |
[email protected] | b0349df | 2011-09-30 23:29:18 | [diff] [blame] | 51 | // Called when the Link (if any) is clicked. The |disposition| specifies how |
| 52 | // the resulting document should be loaded (based on the event flags present |
| 53 | // when the link was clicked). If this function returns true, the infobar is |
| 54 | // then immediately closed. Subclasses MUST NOT return true if in handling |
| 55 | // this call something triggers the infobar to begin closing. |
[email protected] | 7cceebac | 2011-03-03 00:32:21 | [diff] [blame] | 56 | virtual bool LinkClicked(WindowOpenDisposition disposition); |
| 57 | |
| 58 | protected: |
[email protected] | 95a33ed6 | 2011-09-30 15:07:08 | [diff] [blame] | 59 | explicit ConfirmInfoBarDelegate(InfoBarTabHelper* infobar_helper); |
[email protected] | 7cceebac | 2011-03-03 00:32:21 | [diff] [blame] | 60 | virtual ~ConfirmInfoBarDelegate(); |
| 61 | |
[email protected] | 4e697b04 | 2011-07-08 06:44:56 | [diff] [blame] | 62 | virtual bool ShouldExpire( |
| 63 | const content::LoadCommittedDetails& details) const OVERRIDE; |
| 64 | |
[email protected] | 7cceebac | 2011-03-03 00:32:21 | [diff] [blame] | 65 | private: |
| 66 | // InfoBarDelegate: |
[email protected] | 95a33ed6 | 2011-09-30 15:07:08 | [diff] [blame] | 67 | virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE; |
[email protected] | 7cceebac | 2011-03-03 00:32:21 | [diff] [blame] | 68 | virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE; |
| 69 | virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() OVERRIDE; |
| 70 | |
| 71 | DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate); |
| 72 | }; |
| 73 | |
| 74 | #endif // CHROME_BROWSER_TAB_CONTENTS_CONFIRM_INFOBAR_DELEGATE_H_ |