Home | History | Annotate | Download | only in infobars
      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_UI_GTK_INFOBARS_INFOBAR_CONTAINER_GTK_H_
      6 #define CHROME_BROWSER_UI_GTK_INFOBARS_INFOBAR_CONTAINER_GTK_H_
      7 #pragma once
      8 
      9 #include "base/basictypes.h"
     10 #include "chrome/browser/ui/gtk/owned_widget_gtk.h"
     11 #include "content/common/notification_observer.h"
     12 #include "content/common/notification_registrar.h"
     13 
     14 class InfoBar;
     15 class InfoBarDelegate;
     16 class Profile;
     17 class TabContents;
     18 
     19 typedef struct _GtkWidget GtkWidget;
     20 
     21 class InfoBarContainerGtk : public NotificationObserver {
     22  public:
     23   explicit InfoBarContainerGtk(Profile* profile);
     24   virtual ~InfoBarContainerGtk();
     25 
     26   // Get the native widget.
     27   GtkWidget* widget() const { return container_.get(); }
     28 
     29   // Changes the TabContents for which this container is showing InfoBars. Can
     30   // be NULL, in which case we will simply detach ourselves from the old tab
     31   // contents.
     32   void ChangeTabContents(TabContents* contents);
     33 
     34   // Remove the specified InfoBarDelegate from the selected TabContents. This
     35   // will notify us back and cause us to close the View. This is called from
     36   // the InfoBar's close button handler.
     37   void RemoveDelegate(InfoBarDelegate* delegate);
     38 
     39   // Returns the total pixel height of all infobars in this container that
     40   // are currently animating.
     41   int TotalHeightOfAnimatingBars() const;
     42 
     43  private:
     44   // Overridden from NotificationObserver:
     45   virtual void Observe(NotificationType type,
     46                        const NotificationSource& source,
     47                        const NotificationDetails& details);
     48 
     49   // Constructs the InfoBars needed to reflect the state of the current
     50   // TabContents associated with this container. No animations are run during
     51   // this process.
     52   void UpdateInfoBars();
     53 
     54   // Makes the calls to show an arrow for |delegate| (either on the browser
     55   // toolbar or on the next infobar up).
     56   void ShowArrowForDelegate(InfoBarDelegate* delegate, bool animate);
     57 
     58   // Adds an InfoBar for the specified delegate, in response to a notification
     59   // from the selected TabContents.
     60   void AddInfoBar(InfoBarDelegate* delegate, bool animate);
     61 
     62   // Removes an InfoBar for the specified delegate, in response to a
     63   // notification from the selected TabContents. The InfoBar's disappearance
     64   // will be animated.
     65   void RemoveInfoBar(InfoBarDelegate* delegate, bool animate);
     66 
     67   // Tells the browser window about our state so it can draw the arrow
     68   // appropriately.
     69   void UpdateToolbarInfoBarState(InfoBar* infobar, bool animate);
     70 
     71   NotificationRegistrar registrar_;
     72 
     73   // The profile for the browser that hosts this InfoBarContainer.
     74   Profile* profile_;
     75 
     76   // The TabContents for which we are currently showing InfoBars.
     77   TabContents* tab_contents_;
     78 
     79   // VBox that holds the info bars.
     80   OwnedWidgetGtk container_;
     81 
     82   DISALLOW_COPY_AND_ASSIGN(InfoBarContainerGtk);
     83 };
     84 
     85 #endif  // CHROME_BROWSER_UI_GTK_INFOBARS_INFOBAR_CONTAINER_GTK_H_
     86