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 COMPONENTS_INFOBARS_CORE_CONFIRM_INFOBAR_DELEGATE_H_
6 #define COMPONENTS_INFOBARS_CORE_CONFIRM_INFOBAR_DELEGATE_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string16.h"
10 #include "components/infobars/core/infobar_delegate.h"
11 #include "components/infobars/core/infobar_manager.h"
18 // An interface derived from InfoBarDelegate implemented by objects wishing to
19 // control a ConfirmInfoBar.
20 class ConfirmInfoBarDelegate
: public infobars::InfoBarDelegate
{
25 BUTTON_CANCEL
= 1 << 1,
28 ~ConfirmInfoBarDelegate() override
;
30 // Returns the InfoBar type to be displayed for the InfoBar.
31 InfoBarAutomationType
GetInfoBarAutomationType() const override
;
33 // Returns the message string to be displayed for the InfoBar.
34 virtual base::string16
GetMessageText() const = 0;
36 // Returns the buttons to be shown for this InfoBar.
37 virtual int GetButtons() const;
39 // Returns the label for the specified button. The default implementation
40 // returns "OK" for the OK button and "Cancel" for the Cancel button.
41 virtual base::string16
GetButtonLabel(InfoBarButton button
) const;
43 // Returns whether or not the OK button will trigger a UAC elevation prompt on
45 virtual bool OKButtonTriggersUACPrompt() const;
47 // Called when the OK button is pressed. If this function returns true, the
48 // infobar is then immediately closed. Subclasses MUST NOT return true if in
49 // handling this call something triggers the infobar to begin closing.
50 virtual bool Accept();
52 // Called when the Cancel button is pressed. If this function returns true,
53 // the infobar is then immediately closed. Subclasses MUST NOT return true if
54 // in handling this call something triggers the infobar to begin closing.
55 virtual bool Cancel();
57 // Returns the text of the link to be displayed, if any. Otherwise returns
59 virtual base::string16
GetLinkText() const;
61 // Called when the Link (if any) is clicked. The |disposition| specifies how
62 // the resulting document should be loaded (based on the event flags present
63 // when the link was clicked). If this function returns true, the infobar is
64 // then immediately closed. Subclasses MUST NOT return true if in handling
65 // this call something triggers the infobar to begin closing.
66 virtual bool LinkClicked(WindowOpenDisposition disposition
);
69 ConfirmInfoBarDelegate();
71 bool ShouldExpireInternal(const NavigationDetails
& details
) const override
;
75 bool EqualsDelegate(infobars::InfoBarDelegate
* delegate
) const override
;
76 ConfirmInfoBarDelegate
* AsConfirmInfoBarDelegate() override
;
78 DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate
);
81 #endif // COMPONENTS_INFOBARS_CORE_CONFIRM_INFOBAR_DELEGATE_H_