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

Unified Diff: chrome/browser/favicon/favicon_util.cc

Issue 10912088: favicon handler: Consider all frames when receiving favicons from the history db (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 8 years, 3 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
« no previous file with comments | « chrome/browser/favicon/favicon_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
« no previous file with comments | « chrome/browser/favicon/favicon_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698