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

Unified Diff: components/favicon/core/favicon_service_impl.cc

Issue 2721363002: Extend LargeIconService to fetch missing favicons from a Google server (Closed)
Patch Set: Add fallback_opts=TYPE Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/favicon/core/favicon_service_impl.h ('k') | components/favicon/core/large_icon_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..98557b2476647f77240bab105c6987c41386edce 100644
--- a/components/favicon/core/favicon_service_impl.cc
+++ b/components/favicon/core/favicon_service_impl.cc
@@ -36,6 +36,23 @@ std::vector<int> GetPixelSizesForFaviconScales(int size_in_dip) {
return sizes_in_pixel;
}
+std::vector<SkBitmap> ExtractSkBitmapsToStore(const gfx::Image& image) {
+ gfx::ImageSkia image_skia = image.AsImageSkia();
+ 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());
+ }
+ return bitmaps;
+}
+
} // namespace
FaviconServiceImpl::FaviconServiceImpl(
@@ -215,20 +232,18 @@ void FaviconServiceImpl::SetFavicons(const GURL& page_url,
const GURL& icon_url,
favicon_base::IconType icon_type,
const gfx::Image& image) {
- gfx::ImageSkia image_skia = image.AsImageSkia();
- 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_->SetFavicons(page_url, icon_type, icon_url, bitmaps);
+ history_service_->SetFavicons(page_url, icon_type, icon_url,
+ ExtractSkBitmapsToStore(image));
+}
+
+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) {
+ history_service_->SetLastResortFavicons(
+ page_url, icon_type, icon_url, ExtractSkBitmapsToStore(image), callback);
}
void FaviconServiceImpl::UnableToDownloadFavicon(const GURL& icon_url) {
« no previous file with comments | « components/favicon/core/favicon_service_impl.h ('k') | components/favicon/core/large_icon_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698