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/ui/views/infobars/infobar_view.h" 10 #include "ui/views/controls/button/menu_button_listener.h" 11 12 class Browser; 13 class ExtensionInfoBarDelegate; 14 class ExtensionViewViews; 15 16 namespace views { 17 class ImageView; 18 class MenuButton; 19 } 20 21 class ExtensionInfoBar : public InfoBarView, 22 public views::MenuButtonListener { 23 public: 24 ExtensionInfoBar(scoped_ptr<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 // views::MenuButtonListener: 37 virtual void OnMenuButtonClicked(views::View* source, 38 const gfx::Point& point) OVERRIDE; 39 40 void OnImageLoaded(const gfx::Image& image); 41 ExtensionInfoBarDelegate* GetDelegate(); 42 const ExtensionInfoBarDelegate* GetDelegate() const; 43 ExtensionViewViews* GetExtensionView(); 44 45 // Returns the width of all content other than the extension view. Layout() 46 // uses this to determine how much space the extension view can take. 47 int NonExtensionViewWidth() const; 48 49 Browser* browser_; 50 51 // The infobar icon used for the extension infobar. The icon can be either a 52 // plain image (in which case |icon_as_image_| is set) or a dropdown menu (in 53 // which case |icon_as_menu_| is set). 54 // The icon is a dropdown menu if the extension showing the infobar shows 55 // configure context menus. 56 views::View* infobar_icon_; 57 58 // The dropdown menu for accessing the contextual extension actions. 59 // It is non-NULL if the |infobar_icon_| is a menu button and in that case 60 // |icon_as_menu_ == infobar_icon_|. 61 views::MenuButton* icon_as_menu_; 62 63 // The image view for the icon. 64 // It is non-NULL if |infobar_icon_| is an image and in that case 65 // |icon_as_image_ == infobar_icon_|. 66 views::ImageView* icon_as_image_; 67 68 base::WeakPtrFactory<ExtensionInfoBar> weak_ptr_factory_; 69 70 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBar); 71 }; 72 73 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_ 74