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

Side by Side Diff: chrome/browser/favicon/favicon_util.cc

Issue 11411180: move favicon download code from chrome/ into content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
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"
10 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
11 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
12 #include "ui/gfx/codec/png_codec.h" 11 #include "ui/gfx/codec/png_codec.h"
13 #include "ui/gfx/image/image_skia.h" 12 #include "ui/gfx/image/image_skia.h"
14 13
15 // static 14 // static
16 std::vector<ui::ScaleFactor> FaviconUtil::GetFaviconScaleFactors() { 15 std::vector<ui::ScaleFactor> FaviconUtil::GetFaviconScaleFactors() {
17 const float kScale1x = ui::GetScaleFactorScale(ui::SCALE_FACTOR_100P); 16 const float kScale1x = ui::GetScaleFactorScale(ui::SCALE_FACTOR_100P);
18 std::vector<ui::ScaleFactor> favicon_scale_factors = 17 std::vector<ui::ScaleFactor> favicon_scale_factors =
19 ui::GetSupportedScaleFactors(); 18 ui::GetSupportedScaleFactors();
(...skipping 10 matching lines...) Expand all
30 insert_index = i; 29 insert_index = i;
31 break; 30 break;
32 } 31 }
33 } 32 }
34 favicon_scale_factors.insert(favicon_scale_factors.begin() + insert_index, 33 favicon_scale_factors.insert(favicon_scale_factors.begin() + insert_index,
35 ui::SCALE_FACTOR_100P); 34 ui::SCALE_FACTOR_100P);
36 return favicon_scale_factors; 35 return favicon_scale_factors;
37 } 36 }
38 37
39 // static 38 // static
40 int FaviconUtil::DownloadFavicon(content::RenderViewHost* rvh,
41 const GURL& url,
42 int image_size) {
43 static int id = 0;
44 rvh->Send(new IconMsg_DownloadFavicon(rvh->GetRoutingID(), ++id, url,
45 image_size));
46 return id;
47 }
48 // static
49 gfx::Image FaviconUtil::SelectFaviconFramesFromPNGs( 39 gfx::Image FaviconUtil::SelectFaviconFramesFromPNGs(
50 const std::vector<history::FaviconBitmapResult>& png_data, 40 const std::vector<history::FaviconBitmapResult>& png_data,
51 const std::vector<ui::ScaleFactor> scale_factors, 41 const std::vector<ui::ScaleFactor> scale_factors,
52 int favicon_size) { 42 int favicon_size) {
53 std::vector<SkBitmap> bitmaps; 43 std::vector<SkBitmap> bitmaps;
54 for (size_t i = 0; i < png_data.size(); ++i) { 44 for (size_t i = 0; i < png_data.size(); ++i) {
55 if (!png_data[i].is_valid()) 45 if (!png_data[i].is_valid())
56 continue; 46 continue;
57 47
58 SkBitmap bitmap; 48 SkBitmap bitmap;
(...skipping 19 matching lines...) Expand all
78 int desired_size) { 68 int desired_size) {
79 std::vector<gfx::Size> sizes; 69 std::vector<gfx::Size> sizes;
80 for (size_t i = 0; i < bitmaps.size(); ++i) 70 for (size_t i = 0; i < bitmaps.size(); ++i)
81 sizes.push_back(gfx::Size(bitmaps[i].width(), bitmaps[i].height())); 71 sizes.push_back(gfx::Size(bitmaps[i].width(), bitmaps[i].height()));
82 std::vector<size_t> selected_bitmap_indices; 72 std::vector<size_t> selected_bitmap_indices;
83 SelectFaviconFrameIndices(sizes, scale_factors, desired_size, 73 SelectFaviconFrameIndices(sizes, scale_factors, desired_size,
84 &selected_bitmap_indices, NULL); 74 &selected_bitmap_indices, NULL);
85 DCHECK_EQ(1u, selected_bitmap_indices.size()); 75 DCHECK_EQ(1u, selected_bitmap_indices.size());
86 return selected_bitmap_indices[0]; 76 return selected_bitmap_indices[0];
87 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698