OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/fav_icon_helper.h" | 5 #include "chrome/browser/fav_icon_helper.h" |
6 | 6 |
7 #include "base/gfx/png_decoder.h" | 7 #include "base/gfx/png_decoder.h" |
8 #include "base/gfx/png_encoder.h" | 8 #include "base/gfx/png_encoder.h" |
9 #include "chrome/browser/render_view_host.h" | 9 #include "chrome/browser/render_view_host.h" |
10 #include "chrome/browser/tab_contents/navigation_entry.h" | 10 #include "chrome/browser/tab_contents/navigation_entry.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // possible to get here. | 77 // possible to get here. |
78 return; | 78 return; |
79 } | 79 } |
80 | 80 |
81 const SkBitmap& sized_image = | 81 const SkBitmap& sized_image = |
82 (image.width() == kFavIconSize && image.height() == kFavIconSize) | 82 (image.width() == kFavIconSize && image.height() == kFavIconSize) |
83 ? image : ConvertToFavIconSize(image); | 83 ? image : ConvertToFavIconSize(image); |
84 | 84 |
85 if (GetHistoryService() && !profile()->IsOffTheRecord()) { | 85 if (GetHistoryService() && !profile()->IsOffTheRecord()) { |
86 std::vector<unsigned char> image_data; | 86 std::vector<unsigned char> image_data; |
87 SkAutoLockPixels icon_lock(sized_image); | 87 PNGEncoder::EncodeBGRASkBitmap(sized_image, false, &image_data); |
88 PNGEncoder::Encode( | |
89 reinterpret_cast<unsigned char*>(sized_image.getPixels()), | |
90 PNGEncoder::FORMAT_BGRA, sized_image.width(), | |
91 sized_image.height(), sized_image.width()* 4, false, | |
92 &image_data); | |
93 GetHistoryService()->SetFavIcon(i->second.url, i->second.fav_icon_url, | 88 GetHistoryService()->SetFavIcon(i->second.url, i->second.fav_icon_url, |
94 image_data); | 89 image_data); |
95 } | 90 } |
96 | 91 |
97 if (i->second.url == url_) { | 92 if (i->second.url == url_) { |
98 NavigationEntry* entry = GetEntry(); | 93 NavigationEntry* entry = GetEntry(); |
99 if (entry) | 94 if (entry) |
100 UpdateFavIcon(entry, sized_image); | 95 UpdateFavIcon(entry, sized_image); |
101 } | 96 } |
102 | 97 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 int height = image.height(); | 252 int height = image.height(); |
258 if (width > 0 && height > 0) { | 253 if (width > 0 && height > 0) { |
259 calc_favicon_target_size(&width, &height); | 254 calc_favicon_target_size(&width, &height); |
260 return skia::ImageOperations::Resize( | 255 return skia::ImageOperations::Resize( |
261 image, skia::ImageOperations::RESIZE_LANCZOS3, | 256 image, skia::ImageOperations::RESIZE_LANCZOS3, |
262 width, height); | 257 width, height); |
263 } | 258 } |
264 return image; | 259 return image; |
265 } | 260 } |
266 | 261 |
OLD | NEW |