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

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

Issue 9586018: Add support for multiple icon sizes for Mac platform apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build Created 8 years, 9 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 | Annotate | Revision Log
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/platform_util.h" 10 #include "chrome/browser/platform_util.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 double* r, double* g, double* b) { 56 double* r, double* g, double* b) {
57 // Extension infobars are always drawn with chrome-theme colors. 57 // Extension infobars are always drawn with chrome-theme colors.
58 *r = *g = *b = 233.0 / 255.0; 58 *r = *g = *b = 233.0 / 255.0;
59 } 59 }
60 60
61 void ExtensionInfoBarGtk::GetBottomColor(InfoBarDelegate::Type type, 61 void ExtensionInfoBarGtk::GetBottomColor(InfoBarDelegate::Type type,
62 double* r, double* g, double* b) { 62 double* r, double* g, double* b) {
63 *r = *g = *b = 218.0 / 255.0; 63 *r = *g = *b = 218.0 / 255.0;
64 } 64 }
65 65
66 void ExtensionInfoBarGtk::OnImageLoaded( 66 void ExtensionInfoBarGtk::OnImageLoaded(const gfx::Image& image,
67 SkBitmap* image, const ExtensionResource& resource, int index) { 67 const std::string& extension_id,
68 int index) {
68 if (!delegate_) 69 if (!delegate_)
69 return; // The delegate can go away while we asynchronously load images. 70 return; // The delegate can go away while we asynchronously load images.
70 71
71 // TODO(erg): IDR_EXTENSIONS_SECTION should have an IDR_INFOBAR_EXTENSIONS 72 // TODO(erg): IDR_EXTENSIONS_SECTION should have an IDR_INFOBAR_EXTENSIONS
72 // icon of the correct size with real subpixel shading and such. 73 // icon of the correct size with real subpixel shading and such.
73 SkBitmap* icon = image; 74 const SkBitmap* icon = NULL;
74 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 75 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
75 if (!image || image->empty()) 76 if (image.IsEmpty())
76 icon = rb.GetBitmapNamed(IDR_EXTENSIONS_SECTION); 77 icon = rb.GetBitmapNamed(IDR_EXTENSIONS_SECTION);
78 else
79 icon = image.ToSkBitmap();
77 80
78 SkBitmap* drop_image = rb.GetBitmapNamed(IDR_APP_DROPARROW); 81 SkBitmap* drop_image = rb.GetBitmapNamed(IDR_APP_DROPARROW);
79 82
80 int image_size = ExtensionIconSet::EXTENSION_ICON_BITTY; 83 int image_size = ExtensionIconSet::EXTENSION_ICON_BITTY;
81 // The margin between the extension icon and the drop-down arrow bitmap. 84 // The margin between the extension icon and the drop-down arrow bitmap.
82 static const int kDropArrowLeftMargin = 3; 85 static const int kDropArrowLeftMargin = 3;
83 scoped_ptr<gfx::CanvasSkia> canvas(new gfx::CanvasSkia( 86 scoped_ptr<gfx::CanvasSkia> canvas(new gfx::CanvasSkia(
84 gfx::Size(image_size + kDropArrowLeftMargin + drop_image->width(), 87 gfx::Size(image_size + kDropArrowLeftMargin + drop_image->width(),
85 image_size), 88 image_size),
86 false)); 89 false));
(...skipping 16 matching lines...) Expand all
103 106
104 icon_ = gtk_image_new(); 107 icon_ = gtk_image_new();
105 gtk_misc_set_alignment(GTK_MISC(icon_), 0.5, 0.5); 108 gtk_misc_set_alignment(GTK_MISC(icon_), 0.5, 0.5);
106 gtk_button_set_image(GTK_BUTTON(button_), icon_); 109 gtk_button_set_image(GTK_BUTTON(button_), icon_);
107 gtk_util::CenterWidgetInHBox(hbox_, button_, false, 0); 110 gtk_util::CenterWidgetInHBox(hbox_, button_, false, 0);
108 111
109 // Start loading the image for the menu button. 112 // Start loading the image for the menu button.
110 const Extension* extension = delegate_->extension_host()->extension(); 113 const Extension* extension = delegate_->extension_host()->extension();
111 ExtensionResource icon_resource = extension->GetIconResource( 114 ExtensionResource icon_resource = extension->GetIconResource(
112 ExtensionIconSet::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY); 115 ExtensionIconSet::EXTENSION_ICON_BITTY, ExtensionIconSet::MATCH_EXACTLY);
113 if (!icon_resource.relative_path().empty()) { 116 // Create a tracker to load the image. It will report back on OnImageLoaded.
114 // Create a tracker to load the image. It will report back on OnImageLoaded. 117 tracker_.LoadImage(extension, icon_resource,
115 tracker_.LoadImage(extension, icon_resource, 118 gfx::Size(ExtensionIconSet::EXTENSION_ICON_BITTY,
116 gfx::Size(ExtensionIconSet::EXTENSION_ICON_BITTY, 119 ExtensionIconSet::EXTENSION_ICON_BITTY),
117 ExtensionIconSet::EXTENSION_ICON_BITTY), 120 ImageLoadingTracker::DONT_CACHE);
118 ImageLoadingTracker::DONT_CACHE);
119 } else {
120 OnImageLoaded(NULL, icon_resource, 0);
121 }
122 121
123 // Pad the bottom of the infobar by one pixel for the border. 122 // 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); 123 alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
125 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_), 0, 1, 0, 0); 124 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_), 0, 1, 0, 0);
126 gtk_box_pack_start(GTK_BOX(hbox_), alignment_, TRUE, TRUE, 0); 125 gtk_box_pack_start(GTK_BOX(hbox_), alignment_, TRUE, TRUE, 0);
127 126
128 ExtensionHost* extension_host = delegate_->extension_host(); 127 ExtensionHost* extension_host = delegate_->extension_host();
129 view_ = extension_host->view(); 128 view_ = extension_host->view();
130 129
131 if (gtk_widget_get_parent(view_->native_view())) { 130 if (gtk_widget_get_parent(view_->native_view())) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // We also need to draw our infobar arrows over the renderer. 197 // We also need to draw our infobar arrows over the renderer.
199 static_cast<InfoBarContainerGtk*>(container())-> 198 static_cast<InfoBarContainerGtk*>(container())->
200 PaintInfobarBitsOn(sender, event, this); 199 PaintInfobarBitsOn(sender, event, this);
201 200
202 return FALSE; 201 return FALSE;
203 } 202 }
204 203
205 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { 204 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) {
206 return new ExtensionInfoBarGtk(owner, this); 205 return new ExtensionInfoBarGtk(owner, this);
207 } 206 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/infobars/extension_infobar_gtk.h ('k') | chrome/browser/ui/gtk/location_bar_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698