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