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