From 8655122b4e38f645838cdb53dcecdaf8da3ca3f1 Mon Sep 17 00:00:00 2001 From: "pkotwicz@chromium.org" Date: Tue, 28 Aug 2012 20:12:55 +0000 Subject: Revert 153695 - Change FaviconData to be able to return data for multiple bitmaps for same icon URL. Add methods to FaviconService to get gfx::Image more easily from Favicon. Remove unused FaviconService::GetFaviconForID(). BUG=138553 Test=Compiles, FaviconHandlerTest.* pass. Review URL: https://chromiumcodereview.appspot.com/10870022 TBR=pkotwicz@chromium.org Review URL: https://chromiumcodereview.appspot.com/10891007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153714 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/jumplist_win.cc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'chrome/browser/jumplist_win.cc') diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc index 7c0a6a0..d66c0da 100644 --- a/chrome/browser/jumplist_win.cc +++ b/chrome/browser/jumplist_win.cc @@ -44,7 +44,6 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/codec/png_codec.h" -#include "ui/gfx/favicon_size.h" #include "ui/gfx/icon_util.h" using content::BrowserThread; @@ -702,15 +701,15 @@ bool JumpList::StartLoadingFavicon() { } FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); - handle_ = favicon_service->GetFaviconImageForURL( - profile_, url, history::FAVICON, gfx::kFaviconSize, &favicon_consumer_, + handle_ = favicon_service->GetFaviconForURL( + profile_, url, history::FAVICON, &favicon_consumer_, base::Bind(&JumpList::OnFaviconDataAvailable, base::Unretained(this))); return true; } void JumpList::OnFaviconDataAvailable( FaviconService::Handle handle, - const history::FaviconImageResult& image_result) { + history::FaviconData favicon) { // If there is currently a favicon request in progress, it is now outdated, // as we have received another, so nullify the handle from the old request. handle_ = NULL; @@ -719,9 +718,9 @@ void JumpList::OnFaviconDataAvailable( base::AutoLock auto_lock(list_lock_); // Attach the received data to the ShellLinkItem object. // This data will be decoded by the RunUpdate method. - if (!image_result.image.IsEmpty()) { + if (favicon.is_valid()) { if (!icon_urls_.empty() && icon_urls_.front().second) - icon_urls_.front().second->SetIconData(image_result.image.AsBitmap()); + icon_urls_.front().second->SetIconData(favicon.image_data); } if (!icon_urls_.empty()) @@ -765,11 +764,11 @@ void JumpList::RunUpdate() { file_util::CreateDirectory(icon_dir_); // Create temporary icon files for shortcuts in the "Most Visited" category. - CreateIconFiles(local_most_visited_pages); + DecodeIconData(local_most_visited_pages); // Create temporary icon files for shortcuts in the "Recently Closed" // category. - CreateIconFiles(local_recently_closed_pages); + DecodeIconData(local_recently_closed_pages); // We finished collecting all resources needed for updating an appliation // JumpList. So, create a new JumpList and replace the current JumpList @@ -778,11 +777,17 @@ void JumpList::RunUpdate() { local_recently_closed_pages); } -void JumpList::CreateIconFiles(const ShellLinkItemList& item_list) { +void JumpList::DecodeIconData(const ShellLinkItemList& item_list) { for (ShellLinkItemList::const_iterator item = item_list.begin(); item != item_list.end(); ++item) { - FilePath icon_path; - if (CreateIconFile((*item)->data(), icon_dir_, &icon_path)) - (*item)->SetIcon(icon_path.value(), 0, true); + SkBitmap icon_bitmap; + if ((*item)->data().get() && + gfx::PNGCodec::Decode((*item)->data()->front(), + (*item)->data()->size(), + &icon_bitmap)) { + FilePath icon_path; + if (CreateIconFile(icon_bitmap, icon_dir_, &icon_path)) + (*item)->SetIcon(icon_path.value(), 0, true); + } } } -- cgit v1.1