Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / infobars / core / confirm_infobar_delegate.h
blobd36ea224a272009f16eb86c784a12442358af7fc
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"
13 namespace infobars {
14 class InfoBar;
15 class InfoBarManager;
18 // An interface derived from InfoBarDelegate implemented by objects wishing to
19 // control a ConfirmInfoBar.
20 class ConfirmInfoBarDelegate : public infobars::InfoBarDelegate {
21 public:
22 enum InfoBarButton {
23 BUTTON_NONE = 0,
24 BUTTON_OK = 1 << 0,
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
44 // Windows.
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
58 // and empty string.
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);
68 protected:
69 ConfirmInfoBarDelegate();
71 private:
72 // InfoBarDelegate:
73 bool EqualsDelegate(infobars::InfoBarDelegate* delegate) const override;
74 ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() override;
76 DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate);
79 #endif // COMPONENTS_INFOBARS_CORE_CONFIRM_INFOBAR_DELEGATE_H_