| 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_handler.h" | 5 #include "chrome/browser/favicon/favicon_handler.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
| 15 #include "chrome/browser/favicon/favicon_service.h" |
| 15 #include "chrome/browser/favicon/favicon_service_factory.h" | 16 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 16 #include "chrome/browser/favicon/favicon_util.h" | 17 #include "chrome/browser/favicon/favicon_util.h" |
| 17 #include "components/favicon_base/select_favicon_frames.h" | 18 #include "components/favicon_base/select_favicon_frames.h" |
| 18 #include "skia/ext/image_operations.h" | 19 #include "skia/ext/image_operations.h" |
| 19 #include "ui/gfx/codec/png_codec.h" | 20 #include "ui/gfx/codec/png_codec.h" |
| 20 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
| 21 #include "ui/gfx/image/image_skia.h" | 22 #include "ui/gfx/image/image_skia.h" |
| 22 #include "ui/gfx/image/image_util.h" | 23 #include "ui/gfx/image/image_util.h" |
| 23 | 24 |
| 24 using favicon::FaviconURL; | 25 using favicon::FaviconURL; |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 NOTREACHED(); | 483 NOTREACHED(); |
| 483 return 0; | 484 return 0; |
| 484 } | 485 } |
| 485 return driver_->StartDownload(image_url, max_bitmap_size); | 486 return driver_->StartDownload(image_url, max_bitmap_size); |
| 486 } | 487 } |
| 487 | 488 |
| 488 void FaviconHandler::UpdateFaviconMappingAndFetch( | 489 void FaviconHandler::UpdateFaviconMappingAndFetch( |
| 489 const GURL& page_url, | 490 const GURL& page_url, |
| 490 const GURL& icon_url, | 491 const GURL& icon_url, |
| 491 favicon_base::IconType icon_type, | 492 favicon_base::IconType icon_type, |
| 492 const FaviconService::FaviconResultsCallback& callback, | 493 const favicon_base::FaviconResultsCallback& callback, |
| 493 base::CancelableTaskTracker* tracker) { | 494 base::CancelableTaskTracker* tracker) { |
| 494 // TODO(pkotwicz): pass in all of |image_urls_| to | 495 // TODO(pkotwicz): pass in all of |image_urls_| to |
| 495 // UpdateFaviconMappingsAndFetch(). | 496 // UpdateFaviconMappingsAndFetch(). |
| 496 std::vector<GURL> icon_urls; | 497 std::vector<GURL> icon_urls; |
| 497 icon_urls.push_back(icon_url); | 498 icon_urls.push_back(icon_url); |
| 498 client_->GetFaviconService()->UpdateFaviconMappingsAndFetch( | 499 client_->GetFaviconService()->UpdateFaviconMappingsAndFetch( |
| 499 page_url, icon_urls, icon_type, preferred_icon_size(), callback, tracker); | 500 page_url, icon_urls, icon_type, preferred_icon_size(), callback, tracker); |
| 500 } | 501 } |
| 501 | 502 |
| 502 void FaviconHandler::GetFaviconFromFaviconService( | 503 void FaviconHandler::GetFaviconFromFaviconService( |
| 503 const GURL& icon_url, | 504 const GURL& icon_url, |
| 504 favicon_base::IconType icon_type, | 505 favicon_base::IconType icon_type, |
| 505 const FaviconService::FaviconResultsCallback& callback, | 506 const favicon_base::FaviconResultsCallback& callback, |
| 506 base::CancelableTaskTracker* tracker) { | 507 base::CancelableTaskTracker* tracker) { |
| 507 client_->GetFaviconService()->GetFavicon( | 508 client_->GetFaviconService()->GetFavicon( |
| 508 icon_url, icon_type, preferred_icon_size(), callback, tracker); | 509 icon_url, icon_type, preferred_icon_size(), callback, tracker); |
| 509 } | 510 } |
| 510 | 511 |
| 511 void FaviconHandler::GetFaviconForURLFromFaviconService( | 512 void FaviconHandler::GetFaviconForURLFromFaviconService( |
| 512 const GURL& page_url, | 513 const GURL& page_url, |
| 513 int icon_types, | 514 int icon_types, |
| 514 const FaviconService::FaviconResultsCallback& callback, | 515 const favicon_base::FaviconResultsCallback& callback, |
| 515 base::CancelableTaskTracker* tracker) { | 516 base::CancelableTaskTracker* tracker) { |
| 516 client_->GetFaviconService()->GetFaviconForURL( | 517 client_->GetFaviconService()->GetFaviconForURL( |
| 517 FaviconService::FaviconForURLParams( | 518 FaviconService::FaviconForURLParams( |
| 518 page_url, icon_types, preferred_icon_size()), | 519 page_url, icon_types, preferred_icon_size()), |
| 519 callback, | 520 callback, |
| 520 tracker); | 521 tracker); |
| 521 } | 522 } |
| 522 | 523 |
| 523 void FaviconHandler::SetHistoryFavicons(const GURL& page_url, | 524 void FaviconHandler::SetHistoryFavicons(const GURL& page_url, |
| 524 const GURL& icon_url, | 525 const GURL& icon_url, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 } else { | 686 } else { |
| 686 gfx::Size largest = i->icon_sizes[index]; | 687 gfx::Size largest = i->icon_sizes[index]; |
| 687 i->icon_sizes.clear(); | 688 i->icon_sizes.clear(); |
| 688 i->icon_sizes.push_back(largest); | 689 i->icon_sizes.push_back(largest); |
| 689 ++i; | 690 ++i; |
| 690 } | 691 } |
| 691 } | 692 } |
| 692 std::stable_sort(image_urls_.begin(), image_urls_.end(), | 693 std::stable_sort(image_urls_.begin(), image_urls_.end(), |
| 693 CompareIconSize); | 694 CompareIconSize); |
| 694 } | 695 } |
| OLD | NEW |