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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/favicon/favicon_util.h ('k') | ui/base/layout.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/favicon/favicon_util.h" 5 #include "chrome/browser/favicon/favicon_util.h"
6 6
7 #include "chrome/browser/history/history_types.h" 7 #include "chrome/browser/history/history_types.h"
8 #include "chrome/browser/history/select_favicon_frames.h" 8 #include "chrome/browser/history/select_favicon_frames.h"
9 #include "chrome/common/icon_messages.h" 9 #include "chrome/common/icon_messages.h"
10 #include "content/public/browser/render_view_host.h" 10 #include "content/public/browser/render_view_host.h"
11 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
12 #include "ui/gfx/codec/png_codec.h" 12 #include "ui/gfx/codec/png_codec.h"
13 #include "ui/gfx/image/image_skia.h" 13 #include "ui/gfx/image/image_skia.h"
14 14
15 // static 15 // static
16 std::vector<ui::ScaleFactor> FaviconUtil::GetFaviconScaleFactors() {
17 static std::vector<ui::ScaleFactor>* favicon_scale_factors =
sky 2012/11/15 18:14:54 Is it really worth caching this? If we do, it mean
18 new std::vector<ui::ScaleFactor>();
19 if (favicon_scale_factors->empty()) {
20 favicon_scale_factors->push_back(ui::SCALE_FACTOR_100P);
21
22 std::vector<ui::ScaleFactor> supported_scale_factors =
23 ui::GetSupportedScaleFactors();
24 for (size_t i = 0; i < supported_scale_factors.size(); ++i) {
25 ui::ScaleFactor scale_factor = supported_scale_factors[i];
26 if (scale_factor != ui::SCALE_FACTOR_100P)
27 favicon_scale_factors->push_back(scale_factor);
28 }
29 }
30 return *favicon_scale_factors;
31 }
32
33 // static
16 int FaviconUtil::DownloadFavicon(content::RenderViewHost* rvh, 34 int FaviconUtil::DownloadFavicon(content::RenderViewHost* rvh,
17 const GURL& url, 35 const GURL& url,
18 int image_size) { 36 int image_size) {
19 static int id = 0; 37 static int id = 0;
20 rvh->Send(new IconMsg_DownloadFavicon(rvh->GetRoutingID(), ++id, url, 38 rvh->Send(new IconMsg_DownloadFavicon(rvh->GetRoutingID(), ++id, url,
21 image_size)); 39 image_size));
22 return id; 40 return id;
23 } 41 }
24 // static 42 // static
25 gfx::Image FaviconUtil::SelectFaviconFramesFromPNGs( 43 gfx::Image FaviconUtil::SelectFaviconFramesFromPNGs(
(...skipping 10 matching lines...) Expand all
36 png_data[i].bitmap_data->size(), 54 png_data[i].bitmap_data->size(),
37 &bitmap)) { 55 &bitmap)) {
38 bitmaps.push_back(bitmap); 56 bitmaps.push_back(bitmap);
39 } 57 }
40 } 58 }
41 59
42 if (bitmaps.empty()) 60 if (bitmaps.empty())
43 return gfx::Image(); 61 return gfx::Image();
44 62
45 gfx::ImageSkia resized_image_skia = SelectFaviconFrames(bitmaps, 63 gfx::ImageSkia resized_image_skia = SelectFaviconFrames(bitmaps,
46 ui::GetSupportedScaleFactors(), favicon_size, NULL); 64 scale_factors, favicon_size, NULL);
47 return gfx::Image(resized_image_skia); 65 return gfx::Image(resized_image_skia);
48 } 66 }
OLDNEW
« 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