Home | History | Annotate | Download | only in tab_contents
      1 // 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"
     12 #include "chrome/browser/tab_contents/infobar_delegate.h"
     13 
     14 // An interface derived from InfoBarDelegate implemented by objects wishing to
     15 // control a ConfirmInfoBar.
     16 class 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 
     37   // Called when the OK button is pressed. If the function returns true, the
     38   // InfoBarDelegate should be removed from the associated TabContents.
     39   virtual bool Accept();
     40 
     41   // Called when the Cancel button is pressed.  If the function returns true,
     42   // the InfoBarDelegate should be removed from the associated TabContents.
     43   virtual bool Cancel();
     44 
     45   // Returns the text of the link to be displayed, if any. Otherwise returns
     46   // and empty string.
     47   virtual string16 GetLinkText();
     48 
     49   // Called when the Link is clicked. The |disposition| specifies how the
     50   // resulting document should be loaded (based on the event flags present when
     51   // the link was clicked). This function returns true if the InfoBar should be
     52   // closed now or false if it should remain until the user explicitly closes
     53   // it.
     54   // Will only be called if GetLinkText() returns non-empty string.
     55   virtual bool LinkClicked(WindowOpenDisposition disposition);
     56 
     57  protected:
     58   explicit ConfirmInfoBarDelegate(TabContents* contents);
     59   virtual ~ConfirmInfoBarDelegate();
     60 
     61  private:
     62   // InfoBarDelegate:
     63   virtual InfoBar* CreateInfoBar() OVERRIDE;
     64   virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE;
     65   virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate() OVERRIDE;
     66 
     67   DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBarDelegate);
     68 };
     69 
     70 #endif  // CHROME_BROWSER_TAB_CONTENTS_CONFIRM_INFOBAR_DELEGATE_H_
     71