OLD | NEW |
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 #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 "chrome/browser/extensions/extension_context_menu_model.h" | 7 #include "chrome/browser/extensions/extension_context_menu_model.h" |
8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
9 #include "chrome/browser/platform_util.h" | 9 #include "chrome/browser/platform_util.h" |
10 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 10 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 void ExtensionInfoBarGtk::OnSizeAllocate(GtkWidget* widget, | 170 void ExtensionInfoBarGtk::OnSizeAllocate(GtkWidget* widget, |
171 GtkAllocation* allocation) { | 171 GtkAllocation* allocation) { |
172 gfx::Size new_size(allocation->width, allocation->height); | 172 gfx::Size new_size(allocation->width, allocation->height); |
173 | 173 |
174 delegate_->extension_host()->view()->render_view_host()->view() | 174 delegate_->extension_host()->view()->render_view_host()->view() |
175 ->SetSize(new_size); | 175 ->SetSize(new_size); |
176 } | 176 } |
177 | 177 |
178 gboolean ExtensionInfoBarGtk::OnButtonPress(GtkWidget* widget, | 178 gboolean ExtensionInfoBarGtk::OnButtonPress(GtkWidget* widget, |
179 GdkEventButton* event) { | 179 GdkEventButton* event) { |
| 180 // If we're closing, don't call anything, it might access the owner. |
| 181 if (!owned()) |
| 182 return FALSE; |
| 183 |
180 if (event->button != 1) | 184 if (event->button != 1) |
181 return FALSE; | 185 return FALSE; |
182 | 186 |
183 MenuGtk* menu = BuildMenu(); | 187 MenuGtk* menu = BuildMenu(); |
184 if (!menu) | 188 if (!menu) |
185 return FALSE; | 189 return FALSE; |
186 | 190 |
187 gtk_chrome_button_set_paint_state(GTK_CHROME_BUTTON(widget), | 191 gtk_chrome_button_set_paint_state(GTK_CHROME_BUTTON(widget), |
188 GTK_STATE_ACTIVE); | 192 GTK_STATE_ACTIVE); |
189 menu->PopupForWidget(widget, event->button, event->time); | 193 menu->PopupForWidget(widget, event->button, event->time); |
190 | 194 |
191 return TRUE; | 195 return TRUE; |
192 } | 196 } |
193 | 197 |
194 gboolean ExtensionInfoBarGtk::OnExpose(GtkWidget* sender, | 198 gboolean ExtensionInfoBarGtk::OnExpose(GtkWidget* sender, |
195 GdkEventExpose* event) { | 199 GdkEventExpose* event) { |
196 // We also need to draw our infobar arrows over the renderer. | 200 // We also need to draw our infobar arrows over the renderer. |
197 static_cast<InfoBarContainerGtk*>(container())-> | 201 static_cast<InfoBarContainerGtk*>(container())-> |
198 PaintInfobarBitsOn(sender, event, this); | 202 PaintInfobarBitsOn(sender, event, this); |
199 | 203 |
200 return FALSE; | 204 return FALSE; |
201 } | 205 } |
202 | 206 |
203 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { | 207 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(TabContentsWrapper* owner) { |
204 return new ExtensionInfoBarGtk(owner, this); | 208 return new ExtensionInfoBarGtk(owner, this); |
205 } | 209 } |
OLD | NEW |