[safe-browsing] Database full hash matches like prefix match.
[chromium-blink-merge.git] / chrome / browser / infobars / confirm_infobar_delegate.h
blobe17b0fcbf676af53e02fab5e98b223c07558e672
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/memory/scoped_ptr.h"
9 #include "base/strings/string16.h"
10 #include "components/infobars/core/infobar_delegate.h"
12 namespace infobars {
13 class InfoBar;
16 // An interface derived from InfoBarDelegate implemented by objects wishing to
17 // control a ConfirmInfoBar.
18 class ConfirmInfoBarDelegate : public infobars::InfoBarDelegate {
19 public:
20 enum InfoBarButton {
21 BUTTON_NONE = 0,
22 BUTTON_OK = 1 << 0,
23 BUTTON_CANCEL = 1 << 1,
26 virtual ~ConfirmInfoBarDelegate();
28 // Returns the InfoBar type to be displayed for the InfoBar.
29 virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE;
31 // Returns the message string to be displayed for the InfoBar.
32 virtual base::string16 GetMessageText() const = 0;
34 // Returns the buttons to be shown for this InfoBar.
35 virtual int GetButtons() const;
37 // Returns the label for the specified button. The default implementation
38 // returns "OK" for the OK button and "Cancel" for the Cancel button.
39 virtual base::string16 GetButtonLabel(InfoBarButton button) const;
41 // Returns whether or not the OK button will trigger a UAC elevation prompt on
42 // Windows.
43 virtual bool OKButtonTriggersUACPrompt() const;
45 // Called when the OK button is pressed. If this function returns true, the
46 // infobar is then immediately closed. Subclasses MUST NOT return true if in
47 // handling this call something triggers the infobar to begin closing.
48 virtual bool Accept();
50 // Called when the Cancel button is pressed. If this function returns true,
51 // the infobar is then immediately closed. Subclasses MUST NOT return true if
52 // in handling this call something triggers the infobar to begin closing.
53 virtual bool Cancel();
55 // Returns the text of the link to be displayed, if any. Otherwise returns
56 // and empty string.
57 virtual base::string16 GetLinkText() const;
59 // Called when the Link (if any) is clicked. The |disposition| specifies how
60 // the resulting document should be loaded (based on the event flags present
61 // when the link was clicked). If this function returns true, the infobar is
62 // then immediately closed. Subclasses MUST NOT return true if in handling
63 // this call something triggers the infobar to begin closing.
64 virtual bool LinkClicked(WindowOpenDisposition disposition);
66 protected:
67 ConfirmInfoBarDelegate();
69 // Returns a confirm infobar that owns |delegate|.
70 static scoped_ptr<infobars::InfoBar> CreateInfoBar(
71 scoped_ptr<ConfirmInfoBarDelegate> delegate);
73 virtual bool ShouldExpireInternal(
74 const NavigationDetails& details) const OVERRIDE;
76 private:
77 // InfoBarDelegate:
78 virtual bool EqualsDelegate(
79 infobars::InfoBarDelegate* delegate) const OVERRIDE;
80 virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() OVERRIDE;
82 DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate);
85 #endif // CHROME_BROWSER_INFOBARS_CONFIRM_INFOBAR_DELEGATE_H_