blob: 593fe3ddcc8e94830dd97d920a4f9f71a64ca329 [file] [log] [blame]
[email protected]7cceebac2011-03-03 00:32:211// Copyright (c) 2011 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#pragma once
8
9#include "base/basictypes.h"
10#include "base/compiler_specific.h"
11#include "base/string16.h"
[email protected]95a33ed62011-09-30 15:07:0812#include "chrome/browser/infobars/infobar_delegate.h"
[email protected]7cceebac2011-03-03 00:32:2113
14// An interface derived from InfoBarDelegate implemented by objects wishing to
15// control a ConfirmInfoBar.
16class ConfirmInfoBarDelegate : public InfoBarDelegate {
17 public:
18 enum InfoBarButton {
19 BUTTON_NONE = 0,
20 BUTTON_OK = 1 << 0,
21 BUTTON_CANCEL = 1 << 1,
22 };
23
24 // Returns the message string to be displayed for the InfoBar.
25 virtual string16 GetMessageText() const = 0;
26
27 // Return the buttons to be shown for this InfoBar.
28 virtual int GetButtons() const;
29
30 // Return the label for the specified button. The default implementation
31 // returns "OK" for the OK button and "Cancel" for the Cancel button.
32 virtual string16 GetButtonLabel(InfoBarButton button) const;
33
34 // Return whether or not the specified button needs elevation.
35 virtual bool NeedElevation(InfoBarButton button) const;
36
[email protected]b0349df2011-09-30 23:29:1837 // Called when the OK button is pressed. If this function returns true, the
38 // infobar is then immediately closed. Subclasses MUST NOT return true if in
39 // handling this call something triggers the infobar to begin closing.
[email protected]7cceebac2011-03-03 00:32:2140 virtual bool Accept();
41
[email protected]b0349df2011-09-30 23:29:1842 // Called when the Cancel button is pressed. If this function returns true,
43 // the infobar is then immediately closed. Subclasses MUST NOT return true if
44 // in handling this call something triggers the infobar to begin closing.
[email protected]7cceebac2011-03-03 00:32:2145 virtual bool Cancel();
46
47 // Returns the text of the link to be displayed, if any. Otherwise returns
48 // and empty string.
[email protected]8f28ba3b32011-06-24 00:32:5249 virtual string16 GetLinkText() const;
[email protected]7cceebac2011-03-03 00:32:2150
[email protected]b0349df2011-09-30 23:29:1851 // Called when the Link (if any) is clicked. The |disposition| specifies how
52 // the resulting document should be loaded (based on the event flags present
53 // when the link was clicked). If this function returns true, the infobar is
54 // then immediately closed. Subclasses MUST NOT return true if in handling
55 // this call something triggers the infobar to begin closing.
[email protected]7cceebac2011-03-03 00:32:2156 virtual bool LinkClicked(WindowOpenDisposition disposition);
57
58 protected:
[email protected]95a33ed62011-09-30 15:07:0859 explicit ConfirmInfoBarDelegate(InfoBarTabHelper* infobar_helper);
[email protected]7cceebac2011-03-03 00:32:2160 virtual ~ConfirmInfoBarDelegate();
61
[email protected]4e697b042011-07-08 06:44:5662 virtual bool ShouldExpire(
63 const content::LoadCommittedDetails& details) const OVERRIDE;
64
[email protected]7cceebac2011-03-03 00:32:2165 private:
66 // InfoBarDelegate:
[email protected]95a33ed62011-09-30 15:07:0867 virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE;
[email protected]7cceebac2011-03-03 00:32:2168 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE;
69 virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() OVERRIDE;
70
71 DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate);
72};
73
74#endif // CHROME_BROWSER_TAB_CONTENTS_CONFIRM_INFOBAR_DELEGATE_H_