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

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

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years 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) 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_GTK_INFOBARS_INFOBAR_GTK_H_ 5 #ifndef CHROME_BROWSER_UI_GTK_INFOBARS_INFOBAR_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_INFOBARS_INFOBAR_GTK_H_ 6 #define CHROME_BROWSER_UI_GTK_INFOBARS_INFOBAR_GTK_H_
7 7
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 15 matching lines...) Expand all
26 class MenuModel; 26 class MenuModel;
27 } 27 }
28 28
29 class InfoBarGtk : public InfoBar, 29 class InfoBarGtk : public InfoBar,
30 public content::NotificationObserver { 30 public content::NotificationObserver {
31 public: 31 public:
32 // Conversion from cairo colors to SkColor. 32 // Conversion from cairo colors to SkColor.
33 typedef void (InfoBarGtk::*ColorGetter)(InfoBarDelegate::Type, 33 typedef void (InfoBarGtk::*ColorGetter)(InfoBarDelegate::Type,
34 double* r, double* g, double* b); 34 double* r, double* g, double* b);
35 35
36 InfoBarGtk(InfoBarService* owner, InfoBarDelegate* delegate); 36 explicit InfoBarGtk(scoped_ptr<InfoBarDelegate> delegate);
37 virtual ~InfoBarGtk(); 37 virtual ~InfoBarGtk();
38 38
39 // Must be called before we try to show the infobar. Inits any widgets and
40 // related objects necessary. This must be called only once during the
41 // infobar's life.
42 //
43 // NOTE: Subclasses who need to init widgets should override this function and
44 // explicitly call their parent's implementation first, then continue with
45 // further work they need to do. Failing to call the parent implementation
46 // first (or at all), or setting up widgets in the constructor instead of
47 // here, will lead to bad side effects like crashing or having this function
48 // get called repeatedly.
49 virtual void InitWidgets();
50
51 // Get the top level native GTK widget for this infobar. 39 // Get the top level native GTK widget for this infobar.
52 GtkWidget* widget() { return widget_.get(); } 40 GtkWidget* widget() { return widget_.get(); }
53 41
54 GdkColor GetBorderColor() const; 42 GdkColor GetBorderColor() const;
55 43
56 // Returns the target height of the infobar if the bar is animating, 44 // Returns the target height of the infobar if the bar is animating,
57 // otherwise 0. We care about this number since we want to prevent 45 // otherwise 0. We care about this number since we want to prevent
58 // unnecessary renderer repaints while animating. 46 // unnecessary renderer repaints while animating.
59 int AnimatingHeight() const; 47 int AnimatingHeight() const;
60 48
61 SkColor ConvertGetColor(ColorGetter getter); 49 SkColor ConvertGetColor(ColorGetter getter);
62 50
63 // Retrieves the component colors for the infobar's background 51 // Retrieves the component colors for the infobar's background
64 // gradient. (This varies by infobars and can be animated to change). 52 // gradient. (This varies by infobars and can be animated to change).
65 virtual void GetTopColor(InfoBarDelegate::Type type, 53 virtual void GetTopColor(InfoBarDelegate::Type type,
66 double* r, double* g, double* b); 54 double* r, double* g, double* b);
67 virtual void GetBottomColor(InfoBarDelegate::Type type, 55 virtual void GetBottomColor(InfoBarDelegate::Type type,
68 double* r, double* g, double* b); 56 double* r, double* g, double* b);
69 57
70 protected: 58 protected:
71 // Spacing after message (and before buttons). 59 // Spacing after message (and before buttons).
72 static const int kEndOfLabelSpacing; 60 static const int kEndOfLabelSpacing;
73 61
74 // InfoBar: 62 // InfoBar:
63
64 // Inits any widgets and related objects necessary.
65 //
66 // NOTE: Subclasses who need to init widgets should override this function and
67 // explicitly call their parent's implementation first, then continue with
68 // further work they need to do. Failing to call the parent implementation
69 // first (or at all), or setting up widgets in the constructor instead of
70 // here, will lead to bad side effects like crashing.
71 virtual void PlatformSpecificSetOwner() OVERRIDE;
72
75 virtual void PlatformSpecificShow(bool animate) OVERRIDE; 73 virtual void PlatformSpecificShow(bool animate) OVERRIDE;
76 virtual void PlatformSpecificOnCloseSoon() OVERRIDE; 74 virtual void PlatformSpecificOnCloseSoon() OVERRIDE;
77 virtual void PlatformSpecificOnHeightsRecalculated() OVERRIDE; 75 virtual void PlatformSpecificOnHeightsRecalculated() OVERRIDE;
78 76
79 // content::NotificationObserver: 77 // content::NotificationObserver:
80 virtual void Observe(int type, 78 virtual void Observe(int type,
81 const content::NotificationSource& source, 79 const content::NotificationSource& source,
82 const content::NotificationDetails& details) OVERRIDE; 80 const content::NotificationDetails& details) OVERRIDE;
83 81
84 // Styles the close button as if we're doing Chrome-stlye widget rendering. 82 // Styles the close button as if we're doing Chrome-stlye widget rendering.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 scoped_ptr<ui::GtkSignalRegistrar> signals_; 146 scoped_ptr<ui::GtkSignalRegistrar> signals_;
149 147
150 // The current menu displayed. Can be null. We own this on the base class so 148 // The current menu displayed. Can be null. We own this on the base class so
151 // we can cancel the menu while we're closing. 149 // we can cancel the menu while we're closing.
152 scoped_ptr<MenuGtk> menu_; 150 scoped_ptr<MenuGtk> menu_;
153 151
154 DISALLOW_COPY_AND_ASSIGN(InfoBarGtk); 152 DISALLOW_COPY_AND_ASSIGN(InfoBarGtk);
155 }; 153 };
156 154
157 #endif // CHROME_BROWSER_UI_GTK_INFOBARS_INFOBAR_GTK_H_ 155 #endif // CHROME_BROWSER_UI_GTK_INFOBARS_INFOBAR_GTK_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc ('k') | chrome/browser/ui/gtk/infobars/infobar_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698