| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_GTK_INFOBARS_EXTENSION_INFOBAR_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_INFOBARS_EXTENSION_INFOBAR_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_INFOBARS_EXTENSION_INFOBAR_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_INFOBARS_EXTENSION_INFOBAR_GTK_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/extensions/extension_infobar_delegate.h" |
| 10 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" | 10 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" |
| 11 #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h" | 11 #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h" |
| 12 #include "chrome/browser/ui/gtk/menu_gtk.h" | 12 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 13 #include "ui/gfx/gtk_util.h" | 13 #include "ui/gfx/gtk_util.h" |
| 14 | 14 |
| 15 class ExtensionContextMenuModel; | 15 class ExtensionContextMenuModel; |
| 16 class ExtensionViewGtk; | 16 class ExtensionViewGtk; |
| 17 class MenuGtk; | 17 class MenuGtk; |
| 18 | 18 |
| 19 class ExtensionInfoBarGtk : public InfoBarGtk, | 19 class ExtensionInfoBarGtk : public InfoBarGtk, public MenuGtk::Delegate { |
| 20 public MenuGtk::Delegate, | |
| 21 public ExtensionInfoBarDelegate::DelegateObserver { | |
| 22 public: | 20 public: |
| 23 ExtensionInfoBarGtk(InfoBarService* owner, | 21 explicit ExtensionInfoBarGtk(scoped_ptr<ExtensionInfoBarDelegate> delegate); |
| 24 ExtensionInfoBarDelegate* delegate); | |
| 25 | 22 |
| 26 private: | 23 private: |
| 27 virtual ~ExtensionInfoBarGtk(); | 24 virtual ~ExtensionInfoBarGtk(); |
| 28 | 25 |
| 29 // InfoBarGtk: | 26 // InfoBarGtk: |
| 27 virtual void PlatformSpecificSetOwner() OVERRIDE; |
| 30 virtual void PlatformSpecificHide(bool animate) OVERRIDE; | 28 virtual void PlatformSpecificHide(bool animate) OVERRIDE; |
| 31 virtual void GetTopColor(InfoBarDelegate::Type type, | 29 virtual void GetTopColor(InfoBarDelegate::Type type, |
| 32 double* r, double* g, double* b) OVERRIDE; | 30 double* r, double* g, double* b) OVERRIDE; |
| 33 virtual void GetBottomColor(InfoBarDelegate::Type type, | 31 virtual void GetBottomColor(InfoBarDelegate::Type type, |
| 34 double* r, double* g, double* b) OVERRIDE; | 32 double* r, double* g, double* b) OVERRIDE; |
| 35 virtual void InitWidgets() OVERRIDE; | |
| 36 | 33 |
| 37 // MenuGtk::Delegate: | 34 // MenuGtk::Delegate: |
| 38 virtual void StoppedShowing() OVERRIDE; | 35 virtual void StoppedShowing() OVERRIDE; |
| 39 | 36 |
| 40 // ExtensionInfoBarDelegate::DelegateObserver: | |
| 41 virtual void OnDelegateDeleted() OVERRIDE; | |
| 42 | |
| 43 void OnImageLoaded(const gfx::Image& image); | 37 void OnImageLoaded(const gfx::Image& image); |
| 44 | 38 |
| 45 ExtensionInfoBarDelegate* GetDelegate(); | 39 ExtensionInfoBarDelegate* GetDelegate(); |
| 46 | 40 |
| 47 // Looks at the window the infobar is in and gets the browser. Can return | 41 // Looks at the window the infobar is in and gets the browser. Can return |
| 48 // NULL if we aren't attached. | 42 // NULL if we aren't attached. |
| 49 Browser* GetBrowser(); | 43 Browser* GetBrowser(); |
| 50 | 44 |
| 51 // Returns the context menu model for this extension. Can be NULL if | 45 // Returns the context menu model for this extension. Can be NULL if |
| 52 // extension context menus are disabled. | 46 // extension context menus are disabled. |
| 53 ExtensionContextMenuModel* BuildMenuModel(); | 47 ExtensionContextMenuModel* BuildMenuModel(); |
| 54 | 48 |
| 55 CHROMEGTK_CALLBACK_1(ExtensionInfoBarGtk, void, OnSizeAllocate, | 49 CHROMEGTK_CALLBACK_1(ExtensionInfoBarGtk, void, OnSizeAllocate, |
| 56 GtkAllocation*); | 50 GtkAllocation*); |
| 57 | 51 |
| 58 CHROMEGTK_CALLBACK_1(ExtensionInfoBarGtk, gboolean, OnButtonPress, | 52 CHROMEGTK_CALLBACK_1(ExtensionInfoBarGtk, gboolean, OnButtonPress, |
| 59 GdkEventButton*); | 53 GdkEventButton*); |
| 60 | 54 |
| 61 CHROMEGTK_CALLBACK_1(ExtensionInfoBarGtk, gboolean, OnExpose, | 55 CHROMEGTK_CALLBACK_1(ExtensionInfoBarGtk, gboolean, OnExpose, |
| 62 GdkEventExpose*); | 56 GdkEventExpose*); |
| 63 | 57 |
| 64 // TODO(pkasting): This shadows InfoBarView::delegate_. Get rid of this once | |
| 65 // InfoBars own their delegates (and thus we don't need the DelegateObserver | |
| 66 // functionality). For now, almost everyone should use GetDelegate() instead. | |
| 67 InfoBarDelegate* delegate_; | |
| 68 | |
| 69 ExtensionViewGtk* view_; | 58 ExtensionViewGtk* view_; |
| 70 | 59 |
| 71 // The button that activates the extension popup menu. Non-NULL if the | 60 // The button that activates the extension popup menu. Non-NULL if the |
| 72 // extension shows configure context menus and a dropdown menu should be used | 61 // extension shows configure context menus and a dropdown menu should be used |
| 73 // in place of the icon. If set, parents |icon_|. | 62 // in place of the icon. If set, parents |icon_|. |
| 74 GtkWidget* button_; | 63 GtkWidget* button_; |
| 75 | 64 |
| 76 // The GtkImage that shows the extension icon. If a dropdown menu should be | 65 // The GtkImage that shows the extension icon. If a dropdown menu should be |
| 77 // used, it's put inside |button_|, otherwise it's put directly in the hbox | 66 // used, it's put inside |button_|, otherwise it's put directly in the hbox |
| 78 // containing the infobar element. Composed in OnImageLoaded(). | 67 // containing the infobar element. Composed in OnImageLoaded(). |
| 79 GtkWidget* icon_; | 68 GtkWidget* icon_; |
| 80 | 69 |
| 81 // An alignment with one pixel of bottom padding. This is set so the |view_| | 70 // An alignment with one pixel of bottom padding. This is set so the |view_| |
| 82 // doesn't overlap the bottom separator. This also makes it more convenient | 71 // doesn't overlap the bottom separator. This also makes it more convenient |
| 83 // to reattach the view since the alignment_ will have the |hbox_| packing | 72 // to reattach the view since the alignment_ will have the |hbox_| packing |
| 84 // child properties. Reparenting becomes easier too. | 73 // child properties. Reparenting becomes easier too. |
| 85 GtkWidget* alignment_; | 74 GtkWidget* alignment_; |
| 86 | 75 |
| 87 // The model for the current menu displayed. | 76 // The model for the current menu displayed. |
| 88 scoped_refptr<ExtensionContextMenuModel> context_menu_model_; | 77 scoped_refptr<ExtensionContextMenuModel> context_menu_model_; |
| 89 | 78 |
| 90 base::WeakPtrFactory<ExtensionInfoBarGtk> weak_ptr_factory_; | 79 base::WeakPtrFactory<ExtensionInfoBarGtk> weak_ptr_factory_; |
| 91 | 80 |
| 92 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarGtk); | 81 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarGtk); |
| 93 }; | 82 }; |
| 94 | 83 |
| 95 #endif // CHROME_BROWSER_UI_GTK_INFOBARS_EXTENSION_INFOBAR_GTK_H_ | 84 #endif // CHROME_BROWSER_UI_GTK_INFOBARS_EXTENSION_INFOBAR_GTK_H_ |
| OLD | NEW |