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

Unified Diff: chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.cc

Issue 12881003: ShortcutInfo::favicon is now a gfx::ImageFamily instead of gfx::Image. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix UpdateIcon on Mac (get the correct image representation from NSImage). Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.cc
diff --git a/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.cc b/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.cc
index 344b87229eb531f6e23788fa71d431406680dd46..ae17d0f4941da9d55f4ccf1f931ddd2869a49e1b 100644
--- a/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.cc
+++ b/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.cc
@@ -32,8 +32,9 @@
#include "ui/base/gtk/gtk_hig_constants.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/gtk_util.h"
+#include "ui/gfx/image/image.h"
+#include "ui/gfx/image/image_family.h"
#include "ui/gfx/image/image_skia.h"
-#include "ui/gfx/image/image_skia_rep.h"
using content::BrowserThread;
using extensions::Extension;
@@ -82,37 +83,15 @@ CreateApplicationShortcutsDialogGtk::CreateApplicationShortcutsDialogGtk(
}
void CreateApplicationShortcutsDialogGtk::CreateIconPixBuf(
- const gfx::Image& image) {
- const gfx::ImageSkia& image_skia = *(image.ToImageSkia());
- std::vector<gfx::ImageSkiaRep> image_reps = image_skia.image_reps();
- // Find the smallest icon bigger or equal to the desired size. If it cannot be
- // found, find the biggest icon smaller than the desired size.
- const gfx::ImageSkiaRep* smallest_larger = NULL;
- const gfx::ImageSkiaRep* largest_smaller = NULL;
- for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin();
- it != image_reps.end(); ++it) {
- if (it->pixel_width() >= kIconPreviewSizePixels) {
- if (!smallest_larger ||
- it->pixel_width() < smallest_larger->pixel_width()) {
- smallest_larger = &*it;
- }
- } else {
- if (!largest_smaller ||
- it->pixel_width() > largest_smaller->pixel_width()) {
- largest_smaller = &*it;
- }
- }
- }
- GdkPixbuf* pixbuf;
- if (smallest_larger) {
- pixbuf = gfx::GdkPixbufFromSkBitmap(smallest_larger->sk_bitmap());
- } else if (largest_smaller) {
- pixbuf = gfx::GdkPixbufFromSkBitmap(largest_smaller->sk_bitmap());
- } else {
- // Should never happen unless the image has no representations. Call
- // ToGdkPixbuf which will presumably return a null image representation.
- pixbuf = static_cast<GdkPixbuf*>(g_object_ref(image.ToGdkPixbuf()));
- }
+ const gfx::ImageFamily& image) {
+ // Get the icon closest to the desired preview size.
+ const gfx::Image* icon = image.GetBest(kIconPreviewSizePixels,
+ kIconPreviewSizePixels);
+ // There must be at least one icon in the image family.
+ CHECK(icon);
+ CHECK(!icon->IsEmpty());
Robert Sesek 2013/04/08 13:16:39 Can remove this CHECK, since ToGdkPixbuf will do i
Matt Giuca 2013/04/09 00:00:45 Done.
+ GdkPixbuf* pixbuf = icon->ToGdkPixbuf();
+ g_object_ref(pixbuf);
// Prepare the icon. Scale it to the correct size to display in the dialog.
int pixbuf_width = gdk_pixbuf_get_width(pixbuf);
int pixbuf_height = gdk_pixbuf_get_height(pixbuf);

Powered by Google App Engine
This is Rietveld 408576698