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