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

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

Issue 10912088: favicon handler: Consider all frames when receiving favicons from the history db (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 8 years, 3 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
« no previous file with comments | « chrome/browser/favicon/favicon_handler.cc ('k') | chrome/browser/favicon/favicon_tab_helper.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_service.h" 5 #include "chrome/browser/favicon/favicon_service.h"
6 6
7 #include "chrome/browser/favicon/favicon_util.h"
7 #include "chrome/browser/favicon/select_favicon_frames.h" 8 #include "chrome/browser/favicon/select_favicon_frames.h"
8 #include "chrome/browser/history/history.h" 9 #include "chrome/browser/history/history.h"
9 #include "chrome/browser/history/history_backend.h" 10 #include "chrome/browser/history/history_backend.h"
10 #include "chrome/browser/history/history_service_factory.h" 11 #include "chrome/browser/history/history_service_factory.h"
11 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" 12 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
12 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 14 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "ui/gfx/codec/png_codec.h" 15 #include "ui/gfx/codec/png_codec.h"
15 #include "ui/gfx/image/image_skia.h" 16 #include "ui/gfx/image/image_skia.h"
16 17
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 223 }
223 return handle; 224 return handle;
224 } 225 }
225 226
226 void FaviconService::GetFaviconImageCallback( 227 void FaviconService::GetFaviconImageCallback(
227 int desired_size_in_dip, 228 int desired_size_in_dip,
228 FaviconImageCallback callback, 229 FaviconImageCallback callback,
229 Handle handle, 230 Handle handle,
230 std::vector<history::FaviconBitmapResult> favicon_bitmap_results, 231 std::vector<history::FaviconBitmapResult> favicon_bitmap_results,
231 history::IconURLSizesMap icon_url_sizes_map) { 232 history::IconURLSizesMap icon_url_sizes_map) {
232 std::vector<SkBitmap> sk_bitmaps;
233 for (size_t i = 0; i < favicon_bitmap_results.size(); ++i) {
234 if (favicon_bitmap_results[i].is_valid()) {
235 scoped_refptr<base::RefCountedMemory> bitmap_data =
236 favicon_bitmap_results[i].bitmap_data;
237 SkBitmap out_bitmap;
238 if (gfx::PNGCodec::Decode(bitmap_data->front(), bitmap_data->size(),
239 &out_bitmap)) {
240 sk_bitmaps.push_back(out_bitmap);
241 }
242 }
243 }
244 history::FaviconImageResult image_result; 233 history::FaviconImageResult image_result;
245 image_result.image = gfx::Image(SelectFaviconFrames( 234 image_result.image = FaviconUtil::SelectFaviconFramesFromPNGs(
246 sk_bitmaps, ui::GetSupportedScaleFactors(), desired_size_in_dip, NULL)); 235 favicon_bitmap_results,
247 image_result.icon_url = favicon_bitmap_results.empty() ? 236 ui::GetSupportedScaleFactors(),
237 desired_size_in_dip);
238 image_result.icon_url = image_result.image.IsEmpty() ?
248 GURL() : favicon_bitmap_results[0].icon_url; 239 GURL() : favicon_bitmap_results[0].icon_url;
249
250 callback.Run(handle, image_result); 240 callback.Run(handle, image_result);
251 } 241 }
252 242
253 void FaviconService::GetRawFaviconCallback( 243 void FaviconService::GetRawFaviconCallback(
254 int desired_size_in_dip, 244 int desired_size_in_dip,
255 ui::ScaleFactor desired_scale_factor, 245 ui::ScaleFactor desired_scale_factor,
256 FaviconRawCallback callback, 246 FaviconRawCallback callback,
257 Handle handle, 247 Handle handle,
258 std::vector<history::FaviconBitmapResult> favicon_bitmap_results, 248 std::vector<history::FaviconBitmapResult> favicon_bitmap_results,
259 history::IconURLSizesMap icon_url_sizes_map) { 249 history::IconURLSizesMap icon_url_sizes_map) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( 293 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector(
304 &resized_bitmap_data); 294 &resized_bitmap_data);
305 callback.Run(handle, bitmap_result); 295 callback.Run(handle, bitmap_result);
306 } 296 }
307 297
308 void FaviconService::ForwardEmptyResultAsync(GetFaviconRequest* request) { 298 void FaviconService::ForwardEmptyResultAsync(GetFaviconRequest* request) {
309 request->ForwardResultAsync(request->handle(), 299 request->ForwardResultAsync(request->handle(),
310 std::vector<history::FaviconBitmapResult>(), 300 std::vector<history::FaviconBitmapResult>(),
311 history::IconURLSizesMap()); 301 history::IconURLSizesMap());
312 } 302 }
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_handler.cc ('k') | chrome/browser/favicon/favicon_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698