| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/platform_util.h" | 10 #include "chrome/browser/platform_util.h" |
| 11 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 11 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 12 #include "chrome/browser/ui/gtk/custom_button.h" | 12 #include "chrome/browser/ui/gtk/custom_button.h" |
| 13 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 13 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
| 14 #include "chrome/browser/ui/gtk/gtk_util.h" | 14 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 15 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" | 15 #include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h" |
| 16 #include "chrome/common/extensions/api/icons/icons_handler.h" |
| 16 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 17 #include "chrome/common/extensions/extension_constants.h" | 18 #include "chrome/common/extensions/extension_constants.h" |
| 18 #include "chrome/common/extensions/extension_icon_set.h" | 19 #include "chrome/common/extensions/extension_icon_set.h" |
| 19 #include "chrome/common/extensions/extension_resource.h" | 20 #include "chrome/common/extensions/extension_resource.h" |
| 20 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
| 21 #include "content/public/browser/render_widget_host_view.h" | 22 #include "content/public/browser/render_widget_host_view.h" |
| 22 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
| 23 #include "ui/base/gtk/gtk_signal_registrar.h" | 24 #include "ui/base/gtk/gtk_signal_registrar.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 reinterpret_cast<void*>(true)); | 106 reinterpret_cast<void*>(true)); |
| 106 | 107 |
| 107 icon_ = gtk_image_new(); | 108 icon_ = gtk_image_new(); |
| 108 gtk_misc_set_alignment(GTK_MISC(icon_), 0.5, 0.5); | 109 gtk_misc_set_alignment(GTK_MISC(icon_), 0.5, 0.5); |
| 109 gtk_button_set_image(GTK_BUTTON(button_), icon_); | 110 gtk_button_set_image(GTK_BUTTON(button_), icon_); |
| 110 gtk_util::CenterWidgetInHBox(hbox_, button_, false, 0); | 111 gtk_util::CenterWidgetInHBox(hbox_, button_, false, 0); |
| 111 | 112 |
| 112 // Start loading the image for the menu button. | 113 // Start loading the image for the menu button. |
| 113 const extensions::Extension* extension = | 114 const extensions::Extension* extension = |
| 114 delegate_->extension_host()->extension(); | 115 delegate_->extension_host()->extension(); |
| 115 ExtensionResource icon_resource = extension->GetIconResource( | 116 ExtensionResource icon_resource = extensions::IconsInfo::GetIconResource( |
| 116 extension_misc::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); | 117 extension, |
| 118 extension_misc::EXTENSION_ICON_BITTY, |
| 119 ExtensionIconSet::MATCH_EXACTLY); |
| 117 // Create a tracker to load the image. It will report back on OnImageLoaded. | 120 // Create a tracker to load the image. It will report back on OnImageLoaded. |
| 118 tracker_.LoadImage(extension, icon_resource, | 121 tracker_.LoadImage(extension, icon_resource, |
| 119 gfx::Size(extension_misc::EXTENSION_ICON_BITTY, | 122 gfx::Size(extension_misc::EXTENSION_ICON_BITTY, |
| 120 extension_misc::EXTENSION_ICON_BITTY), | 123 extension_misc::EXTENSION_ICON_BITTY), |
| 121 ImageLoadingTracker::DONT_CACHE); | 124 ImageLoadingTracker::DONT_CACHE); |
| 122 | 125 |
| 123 // Pad the bottom of the infobar by one pixel for the border. | 126 // Pad the bottom of the infobar by one pixel for the border. |
| 124 alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); | 127 alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); |
| 125 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_), 0, 1, 0, 0); | 128 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_), 0, 1, 0, 0); |
| 126 gtk_box_pack_start(GTK_BOX(hbox_), alignment_, TRUE, TRUE, 0); | 129 gtk_box_pack_start(GTK_BOX(hbox_), alignment_, TRUE, TRUE, 0); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 // We also need to draw our infobar arrows over the renderer. | 201 // We also need to draw our infobar arrows over the renderer. |
| 199 static_cast<InfoBarContainerGtk*>(container())-> | 202 static_cast<InfoBarContainerGtk*>(container())-> |
| 200 PaintInfobarBitsOn(sender, event, this); | 203 PaintInfobarBitsOn(sender, event, this); |
| 201 | 204 |
| 202 return FALSE; | 205 return FALSE; |
| 203 } | 206 } |
| 204 | 207 |
| 205 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { | 208 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarService* owner) { |
| 206 return new ExtensionInfoBarGtk(owner, this); | 209 return new ExtensionInfoBarGtk(owner, this); |
| 207 } | 210 } |
| OLD | NEW |