diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-28 17:51:02 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-28 17:51:02 +0000 |
commit | 8dae8e1278013adbce40e80465ad0706d2c76a39 (patch) | |
tree | aabea70f97adb9015b99e149c96c094708fb200e /chrome/browser/bookmarks | |
parent | 677d094cd882689ded7083a0f4d110b4e0cf200d (diff) | |
download | chromium_src-8dae8e1278013adbce40e80465ad0706d2c76a39.zip chromium_src-8dae8e1278013adbce40e80465ad0706d2c76a39.tar.gz chromium_src-8dae8e1278013adbce40e80465ad0706d2c76a39.tar.bz2 |
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
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153695 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks')
-rw-r--r-- | chrome/browser/bookmarks/bookmark_html_writer.cc | 11 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_html_writer.h | 5 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_model.cc | 19 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_model.h | 5 |
4 files changed, 21 insertions, 19 deletions
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc index 9bbd49d..501bed3 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer.cc @@ -31,6 +31,7 @@ #include "net/base/file_stream.h" #include "net/base/net_errors.h" #include "ui/base/l10n/l10n_util.h" +#include "ui/gfx/favicon_size.h" using content::BrowserThread; @@ -460,7 +461,8 @@ bool BookmarkFaviconFetcher::FetchNextFavicon() { if (favicons_map_->end() == iter) { FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( profile_, Profile::EXPLICIT_ACCESS); - favicon_service->GetFaviconForURL(profile_, GURL(url), history::FAVICON, + favicon_service->GetRawFaviconForURL(profile_, GURL(url), + history::FAVICON, gfx::kFaviconSize, ui::SCALE_FACTOR_100P, &favicon_consumer_, base::Bind(&BookmarkFaviconFetcher::OnFaviconDataAvailable, base::Unretained(this))); @@ -474,14 +476,15 @@ bool BookmarkFaviconFetcher::FetchNextFavicon() { void BookmarkFaviconFetcher::OnFaviconDataAvailable( FaviconService::Handle handle, - history::FaviconData favicon) { + const history::FaviconBitmapResult& bitmap_result) { GURL url; if (!bookmark_urls_.empty()) { url = GURL(bookmark_urls_.front()); bookmark_urls_.pop_front(); } - if (favicon.is_valid() && !url.is_empty()) { - favicons_map_->insert(make_pair(url.spec(), favicon.image_data)); + if (bitmap_result.is_valid() && !url.is_empty()) { + favicons_map_->insert( + make_pair(url.spec(), bitmap_result.bitmap_data)); } if (FetchNextFavicon()) { diff --git a/chrome/browser/bookmarks/bookmark_html_writer.h b/chrome/browser/bookmarks/bookmark_html_writer.h index 0eaf637..0b94e9e 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.h +++ b/chrome/browser/bookmarks/bookmark_html_writer.h @@ -64,8 +64,9 @@ class BookmarkFaviconFetcher: public content::NotificationObserver { // Favicon fetch callback. After all favicons are fetched executes // html output on the file thread. - void OnFaviconDataAvailable(FaviconService::Handle handle, - history::FaviconData favicon); + void OnFaviconDataAvailable( + FaviconService::Handle handle, + const history::FaviconBitmapResult& bitmap_result); // The Profile object used for accessing FaviconService, bookmarks model. Profile* profile_; diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc index fcdea2f..30d361b 100644 --- a/chrome/browser/bookmarks/bookmark_model.cc +++ b/chrome/browser/bookmarks/bookmark_model.cc @@ -29,6 +29,7 @@ #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util_collator.h" +#include "ui/gfx/favicon_size.h" #include "ui/gfx/image/image_util.h" using base::Time; @@ -777,21 +778,16 @@ BookmarkPermanentNode* BookmarkModel::CreatePermanentNode( void BookmarkModel::OnFaviconDataAvailable( FaviconService::Handle handle, - history::FaviconData favicon) { + const history::FaviconImageResult& image_result) { BookmarkNode* node = load_consumer_.GetClientData( FaviconServiceFactory::GetForProfile( profile_, Profile::EXPLICIT_ACCESS), handle); DCHECK(node); node->set_favicon_load_handle(0); - if (favicon.is_valid()) { - scoped_ptr<gfx::Image> favicon_image( - gfx::ImageFromPNGEncodedData(favicon.image_data->front(), - favicon.image_data->size())); - if (favicon_image.get()) { - node->set_favicon(*favicon_image.get()); - FaviconLoaded(node); - } + if (!image_result.image.IsEmpty()) { + node->set_favicon(image_result.image); + FaviconLoaded(node); } } @@ -804,8 +800,9 @@ void BookmarkModel::LoadFavicon(BookmarkNode* node) { profile_, Profile::EXPLICIT_ACCESS); if (!favicon_service) return; - FaviconService::Handle handle = favicon_service->GetFaviconForURL( - profile_, node->url(), history::FAVICON, &load_consumer_, + FaviconService::Handle handle = favicon_service->GetFaviconImageForURL( + profile_, node->url(), history::FAVICON, gfx::kFaviconSize, + &load_consumer_, base::Bind(&BookmarkModel::OnFaviconDataAvailable, base::Unretained(this))); load_consumer_.SetClientData(favicon_service, handle, node); diff --git a/chrome/browser/bookmarks/bookmark_model.h b/chrome/browser/bookmarks/bookmark_model.h index 1f1f8ea..f78d602 100644 --- a/chrome/browser/bookmarks/bookmark_model.h +++ b/chrome/browser/bookmarks/bookmark_model.h @@ -414,8 +414,9 @@ class BookmarkModel : public content::NotificationObserver, // Notification that a favicon has finished loading. If we can decode the // favicon, FaviconLoaded is invoked. - void OnFaviconDataAvailable(FaviconService::Handle handle, - history::FaviconData favicon); + void OnFaviconDataAvailable( + FaviconService::Handle handle, + const history::FaviconImageResult& image_result); // Invoked from the node to load the favicon. Requests the favicon from the // favicon service. |