Home | History | Annotate | Download | only in infobars
      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.
      4 
      5 #ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_
      6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_
      7 
      8 #include "base/compiler_specific.h"
      9 #include "chrome/browser/extensions/extension_infobar_delegate.h"
     10 #include "chrome/browser/ui/views/infobars/infobar_view.h"
     11 #include "ui/views/controls/button/menu_button_listener.h"
     12 
     13 class Browser;
     14 namespace views {
     15 class ImageView;
     16 class MenuButton;
     17 }
     18 
     19 class ExtensionInfoBar : public InfoBarView,
     20                          public ExtensionInfoBarDelegate::DelegateObserver,
     21                          public views::MenuButtonListener {
     22  public:
     23   ExtensionInfoBar(InfoBarService* owner,
     24                    ExtensionInfoBarDelegate* delegate,
     25                    Browser* browser);
     26 
     27  private:
     28   virtual ~ExtensionInfoBar();
     29 
     30   // InfoBarView:
     31   virtual void Layout() OVERRIDE;
     32   virtual void ViewHierarchyChanged(
     33       const ViewHierarchyChangedDetails& details) OVERRIDE;
     34   virtual int ContentMinimumWidth() const OVERRIDE;
     35 
     36   // ExtensionInfoBarDelegate::DelegateObserver:
     37   virtual void OnDelegateDeleted() OVERRIDE;
     38 
     39   // views::MenuButtonListener:
     40   virtual void OnMenuButtonClicked(views::View* source,
     41                                    const gfx::Point& point) OVERRIDE;
     42 
     43   void OnImageLoaded(const gfx::Image& image);
     44 
     45   ExtensionInfoBarDelegate* GetDelegate();
     46 
     47   // TODO(pkasting): This shadows InfoBarView::delegate_.  Get rid of this once
     48   // InfoBars own their delegates (and thus we don't need the DelegateObserver
     49   // functionality).  For now, almost everyone should use GetDelegate() instead.
     50   InfoBarDelegate* delegate_;
     51 
     52   Browser* browser_;
     53 
     54   // The infobar icon used for the extension infobar. The icon can be either a
     55   // plain image (in which case |icon_as_image_| is set) or a dropdown menu (in
     56   // which case |icon_as_menu_| is set).
     57   // The icon is a dropdown menu if the extension showing the infobar shows
     58   // configure context menus.
     59   views::View* infobar_icon_;
     60 
     61   // The dropdown menu for accessing the contextual extension actions.
     62   // It is non-NULL if the |infobar_icon_| is a menu button and in that case
     63   // |icon_as_menu_ == infobar_icon_|.
     64   views::MenuButton* icon_as_menu_;
     65 
     66   // The image view for the icon.
     67   // It is non-NULL if |infobar_icon_| is an image and in that case
     68   // |icon_as_image_ == infobar_icon_|.
     69   views::ImageView* icon_as_image_;
     70 
     71   base::WeakPtrFactory<ExtensionInfoBar> weak_ptr_factory_;
     72 
     73   DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBar);
     74 };
     75 
     76 #endif  // CHROME_BROWSER_UI_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_
     77