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

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

Issue 18501013: Move most importer code to chrome/utility/importer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CanImport Created 7 years, 5 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 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/favicon/favicon_types.h" 7 #include "chrome/browser/favicon/favicon_types.h"
8 #include "chrome/browser/history/select_favicon_frames.h" 8 #include "chrome/browser/history/select_favicon_frames.h"
9 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/child/image_decoder_utils.h" 10 #include "content/public/child/image_decoder_utils.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 int desired_size) { 193 int desired_size) {
194 std::vector<gfx::Size> sizes; 194 std::vector<gfx::Size> sizes;
195 for (size_t i = 0; i < bitmaps.size(); ++i) 195 for (size_t i = 0; i < bitmaps.size(); ++i)
196 sizes.push_back(gfx::Size(bitmaps[i].width(), bitmaps[i].height())); 196 sizes.push_back(gfx::Size(bitmaps[i].width(), bitmaps[i].height()));
197 std::vector<size_t> selected_bitmap_indices; 197 std::vector<size_t> selected_bitmap_indices;
198 SelectFaviconFrameIndices(sizes, scale_factors, desired_size, 198 SelectFaviconFrameIndices(sizes, scale_factors, desired_size,
199 &selected_bitmap_indices, NULL); 199 &selected_bitmap_indices, NULL);
200 DCHECK_EQ(1u, selected_bitmap_indices.size()); 200 DCHECK_EQ(1u, selected_bitmap_indices.size());
201 return selected_bitmap_indices[0]; 201 return selected_bitmap_indices[0];
202 } 202 }
203
204 // static
205 bool FaviconUtil::ReencodeFavicon(const unsigned char* src_data,
206 size_t src_len,
207 std::vector<unsigned char>* png_data) {
208 // Decode the favicon using WebKit's image decoder.
209 SkBitmap decoded = content::DecodeImage(
210 src_data,
211 gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize),
212 src_len);
213 if (decoded.empty())
214 return false; // Unable to decode.
215
216 if (decoded.width() != gfx::kFaviconSize ||
217 decoded.height() != gfx::kFaviconSize) {
218 // The bitmap is not the correct size, re-sample.
219 int new_width = decoded.width();
220 int new_height = decoded.height();
221 gfx::CalculateFaviconTargetSize(&new_width, &new_height);
222 decoded = skia::ImageOperations::Resize(
223 decoded, skia::ImageOperations::RESIZE_LANCZOS3, new_width, new_height);
224 }
225
226 // Encode our bitmap as a PNG.
227 gfx::PNGCodec::EncodeBGRASkBitmap(decoded, false, png_data);
228 return true;
229 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698