1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/favicon/core/favicon_util.h"
8 #include "base/callback.h"
9 #include "components/favicon/core/favicon_service.h"
14 // Adapter to convert a FaviconImageCallback into a FaviconRawBitmapCallback
15 // for GetFaviconImageForPageURL.
16 void RunCallbackWithImage(
17 const favicon_base::FaviconImageCallback
& callback
,
18 const favicon_base::FaviconRawBitmapResult
& bitmap_result
) {
19 favicon_base::FaviconImageResult result
;
20 if (bitmap_result
.is_valid()) {
21 result
.image
= gfx::Image::CreateFrom1xPNGBytes(
22 bitmap_result
.bitmap_data
->front(), bitmap_result
.bitmap_data
->size());
23 result
.icon_url
= bitmap_result
.icon_url
;
32 base::CancelableTaskTracker::TaskId
GetFaviconImageForPageURL(
33 FaviconService
* favicon_service
,
35 favicon_base::IconType type
,
36 const favicon_base::FaviconImageCallback
& callback
,
37 base::CancelableTaskTracker
* tracker
) {
39 return base::CancelableTaskTracker::kBadTaskId
;
41 if (type
== favicon_base::FAVICON
) {
42 return favicon_service
->GetFaviconImageForPageURL(page_url
, callback
,
46 return favicon_service
->GetRawFaviconForPageURL(
47 page_url
, type
, 0, base::Bind(&RunCallbackWithImage
, callback
), tracker
);
50 } // namespace favicon