Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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::SetLastResortFavicons( | |
| 235 const GURL& page_url, | |
| 236 const GURL& icon_url, | |
| 237 favicon_base::IconType icon_type, | |
| 238 const gfx::Image& image, | |
| 239 base::Callback<void(bool)> callback) { | |
| 240 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!
| |
| 241 image_skia.EnsureRepsForSupportedScales(); | |
| 242 const std::vector<gfx::ImageSkiaRep>& image_reps = image_skia.image_reps(); | |
| 243 std::vector<SkBitmap> bitmaps; | |
| 244 const std::vector<float> favicon_scales = favicon_base::GetFaviconScales(); | |
| 245 for (size_t i = 0; i < image_reps.size(); ++i) { | |
| 246 // Don't save if the scale isn't one of supported favicon scales. | |
| 247 if (std::find(favicon_scales.begin(), favicon_scales.end(), | |
| 248 image_reps[i].scale()) == favicon_scales.end()) { | |
| 249 continue; | |
| 250 } | |
| 251 bitmaps.push_back(image_reps[i].sk_bitmap()); | |
| 252 } | |
| 253 history_service_->SetLastResortFavicons(page_url, icon_type, icon_url, | |
| 254 bitmaps, callback); | |
| 255 } | |
| 256 | |
| 234 void FaviconServiceImpl::UnableToDownloadFavicon(const GURL& icon_url) { | 257 void FaviconServiceImpl::UnableToDownloadFavicon(const GURL& icon_url) { |
| 235 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); | 258 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); |
| 236 missing_favicon_urls_.insert(url_hash); | 259 missing_favicon_urls_.insert(url_hash); |
| 237 } | 260 } |
| 238 | 261 |
| 239 bool FaviconServiceImpl::WasUnableToDownloadFavicon( | 262 bool FaviconServiceImpl::WasUnableToDownloadFavicon( |
| 240 const GURL& icon_url) const { | 263 const GURL& icon_url) const { |
| 241 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); | 264 MissingFaviconURLHash url_hash = base::Hash(icon_url.spec()); |
| 242 return missing_favicon_urls_.find(url_hash) != missing_favicon_urls_.end(); | 265 return missing_favicon_urls_.find(url_hash) != missing_favicon_urls_.end(); |
| 243 } | 266 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 const std::vector<favicon_base::FaviconRawBitmapResult>& | 309 const std::vector<favicon_base::FaviconRawBitmapResult>& |
| 287 favicon_bitmap_results) { | 310 favicon_bitmap_results) { |
| 288 TRACE_EVENT0( | 311 TRACE_EVENT0( |
| 289 "browser", | 312 "browser", |
| 290 "FaviconServiceImpl::RunFaviconRawBitmapCallbackWithBitmapResults"); | 313 "FaviconServiceImpl::RunFaviconRawBitmapCallbackWithBitmapResults"); |
| 291 callback.Run( | 314 callback.Run( |
| 292 ResizeFaviconBitmapResult(favicon_bitmap_results, desired_size_in_pixel)); | 315 ResizeFaviconBitmapResult(favicon_bitmap_results, desired_size_in_pixel)); |
| 293 } | 316 } |
| 294 | 317 |
| 295 } // namespace favicon | 318 } // namespace favicon |
| OLD | NEW |