Chromium Code Reviews| Index: chrome/browser/favicon/favicon_handler.cc |
| diff --git a/chrome/browser/favicon/favicon_handler.cc b/chrome/browser/favicon/favicon_handler.cc |
| index dc2b228c6a2189fb0fd89b93557259225c6b21b1..fbddaaf5b7a1ec09d64c0c3edce1b295c955cf3d 100644 |
| --- a/chrome/browser/favicon/favicon_handler.cc |
| +++ b/chrome/browser/favicon/favicon_handler.cc |
| @@ -14,6 +14,7 @@ |
| #include "chrome/browser/bookmarks/bookmark_model.h" |
| #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| #include "chrome/browser/favicon/favicon_service_factory.h" |
| +#include "chrome/browser/favicon/select_favicon_frames.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/common/icon_messages.h" |
| #include "content/public/browser/favicon_status.h" |
| @@ -21,6 +22,7 @@ |
| #include "skia/ext/image_operations.h" |
| #include "ui/gfx/codec/png_codec.h" |
| #include "ui/gfx/image/image.h" |
| +#include "ui/gfx/image/image_skia.h" |
| #include "ui/gfx/image/image_util.h" |
| using content::NavigationEntry; |
| @@ -232,10 +234,24 @@ void FaviconHandler::SetFavicon( |
| } |
| void FaviconHandler::UpdateFavicon(NavigationEntry* entry, |
| - scoped_refptr<base::RefCountedMemory> data) { |
| - scoped_ptr<gfx::Image> image(gfx::ImageFromPNGEncodedData(data->front(), |
| - data->size())); |
| - UpdateFavicon(entry, image.get()); |
| + const std::vector<history::FaviconBitmapResult>& favicon_bitmap_results) { |
|
pkotwicz
2012/09/05 14:08:46
Nit:
Can we put the code for converting from a Fav
Nico
2012/09/05 14:48:54
Done.
|
| + std::vector<SkBitmap> bitmaps; |
| + for (size_t i = 0; i < favicon_bitmap_results.size(); ++i) { |
| + SkBitmap bitmap; |
| + if (gfx::PNGCodec::Decode(favicon_bitmap_results[i].bitmap_data->front(), |
| + favicon_bitmap_results[i].bitmap_data->size(), |
| + &bitmap)) { |
| + bitmaps.push_back(bitmap); |
| + } |
| + } |
| + |
| + if (bitmaps.empty()) |
| + return; |
| + |
| + gfx::ImageSkia resized_image_skia = SelectFaviconFrames(bitmaps, |
| + ui::GetSupportedScaleFactors(), preferred_icon_size(), NULL); |
| + gfx::Image resized_image(resized_image_skia); |
| + UpdateFavicon(entry, &resized_image); |
| } |
| void FaviconHandler::UpdateFavicon(NavigationEntry* entry, |
| @@ -441,7 +457,7 @@ void FaviconHandler::OnFaviconDataForInitialURL( |
| // user doesn't see a flash of the default favicon. |
| entry->GetFavicon().url = bitmap_result.icon_url; |
| if (bitmap_result.is_valid()) |
| - UpdateFavicon(entry, bitmap_result.bitmap_data); |
| + UpdateFavicon(entry, favicon_bitmap_results); |
| entry->GetFavicon().valid = true; |
| } |
| @@ -516,7 +532,7 @@ void FaviconHandler::OnFaviconData( |
| // There is a favicon, set it now. If expired we'll download the current |
| // one again, but at least the user will get some icon instead of the |
| // default and most likely the current one is fine anyway. |
| - UpdateFavicon(entry, bitmap_result.bitmap_data); |
| + UpdateFavicon(entry, favicon_bitmap_results); |
| } |
| if (HasExpiredFaviconResult(favicon_bitmap_results)) { |
| // The favicon is out of date. Request the current one. |