| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 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" | 9 #include "chrome/browser/ui/views/infobars/infobar_view.h" |
| 11 #include "ui/views/controls/button/menu_button_listener.h" | 10 #include "ui/views/controls/button/menu_button_listener.h" |
| 12 | 11 |
| 13 class Browser; | 12 class Browser; |
| 13 class ExtensionInfoBarDelegate; |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 class ImageView; | 16 class ImageView; |
| 17 class MenuButton; | 17 class MenuButton; |
| 18 } | 18 } |
| 19 | 19 |
| 20 class ExtensionInfoBar : public InfoBarView, | 20 class ExtensionInfoBar : public InfoBarView, |
| 21 public ExtensionInfoBarDelegate::DelegateObserver, | |
| 22 public views::MenuButtonListener { | 21 public views::MenuButtonListener { |
| 23 public: | 22 public: |
| 24 ExtensionInfoBar(InfoBarService* owner, | 23 ExtensionInfoBar(scoped_ptr<ExtensionInfoBarDelegate> delegate, |
| 25 ExtensionInfoBarDelegate* delegate, | |
| 26 Browser* browser); | 24 Browser* browser); |
| 27 | 25 |
| 28 private: | 26 private: |
| 29 virtual ~ExtensionInfoBar(); | 27 virtual ~ExtensionInfoBar(); |
| 30 | 28 |
| 31 // InfoBarView: | 29 // InfoBarView: |
| 32 virtual void Layout() OVERRIDE; | 30 virtual void Layout() OVERRIDE; |
| 33 virtual void ViewHierarchyChanged( | 31 virtual void ViewHierarchyChanged( |
| 34 const ViewHierarchyChangedDetails& details) OVERRIDE; | 32 const ViewHierarchyChangedDetails& details) OVERRIDE; |
| 35 virtual int ContentMinimumWidth() const OVERRIDE; | 33 virtual int ContentMinimumWidth() const OVERRIDE; |
| 36 | 34 |
| 37 // ExtensionInfoBarDelegate::DelegateObserver: | |
| 38 virtual void OnDelegateDeleted() OVERRIDE; | |
| 39 | |
| 40 // views::MenuButtonListener: | 35 // views::MenuButtonListener: |
| 41 virtual void OnMenuButtonClicked(views::View* source, | 36 virtual void OnMenuButtonClicked(views::View* source, |
| 42 const gfx::Point& point) OVERRIDE; | 37 const gfx::Point& point) OVERRIDE; |
| 43 | 38 |
| 44 void OnImageLoaded(const gfx::Image& image); | 39 void OnImageLoaded(const gfx::Image& image); |
| 45 | 40 |
| 46 ExtensionInfoBarDelegate* GetDelegate(); | 41 ExtensionInfoBarDelegate* GetDelegate(); |
| 47 | 42 |
| 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_; | 43 Browser* browser_; |
| 54 | 44 |
| 55 // The infobar icon used for the extension infobar. The icon can be either a | 45 // 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 | 46 // plain image (in which case |icon_as_image_| is set) or a dropdown menu (in |
| 57 // which case |icon_as_menu_| is set). | 47 // which case |icon_as_menu_| is set). |
| 58 // The icon is a dropdown menu if the extension showing the infobar shows | 48 // The icon is a dropdown menu if the extension showing the infobar shows |
| 59 // configure context menus. | 49 // configure context menus. |
| 60 views::View* infobar_icon_; | 50 views::View* infobar_icon_; |
| 61 | 51 |
| 62 // The dropdown menu for accessing the contextual extension actions. | 52 // 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 | 53 // It is non-NULL if the |infobar_icon_| is a menu button and in that case |
| 64 // |icon_as_menu_ == infobar_icon_|. | 54 // |icon_as_menu_ == infobar_icon_|. |
| 65 views::MenuButton* icon_as_menu_; | 55 views::MenuButton* icon_as_menu_; |
| 66 | 56 |
| 67 // The image view for the icon. | 57 // The image view for the icon. |
| 68 // It is non-NULL if |infobar_icon_| is an image and in that case | 58 // It is non-NULL if |infobar_icon_| is an image and in that case |
| 69 // |icon_as_image_ == infobar_icon_|. | 59 // |icon_as_image_ == infobar_icon_|. |
| 70 views::ImageView* icon_as_image_; | 60 views::ImageView* icon_as_image_; |
| 71 | 61 |
| 72 base::WeakPtrFactory<ExtensionInfoBar> weak_ptr_factory_; | 62 base::WeakPtrFactory<ExtensionInfoBar> weak_ptr_factory_; |
| 73 | 63 |
| 74 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBar); | 64 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBar); |
| 75 }; | 65 }; |
| 76 | 66 |
| 77 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_ | 67 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_EXTENSION_INFOBAR_H_ |
| OLD | NEW |