OLD | NEW |
| (Empty) |
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 | |
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 | |
8 #include "base/basictypes.h" | |
9 #include "base/compiler_specific.h" | |
10 #include "base/string16.h" | |
11 #include "chrome/browser/infobars/infobar_delegate.h" | |
12 | |
13 // An interface derived from InfoBarDelegate implemented by objects wishing to | |
14 // control a ConfirmInfoBar. | |
15 class ConfirmInfoBarDelegate : public InfoBarDelegate { | |
16 public: | |
17 enum InfoBarButton { | |
18 BUTTON_NONE = 0, | |
19 BUTTON_OK = 1 << 0, | |
20 BUTTON_CANCEL = 1 << 1, | |
21 }; | |
22 | |
23 // Returns the InfoBar type to be displayed for the InfoBar. | |
24 virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE; | |
25 | |
26 // Returns the message string to be displayed for the InfoBar. | |
27 virtual string16 GetMessageText() const = 0; | |
28 | |
29 // Return the buttons to be shown for this InfoBar. | |
30 virtual int GetButtons() const; | |
31 | |
32 // Return the label for the specified button. The default implementation | |
33 // returns "OK" for the OK button and "Cancel" for the Cancel button. | |
34 virtual string16 GetButtonLabel(InfoBarButton button) const; | |
35 | |
36 // Return whether or not the specified button needs elevation. | |
37 virtual bool NeedElevation(InfoBarButton button) const; | |
38 | |
39 // Called when the OK button is pressed. If this function returns true, the | |
40 // infobar is then immediately closed. Subclasses MUST NOT return true if in | |
41 // handling this call something triggers the infobar to begin closing. | |
42 virtual bool Accept(); | |
43 | |
44 // Called when the Cancel button is pressed. If this function returns true, | |
45 // the infobar is then immediately closed. Subclasses MUST NOT return true if | |
46 // in handling this call something triggers the infobar to begin closing. | |
47 virtual bool Cancel(); | |
48 | |
49 // Returns the text of the link to be displayed, if any. Otherwise returns | |
50 // and empty string. | |
51 virtual string16 GetLinkText() const; | |
52 | |
53 // Called when the Link (if any) is clicked. The |disposition| specifies how | |
54 // the resulting document should be loaded (based on the event flags present | |
55 // when the link was clicked). If this function returns true, the infobar is | |
56 // then immediately closed. Subclasses MUST NOT return true if in handling | |
57 // this call something triggers the infobar to begin closing. | |
58 virtual bool LinkClicked(WindowOpenDisposition disposition); | |
59 | |
60 protected: | |
61 explicit ConfirmInfoBarDelegate(InfoBarTabHelper* infobar_helper); | |
62 virtual ~ConfirmInfoBarDelegate(); | |
63 | |
64 virtual bool ShouldExpireInternal( | |
65 const content::LoadCommittedDetails& details) const OVERRIDE; | |
66 | |
67 private: | |
68 // InfoBarDelegate: | |
69 virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE; | |
70 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE; | |
71 virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() OVERRIDE; | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate); | |
74 }; | |
75 | |
76 #endif // CHROME_BROWSER_TAB_CONTENTS_CONFIRM_INFOBAR_DELEGATE_H_ | |
OLD | NEW |