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.
5 #ifndef CHROME_BROWSER_UI_GTK_INFOBARS_EXTENSION_INFOBAR_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_INFOBARS_EXTENSION_INFOBAR_GTK_H_
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"
15 class ExtensionContextMenuModel;
16 class ExtensionViewGtk;
19 class ExtensionInfoBarGtk : public InfoBarGtk, public MenuGtk::Delegate {
21 explicit ExtensionInfoBarGtk(scoped_ptr<ExtensionInfoBarDelegate> delegate);
24 virtual ~ExtensionInfoBarGtk();
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;
35 virtual void StoppedShowing() OVERRIDE;
37 void OnImageLoaded(const gfx::Image& image);
39 ExtensionInfoBarDelegate* GetDelegate();
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();
45 // Returns the context menu model for this extension. Can be NULL if
46 // extension context menus are disabled.
47 ExtensionContextMenuModel* BuildMenuModel();
49 CHROMEGTK_CALLBACK_1(ExtensionInfoBarGtk, void, OnSizeAllocate,
52 CHROMEGTK_CALLBACK_1(ExtensionInfoBarGtk, gboolean, OnButtonPress,
55 CHROMEGTK_CALLBACK_1(ExtensionInfoBarGtk, gboolean, OnExpose,
58 ExtensionViewGtk* view_;
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_|.
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().
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_;
76 // The model for the current menu displayed.
77 scoped_refptr<ExtensionContextMenuModel> context_menu_model_;
79 base::WeakPtrFactory<ExtensionInfoBarGtk> weak_ptr_factory_;
81 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarGtk);
84 #endif // CHROME_BROWSER_UI_GTK_INFOBARS_EXTENSION_INFOBAR_GTK_H_