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

Side by Side Diff: chrome/browser/ui/gtk/extensions/extension_install_dialog_gtk.cc

Issue 10377122: Convert GdkPixbufFromSkBitmap and GdkPixbufToSkBitmap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 <gtk/gtk.h> 5 #include <gtk/gtk.h>
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/bundle_installer.h" 10 #include "chrome/browser/extensions/bundle_installer.h"
(...skipping 23 matching lines...) Expand all
34 // Additional padding (beyond on ui::kControlSpacing) all sides of each 34 // Additional padding (beyond on ui::kControlSpacing) all sides of each
35 // permission in the permissions list. 35 // permission in the permissions list.
36 const int kPermissionsPadding = 2; 36 const int kPermissionsPadding = 2;
37 const int kExtensionsPadding = kPermissionsPadding; 37 const int kExtensionsPadding = kPermissionsPadding;
38 38
39 const double kRatingTextSize = 12.1; // 12.1px = 9pt @ 96dpi 39 const double kRatingTextSize = 12.1; // 12.1px = 9pt @ 96dpi
40 40
41 // Adds a Skia image as an icon control to the given container. 41 // Adds a Skia image as an icon control to the given container.
42 void AddResourceIcon(const SkBitmap* icon, void* data) { 42 void AddResourceIcon(const SkBitmap* icon, void* data) {
43 GtkWidget* container = static_cast<GtkWidget*>(data); 43 GtkWidget* container = static_cast<GtkWidget*>(data);
44 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(icon); 44 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(*icon);
45 GtkWidget* icon_widget = gtk_image_new_from_pixbuf(icon_pixbuf); 45 GtkWidget* icon_widget = gtk_image_new_from_pixbuf(icon_pixbuf);
46 g_object_unref(icon_pixbuf); 46 g_object_unref(icon_pixbuf);
47 gtk_box_pack_start(GTK_BOX(container), icon_widget, FALSE, FALSE, 0); 47 gtk_box_pack_start(GTK_BOX(container), icon_widget, FALSE, FALSE, 0);
48 } 48 }
49 49
50 // Displays the dialog when constructed, deletes itself when dialog is 50 // Displays the dialog when constructed, deletes itself when dialog is
51 // dismissed. Success/failure is passed back through the ExtensionInstallUI:: 51 // dismissed. Success/failure is passed back through the ExtensionInstallUI::
52 // Delegate instance. 52 // Delegate instance.
53 class ExtensionInstallDialog { 53 class ExtensionInstallDialog {
54 public: 54 public:
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 if (!is_bundle_install) { 184 if (!is_bundle_install) {
185 // Resize the icon if necessary. 185 // Resize the icon if necessary.
186 SkBitmap scaled_icon = *prompt.icon().ToSkBitmap(); 186 SkBitmap scaled_icon = *prompt.icon().ToSkBitmap();
187 if (scaled_icon.width() > kImageSize || scaled_icon.height() > kImageSize) { 187 if (scaled_icon.width() > kImageSize || scaled_icon.height() > kImageSize) {
188 scaled_icon = skia::ImageOperations::Resize( 188 scaled_icon = skia::ImageOperations::Resize(
189 scaled_icon, skia::ImageOperations::RESIZE_LANCZOS3, 189 scaled_icon, skia::ImageOperations::RESIZE_LANCZOS3,
190 kImageSize, kImageSize); 190 kImageSize, kImageSize);
191 } 191 }
192 192
193 // Put icon in the right column. 193 // Put icon in the right column.
194 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&scaled_icon); 194 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(scaled_icon);
195 GtkWidget* icon = gtk_image_new_from_pixbuf(pixbuf); 195 GtkWidget* icon = gtk_image_new_from_pixbuf(pixbuf);
196 g_object_unref(pixbuf); 196 g_object_unref(pixbuf);
197 gtk_box_pack_start(GTK_BOX(top_content_hbox), icon, FALSE, FALSE, 0); 197 gtk_box_pack_start(GTK_BOX(top_content_hbox), icon, FALSE, FALSE, 0);
198 // Top justify the image. 198 // Top justify the image.
199 gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0); 199 gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0);
200 } 200 }
201 201
202 // Permissions are shown separated by a divider for inline installs, or 202 // Permissions are shown separated by a divider for inline installs, or
203 // directly under the heading for regular installs (where we don't have 203 // directly under the heading for regular installs (where we don't have
204 // the store data) 204 // the store data)
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 273
274 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( 274 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>(
275 browser->window()); 275 browser->window());
276 if (!browser_window) { 276 if (!browser_window) {
277 delegate->InstallUIAbort(false); 277 delegate->InstallUIAbort(false);
278 return; 278 return;
279 } 279 }
280 280
281 new ExtensionInstallDialog(browser_window->window(), delegate, prompt); 281 new ExtensionInstallDialog(browser_window->window(), delegate, prompt);
282 } 282 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/custom_button.cc ('k') | chrome/browser/ui/gtk/extensions/extension_installed_bubble_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698