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/browser/favicon_service.h" | 5 #include "components/favicon/core/browser/favicon_service.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/hash.h" | 9 #include "base/hash.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 base::CancelableTaskTracker* tracker) { | 193 base::CancelableTaskTracker* tracker) { |
194 return GetFaviconForPageURLImpl( | 194 return GetFaviconForPageURLImpl( |
195 page_url, | 195 page_url, |
196 icon_types, | 196 icon_types, |
197 GetPixelSizesForFaviconScales(desired_size_in_dip), | 197 GetPixelSizesForFaviconScales(desired_size_in_dip), |
198 callback, | 198 callback, |
199 tracker); | 199 tracker); |
200 } | 200 } |
201 | 201 |
202 base::CancelableTaskTracker::TaskId | 202 base::CancelableTaskTracker::TaskId |
| 203 FaviconService::GetGenericLargeIconForPageURL( |
| 204 const GURL& page_url, |
| 205 int desired_size_in_pixel, |
| 206 const favicon_base::FaviconRawBitmapCallback& callback, |
| 207 base::CancelableTaskTracker* tracker) { |
| 208 favicon_base::FaviconResultsCallback favicon_results_callback = |
| 209 Bind(&FaviconService::RunFaviconRawBitmapCallbackWithBitmapResults, |
| 210 base::Unretained(this), |
| 211 callback, |
| 212 desired_size_in_pixel); |
| 213 if (history_service_) { |
| 214 int icon_types = |
| 215 favicon_base::TOUCH_ICON | favicon_base::TOUCH_PRECOMPOSED_ICON; |
| 216 std::vector<int> desired_sizes_in_pixel; |
| 217 desired_sizes_in_pixel.push_back(desired_size_in_pixel); |
| 218 return history_service_->GetFaviconsForURL(page_url, |
| 219 icon_types, |
| 220 desired_sizes_in_pixel, |
| 221 favicon_results_callback, |
| 222 tracker); |
| 223 } |
| 224 return RunWithEmptyResultAsync(favicon_results_callback, tracker); |
| 225 } |
| 226 |
| 227 base::CancelableTaskTracker::TaskId |
203 FaviconService::UpdateFaviconMappingsAndFetch( | 228 FaviconService::UpdateFaviconMappingsAndFetch( |
204 const GURL& page_url, | 229 const GURL& page_url, |
205 const std::vector<GURL>& icon_urls, | 230 const std::vector<GURL>& icon_urls, |
206 int icon_types, | 231 int icon_types, |
207 int desired_size_in_dip, | 232 int desired_size_in_dip, |
208 const favicon_base::FaviconResultsCallback& callback, | 233 const favicon_base::FaviconResultsCallback& callback, |
209 base::CancelableTaskTracker* tracker) { | 234 base::CancelableTaskTracker* tracker) { |
210 if (history_service_) { | 235 if (history_service_) { |
211 return history_service_->UpdateFaviconMappingsAndFetch( | 236 return history_service_->UpdateFaviconMappingsAndFetch( |
212 page_url, | 237 page_url, |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, | 407 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, |
383 &resized_bitmap_data)) { | 408 &resized_bitmap_data)) { |
384 callback.Run(favicon_base::FaviconRawBitmapResult()); | 409 callback.Run(favicon_base::FaviconRawBitmapResult()); |
385 return; | 410 return; |
386 } | 411 } |
387 | 412 |
388 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( | 413 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( |
389 &resized_bitmap_data); | 414 &resized_bitmap_data); |
390 callback.Run(bitmap_result); | 415 callback.Run(bitmap_result); |
391 } | 416 } |
OLD | NEW |