OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/list_store_favicon_loader.h" | 5 #include "chrome/browser/gtk/list_store_favicon_loader.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
| 9 #include "app/gfx/codec/png_codec.h" |
9 #include "base/gfx/gtk_util.h" | 10 #include "base/gfx/gtk_util.h" |
10 #include "base/gfx/png_decoder.h" | |
11 #include "chrome/browser/gtk/gtk_theme_provider.h" | 11 #include "chrome/browser/gtk/gtk_theme_provider.h" |
12 #include "chrome/browser/profile.h" | 12 #include "chrome/browser/profile.h" |
13 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
14 | 14 |
15 ListStoreFavIconLoader::ListStoreFavIconLoader( | 15 ListStoreFavIconLoader::ListStoreFavIconLoader( |
16 GtkListStore* list_store, gint favicon_col, gint favicon_handle_col, | 16 GtkListStore* list_store, gint favicon_col, gint favicon_handle_col, |
17 Profile* profile, CancelableRequestConsumer* consumer) | 17 Profile* profile, CancelableRequestConsumer* consumer) |
18 : list_store_(list_store), favicon_col_(favicon_col), | 18 : list_store_(list_store), favicon_col_(favicon_col), |
19 favicon_handle_col_(favicon_handle_col), profile_(profile), | 19 favicon_handle_col_(favicon_handle_col), profile_(profile), |
20 consumer_(consumer), | 20 consumer_(consumer), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 scoped_refptr<RefCountedBytes> image_data, bool is_expired, GURL icon_url) { | 64 scoped_refptr<RefCountedBytes> image_data, bool is_expired, GURL icon_url) { |
65 GtkTreeIter iter; | 65 GtkTreeIter iter; |
66 if (!GetRowByFavIconHandle(handle, &iter)) | 66 if (!GetRowByFavIconHandle(handle, &iter)) |
67 return; | 67 return; |
68 gtk_list_store_set(list_store_, &iter, | 68 gtk_list_store_set(list_store_, &iter, |
69 favicon_handle_col_, 0, | 69 favicon_handle_col_, 0, |
70 -1); | 70 -1); |
71 if (know_fav_icon && image_data.get() && !image_data->data.empty()) { | 71 if (know_fav_icon && image_data.get() && !image_data->data.empty()) { |
72 int width, height; | 72 int width, height; |
73 std::vector<unsigned char> decoded_data; | 73 std::vector<unsigned char> decoded_data; |
74 if (PNGDecoder::Decode(&image_data->data.front(), image_data->data.size(), | 74 if (gfx::PNGCodec::Decode(&image_data->data.front(), |
75 PNGDecoder::FORMAT_BGRA, &decoded_data, &width, | 75 image_data->data.size(), |
76 &height)) { | 76 gfx::PNGCodec::FORMAT_BGRA, &decoded_data, |
| 77 &width, &height)) { |
77 SkBitmap icon; | 78 SkBitmap icon; |
78 icon.setConfig(SkBitmap::kARGB_8888_Config, width, height); | 79 icon.setConfig(SkBitmap::kARGB_8888_Config, width, height); |
79 icon.allocPixels(); | 80 icon.allocPixels(); |
80 memcpy(icon.getPixels(), &decoded_data.front(), | 81 memcpy(icon.getPixels(), &decoded_data.front(), |
81 width * height * 4); | 82 width * height * 4); |
82 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon); | 83 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon); |
83 gtk_list_store_set(list_store_, &iter, | 84 gtk_list_store_set(list_store_, &iter, |
84 favicon_col_, pixbuf, | 85 favicon_col_, pixbuf, |
85 -1); | 86 -1); |
86 g_object_unref(pixbuf); | 87 g_object_unref(pixbuf); |
87 } | 88 } |
88 } | 89 } |
89 } | 90 } |
OLD | NEW |