summaryrefslogtreecommitdiffstats
path: root/chrome/browser/favicon/favicon_util.cc
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-16 17:25:42 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-16 17:25:42 +0000
commit059d76b564813ef7080175dec989122bdcda91bd (patch)
treed6dea2fc9f3d4093f10621ca603b6e112506078d /chrome/browser/favicon/favicon_util.cc
parentbadba1ad344a4854a5b78112e1b83934c3dd7781 (diff)
downloadchromium_src-059d76b564813ef7080175dec989122bdcda91bd.zip
chromium_src-059d76b564813ef7080175dec989122bdcda91bd.tar.gz
chromium_src-059d76b564813ef7080175dec989122bdcda91bd.tar.bz2
This CL ensures that favicons always
1) Stores a 1x representation in history 2) Returns a 1x representation upon calling FaviconService::GetFaviconImageForURL() such that the 1x favicon can be pushed to sync. BUG=160503 Test=Manual, see instructions below 1) Go to http://www.corp.google.com/~pkotwicz/favicon_small_big/test.html on an iOS device and bookmark it. On the iOS device, the favicon should be red. 2) On a windows device, make sure that the favicon which is received via sync is blue Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=168079 Review URL: https://chromiumcodereview.appspot.com/11360233 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168233 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/favicon/favicon_util.cc')
-rw-r--r--chrome/browser/favicon/favicon_util.cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/chrome/browser/favicon/favicon_util.cc b/chrome/browser/favicon/favicon_util.cc
index 83a9fa9..6189afd 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);
}