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

Unified Diff: chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc
===================================================================
--- chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc (revision 238220)
+++ chrome/browser/ui/gtk/infobars/extension_infobar_gtk.cc (working copy)
@@ -31,53 +31,33 @@
// ExtensionInfoBarDelegate ---------------------------------------------------
-InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
- return new ExtensionInfoBarGtk(owner, this);
+// static
+scoped_ptr<InfoBar> ExtensionInfoBarDelegate::CreateInfoBar(
+ scoped_ptr<ExtensionInfoBarDelegate> delegate) {
+ return scoped_ptr<InfoBar>(new ExtensionInfoBarGtk(delegate.Pass()));
}
// ExtensionInfoBarGtk --------------------------------------------------------
-ExtensionInfoBarGtk::ExtensionInfoBarGtk(InfoBarService* owner,
- ExtensionInfoBarDelegate* delegate)
- : InfoBarGtk(owner, delegate),
- delegate_(delegate),
+ExtensionInfoBarGtk::ExtensionInfoBarGtk(
+ scoped_ptr<ExtensionInfoBarDelegate> delegate)
+ : InfoBarGtk(delegate.PassAs<InfoBarDelegate>()),
view_(NULL),
button_(NULL),
icon_(NULL),
alignment_(NULL),
weak_ptr_factory_(this) {
- GetDelegate()->set_observer(this);
-
int height = GetDelegate()->height();
SetBarTargetHeight((height > 0) ? (height + kSeparatorLineHeight) : 0);
}
ExtensionInfoBarGtk::~ExtensionInfoBarGtk() {
- if (GetDelegate())
- GetDelegate()->set_observer(NULL);
}
-void ExtensionInfoBarGtk::PlatformSpecificHide(bool animate) {
- DCHECK(view_);
- DCHECK(alignment_);
- gtk_util::RemoveAllChildren(alignment_);
-}
+void ExtensionInfoBarGtk::PlatformSpecificSetOwner() {
+ InfoBarGtk::PlatformSpecificSetOwner();
-void ExtensionInfoBarGtk::GetTopColor(InfoBarDelegate::Type type,
- double* r, double* g, double* b) {
- // Extension infobars are always drawn with chrome-theme colors.
- *r = *g = *b = 233.0 / 255.0;
-}
-
-void ExtensionInfoBarGtk::GetBottomColor(InfoBarDelegate::Type type,
- double* r, double* g, double* b) {
- *r = *g = *b = 218.0 / 255.0;
-}
-
-void ExtensionInfoBarGtk::InitWidgets() {
- InfoBarGtk::InitWidgets();
-
// Always render the close button as if we were doing chrome style widget
// rendering. For extension infobars, we force chrome style rendering because
// extension authors are going to expect to match the declared gradient in
@@ -142,15 +122,28 @@
G_CALLBACK(&OnSizeAllocateThunk), this);
}
+void ExtensionInfoBarGtk::PlatformSpecificHide(bool animate) {
+ DCHECK(view_);
+ DCHECK(alignment_);
+ gtk_util::RemoveAllChildren(alignment_);
+}
+
+void ExtensionInfoBarGtk::GetTopColor(InfoBarDelegate::Type type,
+ double* r, double* g, double* b) {
+ // Extension infobars are always drawn with chrome-theme colors.
+ *r = *g = *b = 233.0 / 255.0;
+}
+
+void ExtensionInfoBarGtk::GetBottomColor(InfoBarDelegate::Type type,
+ double* r, double* g, double* b) {
+ *r = *g = *b = 218.0 / 255.0;
+}
+
void ExtensionInfoBarGtk::StoppedShowing() {
if (button_)
gtk_chrome_button_unset_paint_state(GTK_CHROME_BUTTON(button_));
}
-void ExtensionInfoBarGtk::OnDelegateDeleted() {
- delegate_ = NULL;
-}
-
void ExtensionInfoBarGtk::OnImageLoaded(const gfx::Image& image) {
DCHECK(icon_);
@@ -188,7 +181,7 @@
}
ExtensionInfoBarDelegate* ExtensionInfoBarGtk::GetDelegate() {
- return delegate_ ? delegate_->AsExtensionInfoBarDelegate() : NULL;
+ return delegate()->AsExtensionInfoBarDelegate();
}
Browser* ExtensionInfoBarGtk::GetBrowser() {
« no previous file with comments | « chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h ('k') | chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698