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 "chrome/browser/favicon/favicon_service.h" | 5 #include "chrome/browser/favicon/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/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 callback, | 264 callback, |
265 desired_size); | 265 desired_size); |
266 | 266 |
267 if (history_service_) { | 267 if (history_service_) { |
268 return history_service_->GetFaviconForID( | 268 return history_service_->GetFaviconForID( |
269 favicon_id, desired_size, callback_runner, tracker); | 269 favicon_id, desired_size, callback_runner, tracker); |
270 } | 270 } |
271 return RunWithEmptyResultAsync(callback_runner, tracker); | 271 return RunWithEmptyResultAsync(callback_runner, tracker); |
272 } | 272 } |
273 | 273 |
| 274 base::CancelableTaskTracker::TaskId FaviconService::HackGetBigIcon( |
| 275 const GURL& page_url, |
| 276 int desired_size_in_pixel, |
| 277 const favicon_base::FaviconRawBitmapCallback& callback, |
| 278 base::CancelableTaskTracker* tracker) { |
| 279 favicon_base::FaviconResultsCallback favicon_results_callback = |
| 280 Bind(&FaviconService::RunFaviconRawBitmapCallbackWithBitmapResults, |
| 281 base::Unretained(this), |
| 282 callback, |
| 283 0); |
| 284 if (history_service_) { |
| 285 int icon_types = |
| 286 favicon_base::TOUCH_ICON | favicon_base::TOUCH_PRECOMPOSED_ICON; |
| 287 std::vector<int> desired_sizes_in_pixel; |
| 288 desired_sizes_in_pixel.push_back(desired_size_in_pixel); |
| 289 return history_service_->GetFaviconsForURL(page_url, |
| 290 icon_types, |
| 291 desired_sizes_in_pixel, |
| 292 favicon_results_callback, |
| 293 tracker); |
| 294 } |
| 295 return RunWithEmptyResultAsync(favicon_results_callback, tracker); |
| 296 } |
| 297 |
274 void FaviconService::SetFaviconOutOfDateForPage(const GURL& page_url) { | 298 void FaviconService::SetFaviconOutOfDateForPage(const GURL& page_url) { |
275 if (history_service_) | 299 if (history_service_) |
276 history_service_->SetFaviconsOutOfDateForPage(page_url); | 300 history_service_->SetFaviconsOutOfDateForPage(page_url); |
277 } | 301 } |
278 | 302 |
279 void FaviconService::CloneFavicon(const GURL& old_page_url, | 303 void FaviconService::CloneFavicon(const GURL& old_page_url, |
280 const GURL& new_page_url) { | 304 const GURL& new_page_url) { |
281 if (history_service_) | 305 if (history_service_) |
282 history_service_->CloneFavicons(old_page_url, new_page_url); | 306 history_service_->CloneFavicons(old_page_url, new_page_url); |
283 } | 307 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, | 441 if (!gfx::PNGCodec::EncodeBGRASkBitmap(resized_image.AsBitmap(), false, |
418 &resized_bitmap_data)) { | 442 &resized_bitmap_data)) { |
419 callback.Run(favicon_base::FaviconRawBitmapResult()); | 443 callback.Run(favicon_base::FaviconRawBitmapResult()); |
420 return; | 444 return; |
421 } | 445 } |
422 | 446 |
423 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( | 447 bitmap_result.bitmap_data = base::RefCountedBytes::TakeVector( |
424 &resized_bitmap_data); | 448 &resized_bitmap_data); |
425 callback.Run(bitmap_result); | 449 callback.Run(bitmap_result); |
426 } | 450 } |
OLD | NEW |