Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h

Issue 7809007: GTK: Clean up the gtk extension infobar implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include "chrome/browser/extensions/extension_infobar_delegate.h" 9 #include "chrome/browser/extensions/extension_infobar_delegate.h"
10 #include "chrome/browser/extensions/image_loading_tracker.h" 10 #include "chrome/browser/extensions/image_loading_tracker.h"
11 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" 11 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h"
12 #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h" 12 #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h"
13 #include "chrome/browser/ui/gtk/menu_gtk.h"
14 #include "ui/base/gtk/gtk_signal_registrar.h"
13 #include "ui/gfx/gtk_util.h" 15 #include "ui/gfx/gtk_util.h"
14 16
17 class ExtensionContextMenuModel;
15 class ExtensionInfobarDelegate; 18 class ExtensionInfobarDelegate;
16 class ExtensionResource; 19 class ExtensionResource;
17 class ExtensionViewGtk; 20 class ExtensionViewGtk;
21 class MenuGtk;
18 22
19 class ExtensionInfoBarGtk : public InfoBarGtk, 23 class ExtensionInfoBarGtk : public InfoBarGtk,
20 public ImageLoadingTracker::Observer { 24 public ImageLoadingTracker::Observer,
25 public MenuGtk::Delegate {
21 public: 26 public:
22 ExtensionInfoBarGtk(TabContentsWrapper* owner, 27 ExtensionInfoBarGtk(TabContentsWrapper* owner,
23 ExtensionInfoBarDelegate* delegate); 28 ExtensionInfoBarDelegate* delegate);
24 virtual ~ExtensionInfoBarGtk(); 29 virtual ~ExtensionInfoBarGtk();
25 30
31 // Overridden from InfoBar (through InfoBarGtk):
32 virtual void PlatformSpecificHide(bool animate);
33
34 // Overridden from InfoBarGtk:
35 virtual void GetTopColor(InfoBarDelegate::Type type,
36 double* r, double* g, double *b);
37 virtual void GetBottomColor(InfoBarDelegate::Type type,
38 double* r, double* g, double *b);
39
26 // Overridden from ImageLoadingTracker::Observer: 40 // Overridden from ImageLoadingTracker::Observer:
27 virtual void OnImageLoaded( 41 virtual void OnImageLoaded(
28 SkBitmap* image, const ExtensionResource& resource, int index); 42 SkBitmap* image, const ExtensionResource& resource, int index);
29 43
44 // Overridden from MenuGtk::Delegate:
45 virtual void StoppedShowing();
46
30 private: 47 private:
31 // Build the widgets of the Infobar. 48 // Build the widgets of the Infobar.
32 void BuildWidgets(); 49 void BuildWidgets();
33 50
51 // Looks at the window the infobar is in and gets the browser. Can return
52 // NULL if we aren't attached.
53 Browser* GetBrowser();
54
55 // Returns the context menu for this extension. Can be NULL if extension
56 // context menus are disabled.
57 MenuGtk* BuildContextMenu();
58
34 CHROMEGTK_CALLBACK_1(ExtensionInfoBarGtk, void, OnSizeAllocate, 59 CHROMEGTK_CALLBACK_1(ExtensionInfoBarGtk, void, OnSizeAllocate,
35 GtkAllocation*); 60 GtkAllocation*);
36 61
62 CHROMEGTK_CALLBACK_1(ExtensionInfoBarGtk, gboolean, OnButtonPress,
63 GdkEventButton*);
64
37 ImageLoadingTracker tracker_; 65 ImageLoadingTracker tracker_;
38 66
39 ExtensionInfoBarDelegate* delegate_; 67 ExtensionInfoBarDelegate* delegate_;
40 68
41 ExtensionViewGtk* view_; 69 ExtensionViewGtk* view_;
42 70
71 // The button that activates the extension popup menu. Parent of |icon_|.
72 GtkWidget* button_;
73
74 // The GtkImage that is inside of |button_|, composed in OnImageLoaded().
75 GtkWidget* icon_;
76
77 // An alignment with one pixel of bottom padding. This is set so the |view_|
78 // doesn't overlap the bottom separator. This also makes it more convenient
79 // to reattach the view since the alignment_ will have the |hbox_| packing
80 // child properties. Reparenting becomes easier too.
81 GtkWidget* alignment_;
82
83 // We connect to signals on a gtk object that we only hold a weak reference
84 // to which outlives us.
85 ui::GtkSignalRegistrar signals_;
86
87 // The context menu view and model for this extension action.
Evan Stade 2011/08/31 20:00:12 I don't think it's technically a context menu unle
88 scoped_ptr<MenuGtk> context_menu_;
89 scoped_refptr<ExtensionContextMenuModel> context_menu_model_;
90
43 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarGtk); 91 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarGtk);
44 }; 92 };
45 93
46 #endif // CHROME_BROWSER_UI_GTK_INFOBARS_EXTENSION_INFOBAR_GTK_H_ 94 #endif // CHROME_BROWSER_UI_GTK_INFOBARS_EXTENSION_INFOBAR_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698