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

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

Issue 12208091: ExtensionInfobarGtk doesn't handle delegate going away. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 10 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
« no previous file with comments | « chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h" 5 #include "chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "chrome/browser/extensions/extension_context_menu_model.h" 8 #include "chrome/browser/extensions/extension_context_menu_model.h"
9 #include "chrome/browser/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/extensions/image_loader.h" 10 #include "chrome/browser/extensions/image_loader.h"
(...skipping 15 matching lines...) Expand all
26 #include "ui/gfx/canvas.h" 26 #include "ui/gfx/canvas.h"
27 #include "ui/gfx/gtk_util.h" 27 #include "ui/gfx/gtk_util.h"
28 #include "ui/gfx/image/image.h" 28 #include "ui/gfx/image/image.h"
29 29
30 ExtensionInfoBarGtk::ExtensionInfoBarGtk(InfoBarService* owner, 30 ExtensionInfoBarGtk::ExtensionInfoBarGtk(InfoBarService* owner,
31 ExtensionInfoBarDelegate* delegate) 31 ExtensionInfoBarDelegate* delegate)
32 : InfoBarGtk(owner, delegate), 32 : InfoBarGtk(owner, delegate),
33 delegate_(delegate), 33 delegate_(delegate),
34 view_(NULL), 34 view_(NULL),
35 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 35 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
36 delegate->set_observer(this);
37
36 // Always render the close button as if we were doing chrome style widget 38 // Always render the close button as if we were doing chrome style widget
37 // rendering. For extension infobars, we force chrome style rendering because 39 // rendering. For extension infobars, we force chrome style rendering because
38 // extension authors are going to expect to match the declared gradient in 40 // extension authors are going to expect to match the declared gradient in
39 // extensions_infobar.css, and the close button provided by some GTK+ themes 41 // extensions_infobar.css, and the close button provided by some GTK+ themes
40 // won't look good on this background. 42 // won't look good on this background.
41 close_button_->ForceChromeTheme(); 43 close_button_->ForceChromeTheme();
42 44
43 int height = delegate->height(); 45 int height = delegate->height();
44 SetBarTargetHeight((height > 0) ? (height + kSeparatorLineHeight) : 0); 46 SetBarTargetHeight((height > 0) ? (height + kSeparatorLineHeight) : 0);
45 47
46 BuildWidgets(); 48 BuildWidgets();
47 } 49 }
48 50
49 ExtensionInfoBarGtk::~ExtensionInfoBarGtk() {} 51 ExtensionInfoBarGtk::~ExtensionInfoBarGtk() {
52 if (delegate_)
53 delegate_->set_observer(NULL);
54 }
50 55
51 void ExtensionInfoBarGtk::PlatformSpecificHide(bool animate) { 56 void ExtensionInfoBarGtk::PlatformSpecificHide(bool animate) {
52 // This view is not owned by us; we can't unparent it because we aren't the 57 // This view is not owned by us; we can't unparent it because we aren't the
53 // owning container. 58 // owning container.
54 gtk_container_remove(GTK_CONTAINER(alignment_), view_->native_view()); 59 gtk_container_remove(GTK_CONTAINER(alignment_), view_->native_view());
55 } 60 }
56 61
57 void ExtensionInfoBarGtk::GetTopColor(InfoBarDelegate::Type type, 62 void ExtensionInfoBarGtk::GetTopColor(InfoBarDelegate::Type type,
58 double* r, double* g, double* b) { 63 double* r, double* g, double* b) {
59 // Extension infobars are always drawn with chrome-theme colors. 64 // Extension infobars are always drawn with chrome-theme colors.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 Signals()->Connect(view_->native_view(), "expose-event", 146 Signals()->Connect(view_->native_view(), "expose-event",
142 G_CALLBACK(&OnExposeThunk), this); 147 G_CALLBACK(&OnExposeThunk), this);
143 Signals()->Connect(view_->native_view(), "size_allocate", 148 Signals()->Connect(view_->native_view(), "size_allocate",
144 G_CALLBACK(&OnSizeAllocateThunk), this); 149 G_CALLBACK(&OnSizeAllocateThunk), this);
145 } 150 }
146 151
147 void ExtensionInfoBarGtk::StoppedShowing() { 152 void ExtensionInfoBarGtk::StoppedShowing() {
148 gtk_chrome_button_unset_paint_state(GTK_CHROME_BUTTON(button_)); 153 gtk_chrome_button_unset_paint_state(GTK_CHROME_BUTTON(button_));
149 } 154 }
150 155
156 void ExtensionInfoBarGtk::OnDelegateDeleted() {
157 delegate_ = NULL;
158 }
159
151 Browser* ExtensionInfoBarGtk::GetBrowser() { 160 Browser* ExtensionInfoBarGtk::GetBrowser() {
152 // Get the Browser object this infobar is attached to. 161 // Get the Browser object this infobar is attached to.
153 GtkWindow* parent = platform_util::GetTopLevel(icon_); 162 GtkWindow* parent = platform_util::GetTopLevel(icon_);
154 if (!parent) 163 if (!parent)
155 return NULL; 164 return NULL;
156 165
157 return BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent)->browser(); 166 return BrowserWindowGtk::GetBrowserWindowForNativeWindow(parent)->browser();
158 } 167 }
159 168
160 ExtensionContextMenuModel* ExtensionInfoBarGtk::BuildMenuModel() { 169 ExtensionContextMenuModel* ExtensionInfoBarGtk::BuildMenuModel() {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // We also need to draw our infobar arrows over the renderer. 209 // We also need to draw our infobar arrows over the renderer.
201 static_cast<InfoBarContainerGtk*>(container())-> 210 static_cast<InfoBarContainerGtk*>(container())->
202 PaintInfobarBitsOn(sender, event, this); 211 PaintInfobarBitsOn(sender, event, this);
203 212
204 return FALSE; 213 return FALSE;
205 } 214 }
206 215
207 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { 216 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
208 return new ExtensionInfoBarGtk(owner, this); 217 return new ExtensionInfoBarGtk(owner, this);
209 } 218 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698