Chromium Code Reviews| Index: components/favicon/core/favicon_service_impl.cc |
| diff --git a/components/favicon/core/favicon_service_impl.cc b/components/favicon/core/favicon_service_impl.cc |
| index a57c99e9ce2f2f23032ad4049aa7653ccae49337..82d5f08c9eec85776598187a277cbf4e2a046bdb 100644 |
| --- a/components/favicon/core/favicon_service_impl.cc |
| +++ b/components/favicon/core/favicon_service_impl.cc |
| @@ -231,6 +231,29 @@ void FaviconServiceImpl::SetFavicons(const GURL& page_url, |
| history_service_->SetFavicons(page_url, icon_type, icon_url, bitmaps); |
| } |
| +void FaviconServiceImpl::SetLastResortFavicons( |
| + const GURL& page_url, |
| + const GURL& icon_url, |
| + favicon_base::IconType icon_type, |
| + const gfx::Image& image, |
| + base::Callback<void(bool)> callback) { |
| + gfx::ImageSkia image_skia = image.AsImageSkia(); |
|
sdefresne
2017/03/23 10:24:41
This code looks like it is a copy-n-paste version
mastiz
2017/03/23 12:03:23
Done, thanks!
|
| + image_skia.EnsureRepsForSupportedScales(); |
| + const std::vector<gfx::ImageSkiaRep>& image_reps = image_skia.image_reps(); |
| + std::vector<SkBitmap> bitmaps; |
| + const std::vector<float> favicon_scales = favicon_base::GetFaviconScales(); |
| + for (size_t i = 0; i < image_reps.size(); ++i) { |
| + // Don't save if the scale isn't one of supported favicon scales. |
| + if (std::find(favicon_scales.begin(), favicon_scales.end(), |
| + image_reps[i].scale()) == favicon_scales.end()) { |
| + continue; |
| + } |
| + bitmaps.push_back(image_reps[i].sk_bitmap()); |
| + } |
| + history_service_->SetLastResortFavicons(page_url, icon_type, icon_url, |
| + bitmaps, callback); |
| +} |
| + |
| void FaviconServiceImpl::UnableToDownloadFavicon(const GURL& icon_url) { |
| MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); |
| missing_favicon_urls_.insert(url_hash); |