| 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 #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/extension_view.h" | |
| 11 #include "chrome/browser/infobars/infobar_tab_helper.h" | 10 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 12 #include "chrome/browser/platform_util.h" | 11 #include "chrome/browser/platform_util.h" |
| 13 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 12 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 14 #include "chrome/browser/ui/gtk/custom_button.h" | 13 #include "chrome/browser/ui/gtk/custom_button.h" |
| 15 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 14 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
| 16 #include "chrome/browser/ui/gtk/gtk_util.h" | 15 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 17 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" | 16 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" |
| 18 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 19 #include "chrome/common/extensions/extension_constants.h" | 18 #include "chrome/common/extensions/extension_constants.h" |
| 20 #include "chrome/common/extensions/extension_icon_set.h" | 19 #include "chrome/common/extensions/extension_icon_set.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 45 SetBarTargetHeight((height > 0) ? (height + kSeparatorLineHeight) : 0); | 44 SetBarTargetHeight((height > 0) ? (height + kSeparatorLineHeight) : 0); |
| 46 | 45 |
| 47 BuildWidgets(); | 46 BuildWidgets(); |
| 48 } | 47 } |
| 49 | 48 |
| 50 ExtensionInfoBarGtk::~ExtensionInfoBarGtk() {} | 49 ExtensionInfoBarGtk::~ExtensionInfoBarGtk() {} |
| 51 | 50 |
| 52 void ExtensionInfoBarGtk::PlatformSpecificHide(bool animate) { | 51 void ExtensionInfoBarGtk::PlatformSpecificHide(bool animate) { |
| 53 // This view is not owned by us; we can't unparent it because we aren't the | 52 // This view is not owned by us; we can't unparent it because we aren't the |
| 54 // owning container. | 53 // owning container. |
| 55 gtk_container_remove(GTK_CONTAINER(alignment_), view_->GetNativeView()); | 54 gtk_container_remove(GTK_CONTAINER(alignment_), view_->native_view()); |
| 56 } | 55 } |
| 57 | 56 |
| 58 void ExtensionInfoBarGtk::GetTopColor(InfoBarDelegate::Type type, | 57 void ExtensionInfoBarGtk::GetTopColor(InfoBarDelegate::Type type, |
| 59 double* r, double* g, double* b) { | 58 double* r, double* g, double* b) { |
| 60 // Extension infobars are always drawn with chrome-theme colors. | 59 // Extension infobars are always drawn with chrome-theme colors. |
| 61 *r = *g = *b = 233.0 / 255.0; | 60 *r = *g = *b = 233.0 / 255.0; |
| 62 } | 61 } |
| 63 | 62 |
| 64 void ExtensionInfoBarGtk::GetBottomColor(InfoBarDelegate::Type type, | 63 void ExtensionInfoBarGtk::GetBottomColor(InfoBarDelegate::Type type, |
| 65 double* r, double* g, double* b) { | 64 double* r, double* g, double* b) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 gfx::Size(extension_misc::EXTENSION_ICON_BITTY, | 120 gfx::Size(extension_misc::EXTENSION_ICON_BITTY, |
| 122 extension_misc::EXTENSION_ICON_BITTY), | 121 extension_misc::EXTENSION_ICON_BITTY), |
| 123 ImageLoadingTracker::DONT_CACHE); | 122 ImageLoadingTracker::DONT_CACHE); |
| 124 | 123 |
| 125 // Pad the bottom of the infobar by one pixel for the border. | 124 // Pad the bottom of the infobar by one pixel for the border. |
| 126 alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); | 125 alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); |
| 127 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_), 0, 1, 0, 0); | 126 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_), 0, 1, 0, 0); |
| 128 gtk_box_pack_start(GTK_BOX(hbox_), alignment_, TRUE, TRUE, 0); | 127 gtk_box_pack_start(GTK_BOX(hbox_), alignment_, TRUE, TRUE, 0); |
| 129 | 128 |
| 130 extensions::ExtensionHost* extension_host = delegate_->extension_host(); | 129 extensions::ExtensionHost* extension_host = delegate_->extension_host(); |
| 131 view_ = extension_host->GetExtensionView(); | 130 view_ = extension_host->view(); |
| 132 | 131 |
| 133 if (gtk_widget_get_parent(view_->GetNativeView())) { | 132 if (gtk_widget_get_parent(view_->native_view())) { |
| 134 gtk_widget_reparent(view_->GetNativeView(), alignment_); | 133 gtk_widget_reparent(view_->native_view(), alignment_); |
| 135 } else { | 134 } else { |
| 136 gtk_container_add(GTK_CONTAINER(alignment_), view_->GetNativeView()); | 135 gtk_container_add(GTK_CONTAINER(alignment_), view_->native_view()); |
| 137 } | 136 } |
| 138 | 137 |
| 139 Signals()->Connect(button_, "button-press-event", | 138 Signals()->Connect(button_, "button-press-event", |
| 140 G_CALLBACK(&OnButtonPressThunk), this); | 139 G_CALLBACK(&OnButtonPressThunk), this); |
| 141 Signals()->Connect(view_->GetNativeView(), "expose-event", | 140 Signals()->Connect(view_->native_view(), "expose-event", |
| 142 G_CALLBACK(&OnExposeThunk), this); | 141 G_CALLBACK(&OnExposeThunk), this); |
| 143 Signals()->Connect(view_->GetNativeView(), "size_allocate", | 142 Signals()->Connect(view_->native_view(), "size_allocate", |
| 144 G_CALLBACK(&OnSizeAllocateThunk), this); | 143 G_CALLBACK(&OnSizeAllocateThunk), this); |
| 145 } | 144 } |
| 146 | 145 |
| 147 void ExtensionInfoBarGtk::StoppedShowing() { | 146 void ExtensionInfoBarGtk::StoppedShowing() { |
| 148 gtk_chrome_button_unset_paint_state(GTK_CHROME_BUTTON(button_)); | 147 gtk_chrome_button_unset_paint_state(GTK_CHROME_BUTTON(button_)); |
| 149 } | 148 } |
| 150 | 149 |
| 151 Browser* ExtensionInfoBarGtk::GetBrowser() { | 150 Browser* ExtensionInfoBarGtk::GetBrowser() { |
| 152 // Get the Browser object this infobar is attached to. | 151 // Get the Browser object this infobar is attached to. |
| 153 GtkWindow* parent = platform_util::GetTopLevel(icon_); | 152 GtkWindow* parent = platform_util::GetTopLevel(icon_); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 166 if (!browser) | 165 if (!browser) |
| 167 return NULL; | 166 return NULL; |
| 168 | 167 |
| 169 return new ExtensionContextMenuModel(extension, browser); | 168 return new ExtensionContextMenuModel(extension, browser); |
| 170 } | 169 } |
| 171 | 170 |
| 172 void ExtensionInfoBarGtk::OnSizeAllocate(GtkWidget* widget, | 171 void ExtensionInfoBarGtk::OnSizeAllocate(GtkWidget* widget, |
| 173 GtkAllocation* allocation) { | 172 GtkAllocation* allocation) { |
| 174 gfx::Size new_size(allocation->width, allocation->height); | 173 gfx::Size new_size(allocation->width, allocation->height); |
| 175 | 174 |
| 176 delegate_->extension_host()->GetExtensionView()->GetRenderViewHost()-> | 175 delegate_->extension_host()->view()->render_view_host()->GetView() |
| 177 GetView()->SetSize(new_size); | 176 ->SetSize(new_size); |
| 178 } | 177 } |
| 179 | 178 |
| 180 gboolean ExtensionInfoBarGtk::OnButtonPress(GtkWidget* widget, | 179 gboolean ExtensionInfoBarGtk::OnButtonPress(GtkWidget* widget, |
| 181 GdkEventButton* event) { | 180 GdkEventButton* event) { |
| 182 if (event->button != 1) | 181 if (event->button != 1) |
| 183 return FALSE; | 182 return FALSE; |
| 184 | 183 |
| 185 ui::MenuModel* model = BuildMenuModel(); | 184 ui::MenuModel* model = BuildMenuModel(); |
| 186 if (!model) | 185 if (!model) |
| 187 return FALSE; | 186 return FALSE; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 200 // We also need to draw our infobar arrows over the renderer. | 199 // We also need to draw our infobar arrows over the renderer. |
| 201 static_cast<InfoBarContainerGtk*>(container())-> | 200 static_cast<InfoBarContainerGtk*>(container())-> |
| 202 PaintInfobarBitsOn(sender, event, this); | 201 PaintInfobarBitsOn(sender, event, this); |
| 203 | 202 |
| 204 return FALSE; | 203 return FALSE; |
| 205 } | 204 } |
| 206 | 205 |
| 207 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { | 206 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { |
| 208 return new ExtensionInfoBarGtk(static_cast<InfoBarTabHelper*>(owner), this); | 207 return new ExtensionInfoBarGtk(static_cast<InfoBarTabHelper*>(owner), this); |
| 209 } | 208 } |
| OLD | NEW |