15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#ifndef COMPONENTS_INFOBARS_CORE_CONFIRM_INFOBAR_DELEGATE_H_
6cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define COMPONENTS_INFOBARS_CORE_CONFIRM_INFOBAR_DELEGATE_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string16.h"
100529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "components/infobars/core/infobar_delegate.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
120529e5d033099cbfc42635f6f6183833b09dff6eBen Murdochnamespace infobars {
13a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class InfoBar;
140529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch}
15a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// An interface derived from InfoBarDelegate implemented by objects wishing to
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// control a ConfirmInfoBar.
180529e5d033099cbfc42635f6f6183833b09dff6eBen Murdochclass ConfirmInfoBarDelegate : public infobars::InfoBarDelegate {
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  enum InfoBarButton {
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    BUTTON_NONE   = 0,
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    BUTTON_OK     = 1 << 0,
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    BUTTON_CANCEL = 1 << 1,
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~ConfirmInfoBarDelegate();
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the InfoBar type to be displayed for the InfoBar.
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE;
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the message string to be displayed for the InfoBar.
32a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual base::string16 GetMessageText() const = 0;
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
345c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // Returns the buttons to be shown for this InfoBar.
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int GetButtons() const;
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
375c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // Returns the label for the specified button. The default implementation
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // returns "OK" for the OK button and "Cancel" for the Cancel button.
39a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual base::string16 GetButtonLabel(InfoBarButton button) const;
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
415c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // Returns whether or not the OK button will trigger a UAC elevation prompt on
425c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  // Windows.
435c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  virtual bool OKButtonTriggersUACPrompt() const;
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when the OK button is pressed. If this function returns true, the
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // infobar is then immediately closed. Subclasses MUST NOT return true if in
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // handling this call something triggers the infobar to begin closing.
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool Accept();
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when the Cancel button is pressed. If this function returns true,
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the infobar is then immediately closed. Subclasses MUST NOT return true if
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // in handling this call something triggers the infobar to begin closing.
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool Cancel();
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the text of the link to be displayed, if any. Otherwise returns
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and empty string.
57a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual base::string16 GetLinkText() const;
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when the Link (if any) is clicked. The |disposition| specifies how
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the resulting document should be loaded (based on the event flags present
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // when the link was clicked). If this function returns true, the infobar is
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // then immediately closed. Subclasses MUST NOT return true if in handling
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // this call something triggers the infobar to begin closing.
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool LinkClicked(WindowOpenDisposition disposition);
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected:
67a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  ConfirmInfoBarDelegate();
68a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
69a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Returns a confirm infobar that owns |delegate|.
700529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  static scoped_ptr<infobars::InfoBar> CreateInfoBar(
71a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      scoped_ptr<ConfirmInfoBarDelegate> delegate);
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool ShouldExpireInternal(
74c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch      const NavigationDetails& details) const OVERRIDE;
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // InfoBarDelegate:
780529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  virtual bool EqualsDelegate(
790529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch      infobars::InfoBarDelegate* delegate) const OVERRIDE;
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() OVERRIDE;
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate);
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif  // COMPONENTS_INFOBARS_CORE_CONFIRM_INFOBAR_DELEGATE_H_
86