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

Side by Side Diff: components/favicon/core/favicon_service_impl.cc

Issue 2721363002: Extend LargeIconService to fetch missing favicons from a Google server (Closed)
Patch Set: Addressed comments. 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 unified diff | Download patch
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 "components/favicon/core/favicon_service_impl.h" 5 #include "components/favicon/core/favicon_service_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <cmath> 8 #include <cmath>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // Don't save if the scale isn't one of supported favicon scales. 224 // Don't save if the scale isn't one of supported favicon scales.
225 if (std::find(favicon_scales.begin(), favicon_scales.end(), 225 if (std::find(favicon_scales.begin(), favicon_scales.end(),
226 image_reps[i].scale()) == favicon_scales.end()) { 226 image_reps[i].scale()) == favicon_scales.end()) {
227 continue; 227 continue;
228 } 228 }
229 bitmaps.push_back(image_reps[i].sk_bitmap()); 229 bitmaps.push_back(image_reps[i].sk_bitmap());
230 } 230 }
231 history_service_->SetFavicons(page_url, icon_type, icon_url, bitmaps); 231 history_service_->SetFavicons(page_url, icon_type, icon_url, bitmaps);
232 } 232 }
233 233
234 void FaviconServiceImpl::SetExpiredFaviconsIfNoneKnown(
235 const GURL& page_url,
236 const GURL& icon_url,
237 favicon_base::IconType icon_type,
238 const gfx::Image& image) {
239 gfx::ImageSkia image_skia = image.AsImageSkia();
240 image_skia.EnsureRepsForSupportedScales();
241 const std::vector<gfx::ImageSkiaRep>& image_reps = image_skia.image_reps();
242 std::vector<SkBitmap> bitmaps;
243 const std::vector<float> favicon_scales = favicon_base::GetFaviconScales();
244 for (size_t i = 0; i < image_reps.size(); ++i) {
245 // Don't save if the scale isn't one of supported favicon scales.
246 if (std::find(favicon_scales.begin(), favicon_scales.end(),
247 image_reps[i].scale()) == favicon_scales.end()) {
248 continue;
249 }
250 bitmaps.push_back(image_reps[i].sk_bitmap());
251 }
252 history_service_->SetExpiredFaviconsIfNoneKnown(page_url, icon_type, icon_url,
253 bitmaps);
254 }
255
234 void FaviconServiceImpl::UnableToDownloadFavicon(const GURL& icon_url) { 256 void FaviconServiceImpl::UnableToDownloadFavicon(const GURL& icon_url) {
235 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); 257 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec());
236 missing_favicon_urls_.insert(url_hash); 258 missing_favicon_urls_.insert(url_hash);
237 } 259 }
238 260
239 bool FaviconServiceImpl::WasUnableToDownloadFavicon( 261 bool FaviconServiceImpl::WasUnableToDownloadFavicon(
240 const GURL& icon_url) const { 262 const GURL& icon_url) const {
241 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); 263 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec());
242 return missing_favicon_urls_.find(url_hash) != missing_favicon_urls_.end(); 264 return missing_favicon_urls_.find(url_hash) != missing_favicon_urls_.end();
243 } 265 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 const std::vector<favicon_base::FaviconRawBitmapResult>& 308 const std::vector<favicon_base::FaviconRawBitmapResult>&
287 favicon_bitmap_results) { 309 favicon_bitmap_results) {
288 TRACE_EVENT0( 310 TRACE_EVENT0(
289 "browser", 311 "browser",
290 "FaviconServiceImpl::RunFaviconRawBitmapCallbackWithBitmapResults"); 312 "FaviconServiceImpl::RunFaviconRawBitmapCallbackWithBitmapResults");
291 callback.Run( 313 callback.Run(
292 ResizeFaviconBitmapResult(favicon_bitmap_results, desired_size_in_pixel)); 314 ResizeFaviconBitmapResult(favicon_bitmap_results, desired_size_in_pixel));
293 } 315 }
294 316
295 } // namespace favicon 317 } // namespace favicon
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698