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