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

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

Issue 11360233: Ensure that favicons always have 1x representation regardless of whether the platform supports it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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') | ui/base/layout.cc » ('j') | 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 83a9fa9e728188bd6abb1ddd6aa6e71abe07e009..6189afd3f9677f788148791cc6904ab183af598d 100644
--- a/chrome/browser/favicon/favicon_util.cc
+++ b/chrome/browser/favicon/favicon_util.cc
@@ -13,6 +13,30 @@
#include "ui/gfx/image/image_skia.h"
// static
+std::vector<ui::ScaleFactor> FaviconUtil::GetFaviconScaleFactors() {
+ const float kScale1x = ui::GetScaleFactorScale(ui::SCALE_FACTOR_100P);
+ std::vector<ui::ScaleFactor> favicon_scale_factors =
+ ui::GetSupportedScaleFactors();
+
+ // The scale factors returned from ui::GetSupportedScaleFactors() are sorted.
+ // Insert the 1x scale factor such that GetFaviconScaleFactors() is sorted as
+ // well.
+ size_t insert_index = favicon_scale_factors.size();
+ for (size_t i = 0; i < favicon_scale_factors.size(); ++i) {
+ float scale = ui::GetScaleFactorScale(favicon_scale_factors[i]);
+ if (scale == kScale1x) {
+ return favicon_scale_factors;
+ } else if (scale > kScale1x) {
+ insert_index = i;
+ break;
+ }
+ }
+ favicon_scale_factors.insert(favicon_scale_factors.begin() + insert_index,
+ ui::SCALE_FACTOR_100P);
+ return favicon_scale_factors;
+}
+
+// static
int FaviconUtil::DownloadFavicon(content::RenderViewHost* rvh,
const GURL& url,
int image_size) {
@@ -43,6 +67,6 @@ gfx::Image FaviconUtil::SelectFaviconFramesFromPNGs(
return gfx::Image();
gfx::ImageSkia resized_image_skia = SelectFaviconFrames(bitmaps,
- ui::GetSupportedScaleFactors(), favicon_size, NULL);
+ scale_factors, favicon_size, NULL);
return gfx::Image(resized_image_skia);
}
« no previous file with comments | « chrome/browser/favicon/favicon_util.h ('k') | ui/base/layout.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698