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/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/extension.h" | 16 #include "chrome/common/extensions/extension.h" |
| 17 #include "chrome/common/extensions/extension_constants.h" |
17 #include "chrome/common/extensions/extension_icon_set.h" | 18 #include "chrome/common/extensions/extension_icon_set.h" |
18 #include "chrome/common/extensions/extension_resource.h" | 19 #include "chrome/common/extensions/extension_resource.h" |
19 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
20 #include "content/public/browser/render_widget_host_view.h" | 21 #include "content/public/browser/render_widget_host_view.h" |
21 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
22 #include "ui/base/gtk/gtk_signal_registrar.h" | 23 #include "ui/base/gtk/gtk_signal_registrar.h" |
23 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
24 #include "ui/gfx/canvas.h" | 25 #include "ui/gfx/canvas.h" |
25 #include "ui/gfx/gtk_util.h" | 26 #include "ui/gfx/gtk_util.h" |
26 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // icon of the correct size with real subpixel shading and such. | 74 // icon of the correct size with real subpixel shading and such. |
74 const SkBitmap* icon = NULL; | 75 const SkBitmap* icon = NULL; |
75 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 76 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
76 if (image.IsEmpty()) | 77 if (image.IsEmpty()) |
77 icon = rb.GetBitmapNamed(IDR_EXTENSIONS_SECTION); | 78 icon = rb.GetBitmapNamed(IDR_EXTENSIONS_SECTION); |
78 else | 79 else |
79 icon = image.ToSkBitmap(); | 80 icon = image.ToSkBitmap(); |
80 | 81 |
81 SkBitmap* drop_image = rb.GetBitmapNamed(IDR_APP_DROPARROW); | 82 SkBitmap* drop_image = rb.GetBitmapNamed(IDR_APP_DROPARROW); |
82 | 83 |
83 int image_size = ExtensionIconSet::EXTENSION_ICON_BITTY; | 84 int image_size = extension_misc::EXTENSION_ICON_BITTY; |
84 // The margin between the extension icon and the drop-down arrow bitmap. | 85 // The margin between the extension icon and the drop-down arrow bitmap. |
85 static const int kDropArrowLeftMargin = 3; | 86 static const int kDropArrowLeftMargin = 3; |
86 scoped_ptr<gfx::Canvas> canvas(new gfx::Canvas( | 87 scoped_ptr<gfx::Canvas> canvas(new gfx::Canvas( |
87 gfx::Size(image_size + kDropArrowLeftMargin + drop_image->width(), | 88 gfx::Size(image_size + kDropArrowLeftMargin + drop_image->width(), |
88 image_size), ui::SCALE_FACTOR_100P, false)); | 89 image_size), ui::SCALE_FACTOR_100P, false)); |
89 canvas->DrawImageInt(*icon, 0, 0, icon->width(), icon->height(), 0, 0, | 90 canvas->DrawImageInt(*icon, 0, 0, icon->width(), icon->height(), 0, 0, |
90 image_size, image_size, false); | 91 image_size, image_size, false); |
91 canvas->DrawImageInt(*drop_image, image_size + kDropArrowLeftMargin, | 92 canvas->DrawImageInt(*drop_image, image_size + kDropArrowLeftMargin, |
92 image_size / 2); | 93 image_size / 2); |
93 | 94 |
(...skipping 11 matching lines...) Expand all Loading... |
105 | 106 |
106 icon_ = gtk_image_new(); | 107 icon_ = gtk_image_new(); |
107 gtk_misc_set_alignment(GTK_MISC(icon_), 0.5, 0.5); | 108 gtk_misc_set_alignment(GTK_MISC(icon_), 0.5, 0.5); |
108 gtk_button_set_image(GTK_BUTTON(button_), icon_); | 109 gtk_button_set_image(GTK_BUTTON(button_), icon_); |
109 gtk_util::CenterWidgetInHBox(hbox_, button_, false, 0); | 110 gtk_util::CenterWidgetInHBox(hbox_, button_, false, 0); |
110 | 111 |
111 // Start loading the image for the menu button. | 112 // Start loading the image for the menu button. |
112 const extensions::Extension* extension = | 113 const extensions::Extension* extension = |
113 delegate_->extension_host()->extension(); | 114 delegate_->extension_host()->extension(); |
114 ExtensionResource icon_resource = extension->GetIconResource( | 115 ExtensionResource icon_resource = extension->GetIconResource( |
115 ExtensionIconSet::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); | 116 extension_misc::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); |
116 // Create a tracker to load the image. It will report back on OnImageLoaded. | 117 // Create a tracker to load the image. It will report back on OnImageLoaded. |
117 tracker_.LoadImage(extension, icon_resource, | 118 tracker_.LoadImage(extension, icon_resource, |
118 gfx::Size(ExtensionIconSet::EXTENSION_ICON_BITTY, | 119 gfx::Size(extension_misc::EXTENSION_ICON_BITTY, |
119 ExtensionIconSet::EXTENSION_ICON_BITTY), | 120 extension_misc::EXTENSION_ICON_BITTY), |
120 ImageLoadingTracker::DONT_CACHE); | 121 ImageLoadingTracker::DONT_CACHE); |
121 | 122 |
122 // Pad the bottom of the infobar by one pixel for the border. | 123 // Pad the bottom of the infobar by one pixel for the border. |
123 alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); | 124 alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); |
124 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_), 0, 1, 0, 0); | 125 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_), 0, 1, 0, 0); |
125 gtk_box_pack_start(GTK_BOX(hbox_), alignment_, TRUE, TRUE, 0); | 126 gtk_box_pack_start(GTK_BOX(hbox_), alignment_, TRUE, TRUE, 0); |
126 | 127 |
127 extensions::ExtensionHost* extension_host = delegate_->extension_host(); | 128 extensions::ExtensionHost* extension_host = delegate_->extension_host(); |
128 view_ = extension_host->view(); | 129 view_ = extension_host->view(); |
129 | 130 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // We also need to draw our infobar arrows over the renderer. | 198 // We also need to draw our infobar arrows over the renderer. |
198 static_cast<InfoBarContainerGtk*>(container())-> | 199 static_cast<InfoBarContainerGtk*>(container())-> |
199 PaintInfobarBitsOn(sender, event, this); | 200 PaintInfobarBitsOn(sender, event, this); |
200 | 201 |
201 return FALSE; | 202 return FALSE; |
202 } | 203 } |
203 | 204 |
204 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { | 205 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { |
205 return new ExtensionInfoBarGtk(owner, this); | 206 return new ExtensionInfoBarGtk(owner, this); |
206 } | 207 } |
OLD | NEW |