| Index: chrome/browser/favicon/favicon_util.cc
|
| diff --git a/chrome/browser/favicon/favicon_util.cc b/chrome/browser/favicon/favicon_util.cc
|
| index 405eb410448c0c48fc179e9b6706d467022db832..6606a821c945a019b3d37713d1d918f07beafa0c 100644
|
| --- a/chrome/browser/favicon/favicon_util.cc
|
| +++ b/chrome/browser/favicon/favicon_util.cc
|
| @@ -4,9 +4,13 @@
|
|
|
| #include "chrome/browser/favicon/favicon_util.h"
|
|
|
| +#include "chrome/browser/favicon/select_favicon_frames.h"
|
| +#include "chrome/browser/history/history_types.h"
|
| #include "chrome/common/icon_messages.h"
|
| #include "content/public/browser/render_view_host.h"
|
| #include "googleurl/src/gurl.h"
|
| +#include "ui/gfx/codec/png_codec.h"
|
| +#include "ui/gfx/image/image_skia.h"
|
|
|
| // static
|
| int FaviconUtil::DownloadFavicon(content::RenderViewHost* rvh,
|
| @@ -17,3 +21,28 @@ int FaviconUtil::DownloadFavicon(content::RenderViewHost* rvh,
|
| image_size));
|
| return id;
|
| }
|
| +// static
|
| +gfx::Image FaviconUtil::SelectFaviconFramesFromPNGs(
|
| + const std::vector<history::FaviconBitmapResult>& png_data,
|
| + const std::vector<ui::ScaleFactor> scale_factors,
|
| + int favicon_size) {
|
| + std::vector<SkBitmap> bitmaps;
|
| + for (size_t i = 0; i < png_data.size(); ++i) {
|
| + if (!png_data[i].is_valid())
|
| + continue;
|
| +
|
| + SkBitmap bitmap;
|
| + if (gfx::PNGCodec::Decode(png_data[i].bitmap_data->front(),
|
| + png_data[i].bitmap_data->size(),
|
| + &bitmap)) {
|
| + bitmaps.push_back(bitmap);
|
| + }
|
| + }
|
| +
|
| + if (bitmaps.empty())
|
| + return gfx::Image();
|
| +
|
| + gfx::ImageSkia resized_image_skia = SelectFaviconFrames(bitmaps,
|
| + ui::GetSupportedScaleFactors(), favicon_size, NULL);
|
| + return gfx::Image(resized_image_skia);
|
| +}
|
|
|