OLD | NEW |
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 Loading... |
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 explicit InfoBarGtk(scoped_ptr<InfoBarDelegate> delegate); | 36 InfoBarGtk(InfoBarService* owner, 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 |
39 // Get the top level native GTK widget for this infobar. | 51 // Get the top level native GTK widget for this infobar. |
40 GtkWidget* widget() { return widget_.get(); } | 52 GtkWidget* widget() { return widget_.get(); } |
41 | 53 |
42 GdkColor GetBorderColor() const; | 54 GdkColor GetBorderColor() const; |
43 | 55 |
44 // Returns the target height of the infobar if the bar is animating, | 56 // Returns the target height of the infobar if the bar is animating, |
45 // otherwise 0. We care about this number since we want to prevent | 57 // otherwise 0. We care about this number since we want to prevent |
46 // unnecessary renderer repaints while animating. | 58 // unnecessary renderer repaints while animating. |
47 int AnimatingHeight() const; | 59 int AnimatingHeight() const; |
48 | 60 |
49 SkColor ConvertGetColor(ColorGetter getter); | 61 SkColor ConvertGetColor(ColorGetter getter); |
50 | 62 |
51 // Retrieves the component colors for the infobar's background | 63 // Retrieves the component colors for the infobar's background |
52 // gradient. (This varies by infobars and can be animated to change). | 64 // gradient. (This varies by infobars and can be animated to change). |
53 virtual void GetTopColor(InfoBarDelegate::Type type, | 65 virtual void GetTopColor(InfoBarDelegate::Type type, |
54 double* r, double* g, double* b); | 66 double* r, double* g, double* b); |
55 virtual void GetBottomColor(InfoBarDelegate::Type type, | 67 virtual void GetBottomColor(InfoBarDelegate::Type type, |
56 double* r, double* g, double* b); | 68 double* r, double* g, double* b); |
57 | 69 |
58 protected: | 70 protected: |
59 // Spacing after message (and before buttons). | 71 // Spacing after message (and before buttons). |
60 static const int kEndOfLabelSpacing; | 72 static const int kEndOfLabelSpacing; |
61 | 73 |
62 // InfoBar: | 74 // 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 | |
73 virtual void PlatformSpecificShow(bool animate) OVERRIDE; | 75 virtual void PlatformSpecificShow(bool animate) OVERRIDE; |
74 virtual void PlatformSpecificOnCloseSoon() OVERRIDE; | 76 virtual void PlatformSpecificOnCloseSoon() OVERRIDE; |
75 virtual void PlatformSpecificOnHeightsRecalculated() OVERRIDE; | 77 virtual void PlatformSpecificOnHeightsRecalculated() OVERRIDE; |
76 | 78 |
77 // content::NotificationObserver: | 79 // content::NotificationObserver: |
78 virtual void Observe(int type, | 80 virtual void Observe(int type, |
79 const content::NotificationSource& source, | 81 const content::NotificationSource& source, |
80 const content::NotificationDetails& details) OVERRIDE; | 82 const content::NotificationDetails& details) OVERRIDE; |
81 | 83 |
82 // Styles the close button as if we're doing Chrome-stlye widget rendering. | 84 // 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 Loading... |
146 scoped_ptr<ui::GtkSignalRegistrar> signals_; | 148 scoped_ptr<ui::GtkSignalRegistrar> signals_; |
147 | 149 |
148 // The current menu displayed. Can be null. We own this on the base class so | 150 // The current menu displayed. Can be null. We own this on the base class so |
149 // we can cancel the menu while we're closing. | 151 // we can cancel the menu while we're closing. |
150 scoped_ptr<MenuGtk> menu_; | 152 scoped_ptr<MenuGtk> menu_; |
151 | 153 |
152 DISALLOW_COPY_AND_ASSIGN(InfoBarGtk); | 154 DISALLOW_COPY_AND_ASSIGN(InfoBarGtk); |
153 }; | 155 }; |
154 | 156 |
155 #endif // CHROME_BROWSER_UI_GTK_INFOBARS_INFOBAR_GTK_H_ | 157 #endif // CHROME_BROWSER_UI_GTK_INFOBARS_INFOBAR_GTK_H_ |
OLD | NEW |